diff options
author | Michael Lando <ml636r@att.com> | 2017-06-09 03:19:04 +0300 |
---|---|---|
committer | Michael Lando <ml636r@att.com> | 2017-06-09 03:19:04 +0300 |
commit | ed64b5edff15e702493df21aa3230b81593e6133 (patch) | |
tree | a4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui | |
parent | 280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff) |
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1
Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui')
1176 files changed, 37066 insertions, 44429 deletions
diff --git a/catalog-ui/Gruntfile.js b/catalog-ui/Gruntfile.js deleted file mode 100644 index 619d8316a1..0000000000 --- a/catalog-ui/Gruntfile.js +++ /dev/null @@ -1,807 +0,0 @@ -// Generated on 2015-04-28 using -// generator-webapp 0.5.1 -'use strict'; - -// # Globbing -// for performance reasons we're only matching one level down: -// 'test/spec/{,*/}*.js' -// If you want to recursively match all subfolders, use: -// 'test/spec/**/*.js' - -module.exports = function (grunt) { - - // Time how long tasks take. Can help when optimizing build times - require('time-grunt')(grunt); - - // Load grunt tasks automatically - require('load-grunt-tasks')(grunt); - - // Configurable paths - var config = { - app: 'app', - appModuleName: 'sdcApp', - dist: 'app/dist' - }; - - // Define the configuration for all the tasks - grunt.initConfig({ - - // Project settings - config: config, - - // Watches files for changes and runs tasks based on the changed files - watch: { - html: { - files: ['<%= config.app %>/scripts/**/*.html'], - tasks: ['ngtemplates:app'] - }, - less: { - files: ['<%= config.app %>/**/*.less'], - tasks: ['less:all'] - }, - ts: { - files: ['<%= config.app %>/scripts/**/*.ts'], - tasks: ['ts:all'] - }, - bower: { - files: ['bower.json'], - tasks: ['wiredep'] - }, - - gruntfile: { - files: ['Gruntfile.js'] - }, - - livereload: { - options: { - livereload: '<%= connect.options.livereload %>' - }, - files: [ - '<%= config.app %>/{,*/}*.html', - '<%= config.app %>/scripts/**/*.html', - '<%= config.app %>/scripts/**/*.css', - '.tmp/styles/{,*/}*.css', - '<%= config.app %>/images/{,*/}*' - ] - }, - configurations: { - files: [ - 'configurations/*.json' - ], - tasks: ['ngconstant'] - } - }, - - ngconstant: { - options: { - dest: 'app/scripts/modules/configurations.js', - name: 'Sdc.Config' - }, - main: { - constants: { - sdcConfig: grunt.file.readJSON(grunt.option('env') ? 'configurations/' + grunt.option('env') + '.json' : 'configurations/prod.json'), - sdcMenu: grunt.file.readJSON('configurations/menu.json') - } - } - }, - - express: { - options: { - port: process.env.PORT || 9000 - }, - mock: { - options: { - script: 'server-mock/mock-server.js' - } - } - }, - - ts: { - all: { - src: [ - 'app/scripts/**/*.ts', - 'typings/**/*.ts' - ], - reference: 'app/scripts/references.ts' - }, - single: { - src: [] - } - }, - ngtemplates: { - app: { - options: { - module: '<%= config.appModuleName %>', - prefix: '/' - }, - src: [ - '<%= config.app %>/scripts/**/*.html', - '!index.html' - ], - dest: '<%= config.app %>/scripts/templates.js' - } - }, - less: { - all: { - options: { - paths: ['<%= config.app %>/scripts', - '<%= config.app %>/styles'] - }, - files: { - '<%= config.app %>/styles/app.css': '<%= config.app %>/styles/app.less' - } - }, - single: { - paths: ['<%= config.app %>/scripts', - '<%= config.app %>/styles'], - files: [] - } - }, - - injector: { - options: {}, - // Inject application script files into index.html (doesn't include bower) - scripts_models: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_models -->', - endtag: '<!-- endinjector:js_models -->' - }, - files: { - '<%= config.app %>/index.html': [ - [ - '<%= config.app %>/scripts/models/**/*.js', - '!<%= config.app %>/scripts/models/**/*-tests.js' - ] - ] - } - }, - - scripts_utils: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_utils -->', - endtag: '<!-- endinjector:js_utils -->' - }, - files: { - '<%= config.app %>/index.html': [ - [ - '<%= config.app %>/scripts/utils/**/*.js', - '!<%= config.app %>/scripts/models/**/*-tests.js' - ] - ] - } - }, - - scripts_filters: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_filters -->', - endtag: '<!-- endinjector:js_filters -->' - }, - files: { - '<%= config.app %>/index.html': [ - ['<%= config.app %>/scripts/filters/**/*.js', - '!<%= config.app %>/scripts/filters/**/*-tests.js' - ] - ] - } - }, - - scripts_directives: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_directives -->', - endtag: '<!-- endinjector:js_directives -->' - }, - files: { - '<%= config.app %>/index.html': [ - ['<%= config.app %>/scripts/directives/**/*.js', - '!<%= config.app %>/scripts/directives/**/*-tests.js' - ] - ] - } - }, - - scripts_services: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_services -->', - endtag: '<!-- endinjector:js_services -->' - }, - files: { - '<%= config.app %>/index.html': [ - ['<%= config.app %>/scripts/services/**/*.js', - '!<%= config.app %>/scripts/services/**/*-tests.js' - ] - ] - } - }, - - scripts_view_models: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - return '<script src="' + filePath + '"></script>'; - }, - starttag: '<!-- injector:js_view_models -->', - endtag: '<!-- endinjector:js_view_models -->' - }, - files: { - '<%= config.app %>/index.html': [ - ['<%= config.app %>/scripts/view-models/**/*.js', - '!<%= config.app %>/scripts/view-models/**/*-tests.js'] - ] - } - }, - - // Inject component less into app.less - less: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/scripts/', '../scripts/'); - filePath = filePath.replace('/app/styles/', ''); - return '@import \'' + filePath + '\';'; - }, - starttag: '// injector:less', - endtag: '// endinjector:less' - }, - files: { - '<%= config.app %>/styles/app.less': [ - '<%= config.app %>/styles/**/*.less', - '<%= config.app %>/scripts/**/*.less', - '!<%= config.app %>/styles/app.less' - ] - } - }, - - // Inject component css into index.html - css: { - options: { - transform: function (filePath) { - filePath = filePath.replace('/app/', ''); - filePath = filePath.replace('/.tmp/', ''); - return '<link rel="stylesheet" href="' + filePath + '">'; - }, - starttag: '<!-- injector:css -->', - endtag: '<!-- endinjector -->' - }, - files: { - '<%= config.app %>/index.html': [ - '<%= config.app %>/scripts/**/*.css', - '<%= config.app %>/styles/**/*.css', - '!<%= config.app %>/styles/app.css' - ] - } - } - }, - - // The actual grunt server settings - connect: { - options: { - port: 9000, - open: true, - livereload: 35729, - // Change this to '0.0.0.0' to access the server from outside - hostname: 'localhost' - }, - livereload: { - options: { - middleware: function (connect) { - return [ - connect().use(function (req, res, next) { - var mockApis = require('./configurations/mock.json').sdcConfig; - var userType; - switch (grunt.option('role')) { - case "admin": - userType = mockApis.userTypes.admin; - break; - case "tester": - userType = mockApis.userTypes.tester; - break; - case "governor": - userType = mockApis.userTypes.governor; - break; - case "ops": - userType = mockApis.userTypes.ops; - break; - case "designer": - userType = mockApis.userTypes.designer; - break; - case "product_strategist": - userType = mockApis.userTypes.product_strategist; - break; - case "product_manager": - userType = mockApis.userTypes.product_manager; - break; - default: - userType = mockApis.userTypes.designer; - } - res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId); - res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email); - res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName); - res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName); - next(); - }), - connect().use(require('http-proxy-middleware')(['/onboarding', '/onboarding-api'], { - target: 'http://feHost:8181/', - changeOrigin: true, - secure: false - })), - connect().use('/bower_components', connect.static('./bower_components')), - connect().use('/non_bower_components', connect.static('./non_bower_components')), - connect.static(config.app) - ]; - } - } - }, - dist: { - options: { - base: '<%= config.dist %>', - livereload: false - } - } - }, - - // Empties folders to start fresh - clean: { - generated: { - files: [{ - dot: true, - src: [ - '<%= config.app %>/scripts/**/*.js', - '<%= config.app %>/scripts/**/*.css', - '!<%= config.app %>/scripts/**/welcome/styles/*.css', - '<%= config.app %>/styles/**/*.css', - '<%= config.app %>/scripts/**/*.js.map' - ] - }] - }, - dist: { - files: [{ - dot: true, - src: [ - '.tmp', - '<%= config.dist %>/*', - '!<%= config.dist %>/.git*' - ] - }] - }, - server: '.tmp' - }, - // Add vendor prefixed styles - autoprefixer: { - options: { - browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'] - }, - dist: { - files: [{ - expand: true, - cwd: '.tmp/css/', - src: '{,*/**/}*.css', - dest: '.tmp/css/' - }] - } - }, - - // Automatically inject Bower components into the HTML file - wiredep: { - app: { - ignorePath: /^\/|\.\.\//, - src: ['<%= config.app %>/index.html'] - } - }, - - // Renames files for browser caching purposes - rev: { - dist: { - files: { - src: [ - '<%= config.dist %>/scripts/{,*/}*.js', - '<%= config.dist %>/styles/{,*/}*.css', - '<%= config.dist %>/images/{,*/}*.*', - '!<%= config.dist %>/images/resource-icons/{,*/}*.*', - '!<%= config.dist %>/images/service-icons/{,*/}*.*', - '!<%= config.dist %>/images/relationship-icons/{,*/}*.*', - '<%= config.dist %>/*.{ico,png}' - ] - } - } - }, - - // Reads HTML for usemin blocks to enable smart builds that automatically - // concat, minify and revision files. Creates configurations in memory so - // additional tasks can operate on them - useminPrepare: { - options: { - dest: '<%= config.dist %>' - }, - sdc: { - src: ['<%= config.app %>/index.html'] - }, - html: '<%= config.app %>/index.html' - }, - - // Performs rewrites based on rev and the useminPrepare configuration - usemin: { - options: { - assetsDirs: [ - '<%= config.dist %>', - '<%= config.dist %>/images', - '<%= config.dist %>/styles' - ], - // This is so we update image references in our ng-templates - patterns: { - js: [ - [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images'] - ] - } - }, - html: ['<%= config.dist %>/{,*/}*.html'], - css: ['<%= config.dist %>/styles/{,*/}*.css'], - js: ['<%= config.dist %>/public/{,*/}*.js'] - }, - - // The following *-min tasks produce minified files in the dist folder - imagemin: { - dist: { - files: [{ - expand: true, - cwd: '<%= config.app %>/images', - src: '<%= config.app %>/**/*.{gif,jpeg,jpg,png}', - dest: '<%= config.dist %>/images' - }] - } - }, - - svgmin: { - dist: { - files: [{ - expand: true, - cwd: '<%= config.app %>/images', - src: '{,*/}*.svg', - dest: '<%= config.dist %>/images' - }] - } - }, - - htmlmin: { - dist: { - options: { - collapseBooleanAttributes: true, - collapseWhitespace: true, - conservativeCollapse: true, - removeAttributeQuotes: true, - removeCommentsFromCDATA: true, - removeEmptyAttributes: true, - removeOptionalTags: true, - removeRedundantAttributes: true, - useShortDoctype: true - }, - files: [{ - expand: true, - cwd: '<%= config.dist %>', - src: '{,*/}*.html', - dest: '<%= config.dist %>' - }] - } - }, - -// By default, your `index.html`'s <!-- Usemin block --> will take care -// of minification. These next options are pre-configured if you do not -// wish to use the Usemin blocks. - cssmin: { - dist: { - files: { - '<%= config.dist %>/styles/main.css': [ - '.tmp/css/{,*/**/}*.css', - '<%= config.app %>/scripts/{,*/**/}*.css', - '<%= config.app %>/styles/app.css' - ] - } - } - }, - uglify: { - dist: { - files: { - '<%= config.dist %>/scripts/scripts.js': [ - '<%= config.dist %>/scripts/scripts.js' - ] - } - } - }, - replace: { - cssReplace: { - src: ['<%= config.app %>/scripts/{,*/**/}*.css', - '<%= config.app %>/styles/{,*/**/}*.css'], - overwrite: true, - replacements: [ - { - from: '../../../images/', - to: '../images/' - }, - { - from: '../../images/', - to: '../images/' - }, - { - from: '../../../fonts/', - to: '../fonts/' - }, - { - from: '../../fonts/', - to: '../fonts/' - }, - { - from: '../../../styles/images/', - to: 'images/' - } - ] - }, - }, - concat: { - dist: { - options: { - separator: ';\n' - }, - src: ['<%= config.app %>/scripts/{,*/**/}*.js'], - dest: '.tmp/concat/scripts/scripts.js' - }, - generated: { - options: { - separator: '\n' - } - } - }, - - // Copies remaining files to places other tasks can use - copy: { - dist: { - files: [{ - expand: true, - dot: true, - cwd: '<%= config.app %>', - dest: '<%= config.dist %>', - src: [ - '*.{ico,png,txt}', - '.htaccess', - // 'bower_components/**/*', - 'styles/images/**/*', - 'styles/fonts/**/*', - 'languages/**/*', - 'index.html' - ] - }, { - src: 'node_modules/apache-server-configs/dist/.htaccess', - dest: '<%= config.dist %>/.htaccess' - }, - { - expand: true, - cwd: '.tmp/images', - dest: '<%= config.dist %>/images', - src: ['generated/*'] - }, - //TODO to remove this section after integration onboard finished - { - expand: true, - cwd: '<%= config.app %>/third-party', - dest: '<%= config.dist %>/third-party', - src: ['onboard_bundle_full.js'] - }, - { - expand: true, - dest: '<%= config.dist %>', - src: [ - 'package.json' - ] - } - ] - }, - styles: { - expand: true, - cwd: '<%= config.app %>/styles', - dest: '.tmp/css/', - src: '{,*/**/}*.css' - } - }, - - // Run some tasks in parallel to speed up build process - concurrent: { - server: ['copy:styles'], - test: ['copy:styles'], - dist: [ - 'copy:styles', - 'imagemin' - ] - }, - - // Test settings - karma: { - dev: { - configFile: "tests/karma.unit.conf.js", - singleRun: true, - options: { - browsers: ['Chrome'], - coverageReporter: { - type: 'html', - dir: 'tests/Coverage' - } - } - }, - debug: { - configFile: "tests/karma.unit.conf.js", - singleRun: false, - //comment out this line if you want to cancel the watch and see the UT log - background: true, - options: { - browsers: ['Chrome'], - reporters: [ - 'junit', - 'dots', - 'progress' - ] - } - }, - jenkins: { - configFile: "tests/karma.unit.conf.js", - singleRun: true, - options: { - browsers: ['PhantomJS'], - coverageReporter: { - type: 'text-summary', - dir: 'tests/Coverage', - file: 'coverage.txt' - } - } - } - }, - - tslint: { - options: { - configuration: 'tslint.json' - }, - files: { - src: ['<%= config.app %>/**/*.ts'] - } - } - }); - - grunt.registerTask('serve', 'start the server and preview your app, --allow-remote for remote access', function (target) { - - var env = grunt.option('env'); - - if (grunt.option('allow-remote')) { - grunt.config.set('connect.options.hostname', '0.0.0.0'); - } - if (target === 'dist') { - return grunt.task.run(['build', 'connect:dist:keepalive']); - } - - - if (env === 'mock') { - grunt.task.run([ - 'express:mock', - 'clean:generated', - 'ts:all', - 'ngtemplates:app', - 'injector', - 'less:all', - 'ngconstant', - 'wiredep', - 'concurrent:server', - 'autoprefixer', - 'connect:livereload', - 'watch:html', - 'watch:less' - ]); - } - - grunt.task.run([ - 'clean:generated', - 'ts:all', - 'ngtemplates:app', - 'injector', - 'less:all', - 'ngconstant', - 'wiredep', - 'concurrent:server', - 'autoprefixer', - 'connect:livereload', - 'watch' - ]); - }); - - grunt.registerTask('build', [ - 'clean:generated', - 'less:all', - 'ts:all', - 'ngconstant', - 'ngtemplates:app', - 'wiredep', - 'replace', - 'clean:dist', - 'useminPrepare:sdc', - 'concurrent:dist', - 'autoprefixer:dist', - 'concat', - 'copy:dist', - 'cssmin', - 'uglify', - 'rev', - 'usemin' - ]); - - grunt.registerTask("test", function (target) { - - if (!(target === 'debug' || target === 'dev' || target === 'jenkins')) { - throw new Error("target available for test are <dev|debug|jenkins>"); - } - var tasks = [ - // "tslint:karma", - // "ngconstant", - //// "concurrent:test", - // "servicesIconConstants", - // "autoprefixer", - // "ngtemplates:testsTemplates", - // "connect:test" - ]; - - tasks.push('karma:' + target); - if (target === 'debug') { - if (grunt.config.get('watch.ts')) { - tasks.push("watch:ts"); - } else { - throw new Error("target watch:ts is not available, verify that it exists in your Gruntfile"); - } - } - grunt.task.run(tasks); - }); - - - var lessSingleTask = function (filePath) { - var lessSingleFiles = [{ - expand: true, - src: [filePath.replace(/\\/g, '/')], - ext: '.css' - }]; - grunt.config('less.single.files', lessSingleFiles); - grunt.config('watch.less.tasks', 'less:single'); - - }; - - var tsSingleTask = function (filePath) { - - var tsSingleData = { - src: [filePath.replace(/\\/g, '/')] - }; - // grunt.config('ts.single', tsSingleData); - - }; - - var singleTaskByTaskName = { - //less: lessSingleTask, - ts: tsSingleTask - }; - - var onGruntWatchEvent = function (action, filepath, target) { - if (singleTaskByTaskName[target]) { - singleTaskByTaskName[target].call(undefined, filepath); - } - }; - grunt.event.on('watch', onGruntWatchEvent); -}; diff --git a/catalog-ui/README.md b/catalog-ui/README.md new file mode 100644 index 0000000000..c1f590a946 --- /dev/null +++ b/catalog-ui/README.md @@ -0,0 +1,39 @@ +# CatalogUi + +## Development server +Run "npm start" for a dev server. +Navigate to "http://localhost:9000/". +The app will automatically reload if you change any of the source files. + +--- Specify role --- +npm start -- --env.role designer + +npm run <role> + +## Build +--- dev --- +Run "npm run build" to build the project. +The build artifacts will be stored in the `dist/` directory. + +--- prod --- +Run "npm run build:prod" to build the project. +The build artifacts will be stored in the `dist/` directory. + +## Configuration +Dev server is configured in webpack.server.js file. +App configuration dev.js or prod.js and menu.js are located in configuration folder and required by app.ts according to __ENV__ parameter from webpack. + +## Running unit tests +## Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests +## Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +## Before running the tests make sure you are serving the app via `ng serve`. + +-- Working with WebStorm -- + +go to File --> Settings --> Languages & Frameworks + +Under JavaScript -> set JavaScript language version to ECMAScript6 +Under TypeScript -> select 'Enable TypeScript Compiler' and choose 'Use tsconfige.json' + diff --git a/catalog-ui/SETTING-ENVIRONMENT.md b/catalog-ui/SETTING-ENVIRONMENT.md deleted file mode 100644 index edccca1304..0000000000 --- a/catalog-ui/SETTING-ENVIRONMENT.md +++ /dev/null @@ -1,36 +0,0 @@ -# Prerequisites - -1. install [node.js](http://nodejs.org/download/) -2. install [git](http://git-scm.com/). __Make sure to select the option to add git into $PATH__ -3. install grunt with dependencies `npm install -g bower grunt-cli` - - if running on MacOS/Linux the command should be run with `sudo` - -# Running the server - -Make sure all the client and npm dependencies installed by running the following commands: - -1. `npm install` -2. `bower install` - - - -You are then presented with 3 options `ngnix`, `test`, `build` - -1. `grunt serve --env=mock` will setup a dev(nginx) server under `http://localhost:9000` with mock configurations. The are also `grunt serve:test` and `grunt serve:prod` options -2. `grunt test` will run all the unit tests in the project -3. `grunt build` will run a build process resulting with a `dist/` folder including the version ready to be deployed (this task should be mainly run on the CI server) -3. `grunt build:dev` will deploy to nginx a production artifact, (minify files) - -# Webstorm - -Although any text editor can be used to write angular applications Webstorm is the most convenient for the task. In case Webstorm is chosen make sure it has the following plugins: - -* `.editorconfig` - this plugin will keep line indentation same across all developers -* `angular.js` - this plugin will help autocompleting angular syntax -* `markdown` - this one will give nice support to write .md files such as this one you are reading right now - -These can be found in plugins settings section by pressing PC: `CTRL + SHIFT + A` MAC: `CMD + SHIFT + A` and typing addons - - ---> DO NOT COMMIT ANYTHING BEFORE RUNNING grunt build / grunt nginx / grunt nginx:mock --env=mock <-- diff --git a/catalog-ui/SETTING-MOCK-SERVER.md b/catalog-ui/SETTING-MOCK-SERVER.md deleted file mode 100644 index 5db508f225..0000000000 --- a/catalog-ui/SETTING-MOCK-SERVER.md +++ /dev/null @@ -1,53 +0,0 @@ -# Prerequisites - -1. install [node.js](http://nodejs.org/download/) -2. install [git](http://git-scm.com/). __Make sure to select the option to add git into $PATH__ -3. install dependencies [express,cors] npm install express, npm install cors - - - -# Create the server file -Example: - -############################################# -ar express = require('express'); -var mockUris = require('../configurations/mock.json'); -var cors = require('cors'); - - -var app = express(); - -// declare server cross browser -app.use(cors({ - origin: '*', - methods: 'GET, POST, PUT, DELETE', - allowedHeaders: 'Content-Type,Authorization,If-Modified-Since' -})); - -/******************************************* MOCKS ENPOINTS *************************************************/ -/* poiFind */ -app.get('/v1' + mockUris.generalConf.getPoiFind.split('v1')[1], function (req, res) { - var pois = require('./data/poi/poi-search.json'); // the json response for the api call - res.send(pois); -}); - -/**************************************************** *******************************************************/ -// declare server listener port -var server = app.listen(9999, function () { - console.log('mock server listening on port %d', server.address().port); -}); - -################################ - -#create mockDate - -1. create json file with the response. -2. add the api end point in the server file and declare the json file for the response/ - - - -# Running the server - -1. go to server file folder -2. run command : node <FileName> - diff --git a/catalog-ui/_angular-cli.json b/catalog-ui/_angular-cli.json new file mode 100644 index 0000000000..a19145fe12 --- /dev/null +++ b/catalog-ui/_angular-cli.json @@ -0,0 +1,53 @@ +{ + "project": { + "name": "SDC APP", + "ejected": true + }, + "apps": [ + { + "root": "src", + "outDir": "dist", + "assets": [ + "assets/styles/fonts", + "assets/styles/images", + "assets/styles/app.css" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "tsconfig": "tsconfig.json", + "testTsconfig": "tsconfig.json", + "prefix": "app", + "styles": [ + "styles.css" + ], + "scripts": [ + "../node_modules/angular/angular.min.js", + "../node_modules/angular-ui-router/release/angular-ui-router.min.js", + "../node_modules/restangular/dist/restangular.min.js", + "../node_modules/angular-filter/dist/angular-filter.min.js", + "../node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js", + "../node_modules/angular-bootstrap/ui-bootstrap.min.js", + "../node_modules/angular-resource/angular-resource.min.js", + "../node_modules/angular-base64/angular-base64.min.js", + "../node_modules/angular-uuid4/angular-uuid4.min.js" + ], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "defaults": { + "styleExt": "css", + "class": { + "spec": false + }, + "component": { + "spec": true, + "inlineStyle": false, + "inlineTemplate": false + } + } +} diff --git a/catalog-ui/app/index.html b/catalog-ui/app/index.html deleted file mode 100644 index f56fdfd256..0000000000 --- a/catalog-ui/app/index.html +++ /dev/null @@ -1,392 +0,0 @@ -<!doctype html> -<html class="no-js" data-ng-app="sdcApp"> -<head> - <meta charset="utf-8"> - <title>SDC</title> - <meta name="description" content=""> - <meta name="viewport" content="width=device-width"> - <link rel="shortcut icon" href="favicon.png" type="image/png"> - <!--<link rel="icon" href="favicon.png" type="image/png">--> - - <!-- build:css(.) styles/vendor.css --> - <!-- bower:css --> - <link rel="stylesheet" href="bower_components/perfect-scrollbar/src/perfect-scrollbar.css" /> - <link rel="stylesheet" href="bower_components/angular-tooltips/dist/angular-tooltips.min.css" /> - <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" /> - <link rel="stylesheet" href="bower_components/animate.css/animate.css" /> - <link rel="stylesheet" href="bower_components/angular-ui-notification/dist/angular-ui-notification.css" /> - <!-- endbower --> - <link rel="stylesheet" href="bower_components/angular-resizable/src/angular-resizable.css"/> - <link rel="stylesheet" href="bower_components/qtip2/jquery.qtip.min.css"/> - - - - <!-- endbuild --> - <!-- build:css(.tmp) styles/main.css --> - <link rel="stylesheet" href="styles/app.css"> - <!-- /include --> - - <!-- injector:css --> - - <!-- endinjector --> - <!-- endbuild --> - - <!-- include: "type": "css", "files": "scripts/*.css" --> - <!-- /include --> -</head> -<body data-ng-class="bodyClass"> -<!--[if lt IE 10]> -<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade - your browser</a> to improve your experience.</p> -<![endif]--> - - -<div class="sdc-loading-page"> - <h1 class="caption1">Signing in</h1> - <p class="caption2">Please wait. If you are using Internet Explorer, please reattempt access using Chrome or - Firefox.</p> - - </p> - - <div class="main-loader"> - <div class="loader"> - <svg class="circular" viewBox="25 25 50 50"> - <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10"/> - </svg> - </div> - </div> -</div> - -<div class="full-height" data-ui-view=""></div> - -<!-- build:js(.) scripts/vendor.js --> - -<!-- bower:js --> -<script src="bower_components/jquery/dist/jquery.js"></script> -<script src="bower_components/angular/angular.js"></script> -<script src="bower_components/angular-base64/angular-base64.js"></script> -<script src="bower_components/angular-base64-upload/src/angular-base64-upload.js"></script> -<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> -<script src="bower_components/jquery-ui/jquery-ui.js"></script> -<script src="bower_components/angular-dragdrop/src/angular-dragdrop.js"></script> -<script src="bower_components/angular-filter/dist/angular-filter.js"></script> -<script src="bower_components/angular-mocks/angular-mocks.js"></script> -<script src="bower_components/perfect-scrollbar/src/perfect-scrollbar.js"></script> -<script src="bower_components/angular-perfect-scrollbar/src/angular-perfect-scrollbar.js"></script> -<script src="bower_components/angular-resource/angular-resource.js"></script> -<script src="bower_components/angular-sanitize/angular-sanitize.js"></script> -<script src="bower_components/angular-tooltips/dist/angular-tooltips.min.js"></script> -<script src="bower_components/angular-translate/angular-translate.js"></script> -<script src="bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script> -<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script> -<script src="bower_components/angular-uuid4/angular-uuid4.js"></script> -<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script> -<script src="bower_components/checklist-model/checklist-model.js"></script> -<script src="bower_components/jspdf/dist/jspdf.min.js"></script> -<script src="bower_components/angular-clipboard/angular-clipboard.js"></script> -<script src="bower_components/angular-resizable/src/angular-resizable.js"></script> -<script src="bower_components/angular-ui-notification/dist/angular-ui-notification.js"></script> -<script src="bower_components/js-md5/src/md5.js"></script> -<script src="bower_components/cytoscape/dist/cytoscape.js"></script> -<script src="bower_components/lodash/lodash.js"></script> -<script src="bower_components/restangular/dist/restangular.js"></script> -<script src="bower_components/cytoscape-expand-collapse/cytoscape-expand-collapse.js"></script> -<script src="bower_components/ev-emitter/ev-emitter.js"></script> -<script src="bower_components/imagesloaded/imagesloaded.js"></script> -<script src="bower_components/qtip2/jquery.qtip.js"></script> -<script src="bower_components/qtip2/basic/jquery.qtip.js"></script> -<script src="bower_components/cytoscape-qtip/cytoscape-qtip.js"></script> -<!-- endbower --> -<script src="non_bower_components/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js"></script> -<!-- endbuild --> - - -<!-- build:js({app,.tmp}) scripts/main.js --> - - -<!-- include utils --> - -<script src="scripts/utils/dictionary/dictionary.js"></script> -<script src="scripts/utils/prototypes.js"></script> -<script src="scripts/utils/artifacts-utils.js"></script> -<script src="scripts/utils/file-utils.js"></script> -<script src="scripts/utils/validation-utils.js"></script> -<script src="scripts/utils/component-factory.js"></script> -<script src="scripts/utils/component-instance-factory.js"></script> -<script src="scripts/utils/change-lifecycle-state-handler.js"></script> -<script src="scripts/utils/modals-handler.js"></script> -<script src="scripts/utils/menu-handler.js"></script> -<script src="scripts/utils/constants.js"></script> -<script src="scripts/utils/common-utils.js"></script> -<script src="scripts/utils/functions.js"></script> - -<!-- endinjector:js_utils --> -<script src="scripts/modules/utils.js"></script> -<!-- /end include utils--> - -<!-- injector:js_models --> -<script src="scripts/models/activity.js"></script> -<script src="scripts/models/additional-information.js"></script> -<script src="scripts/models/app-config.js"></script> -<script src="scripts/models/artifacts.js"></script> -<script src="scripts/models/aschema-property.js"></script> -<script src="scripts/models/attributes.js"></script> -<script src="scripts/models/capability.js"></script> -<script src="scripts/models/category.js"></script> -<script src="scripts/models/comments.js"></script> -<script src="scripts/models/components/component.js"></script> -<script src="scripts/models/components/displayComponent.js"></script> -<script src="scripts/models/components/product.js"></script> -<script src="scripts/models/components/resource.js"></script> -<script src="scripts/models/components/service.js"></script> -<script src="scripts/models/componentsInstances/componentInstance.js"></script> -<script src="scripts/models/componentsInstances/productInstance.js"></script> -<script src="scripts/models/componentsInstances/resourceInstance.js"></script> -<script src="scripts/models/componentsInstances/serviceInstance.js"></script> -<script src="scripts/models/csar-component.js"></script> -<script src="scripts/models/data-type-properties.js"></script> -<script src="scripts/models/data-types-map.js"></script> -<script src="scripts/models/data-types.js"></script> -<script src="scripts/models/distribution.js"></script> -<script src="scripts/models/file-download.js"></script> -<script src="scripts/models/graph/d2-node.js"></script> -<script src="scripts/models/graph/graph-links/common-base-link.js"></script> -<script src="scripts/models/graph/graph-links/common-ci-link-base.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-link-base.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-link.js"></script> -<script src="scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link.js"></script> -<script src="scripts/models/graph/graph-links/links-factory.js"></script> -<script src="scripts/models/graph/graph-links/module-graph-links/module-ci-link-base.js"></script> -<script src="scripts/models/graph/graph-links/module-graph-links/module-ci-vl-link.js"></script> -<script src="scripts/models/graph/graphTooltip.js"></script> -<script src="scripts/models/graph/link-menu.js"></script> -<script src="scripts/models/graph/match-relation.js"></script> -<script src="scripts/models/graph/nodes/base-common-node.js"></script> -<script src="scripts/models/graph/nodes/common-ci-node-base.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.js"></script> -<script src="scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.js"></script> -<script src="scripts/models/graph/nodes/modules-graph-nodes/module-node-base.js"></script> -<script src="scripts/models/graph/nodes/nodes-factory.js"></script> -<script src="scripts/models/graph/point.js"></script> -<script src="scripts/models/graph/relationMenuObjects.js"></script> -<script src="scripts/models/graph/relationship.js"></script> -<script src="scripts/models/inputs.js"></script> -<script src="scripts/models/instance-inputs-properties-map.js"></script> -<script src="scripts/models/instances-inputs-map.js"></script> -<script src="scripts/models/left-panel.js"></script> -<script src="scripts/models/member.js"></script> -<script src="scripts/models/modules/base-module.js"></script> -<script src="scripts/models/properties.js"></script> -<script src="scripts/models/requirement.js"></script> -<script src="scripts/models/schema-attribute.js"></script> -<script src="scripts/models/tab.js"></script> -<script src="scripts/models/tooltip-data.js"></script> -<script src="scripts/models/user.js"></script> -<script src="scripts/models/validate.js"></script> -<!-- endinjector:js_models --> - -<script src="third-party/ng-infinite-scroll/build/ng-infinite-scroll.js"></script> - -<!-- injector:js_filters --> -<script src="scripts/filters/_category-name-filter.js"></script> -<script src="scripts/filters/capitalize-filter.js"></script> -<script src="scripts/filters/catalog-status-filter.js"></script> -<script src="scripts/filters/category-icon-filter.js"></script> -<script src="scripts/filters/category-type-filter.js"></script> -<script src="scripts/filters/clear-whitespaces-filter.js"></script> -<script src="scripts/filters/entity-filter.js"></script> -<script src="scripts/filters/graph-resource-name-filter.js"></script> -<script src="scripts/filters/product-category-name-filter.js"></script> -<script src="scripts/filters/product-subcategory-name-filter.js"></script> -<script src="scripts/filters/relation-name-fllter.js"></script> -<script src="scripts/filters/resource-name-filter.js"></script> -<script src="scripts/filters/resource-type-filter.js"></script> -<script src="scripts/filters/string-to-date-filter.js"></script> -<script src="scripts/filters/tests-id-filter.js"></script> -<script src="scripts/filters/trim-filter.js"></script> -<script src="scripts/filters/truncate-filter.js"></script> -<script src="scripts/filters/underscoreless-filter.js"></script> -<!-- endinjector:js_filters --> -<script src="scripts/modules/filters.js"></script> - -<script src="third-party/PunchOutRegistry.js"></script> - - -<!-- injector:js_directives --> -<script src="scripts/directives/clicked-outside/clicked-outside-directive.js"></script> -<script src="scripts/directives/custom-validation/custom-validation.js"></script> -<script src="scripts/directives/download-artifact/download-artifact.js"></script> -<script src="scripts/directives/ecomp-header/ecomp-header.js"></script> -<script src="scripts/directives/edit-name-popover/edit-name-popover-directive.js"></script> -<script src="scripts/directives/elements/checkbox/checkbox.js"></script> -<script src="scripts/directives/elements/radiobutton/radiobutton.js"></script> -<script src="scripts/directives/ellipsis/ellipsis-directive.js"></script> -<script src="scripts/directives/events/on-last-repeat/on-last-repeat.js"></script> -<script src="scripts/directives/file-opener/file-opener.js"></script> -<script src="scripts/directives/file-type/file-type.js"></script> -<script src="scripts/directives/file-upload/file-upload.js"></script> -<script src="scripts/directives/graphs-v2/common/common-graph-utils.js"></script> -<script src="scripts/directives/graphs-v2/common/style/component-instances-nodes-style.js"></script> -<script src="scripts/directives/graphs-v2/common/style/module-node-style.js"></script> -<script src="scripts/directives/graphs-v2/composition-graph/composition-graph.directive.js"></script> -<script src="scripts/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.js"></script> -<script src="scripts/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.js"></script> -<script src="scripts/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.js"></script> -<script src="scripts/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.js"></script> -<script src="scripts/directives/graphs-v2/deployment-graph/deployment-graph.directive.js"></script> -<script src="scripts/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.js"></script> -<script src="scripts/directives/graphs-v2/image-creator/image-creator.service.js"></script> -<script src="scripts/directives/graphs-v2/palette/palette.directive.js"></script> -<script src="scripts/directives/graphs-v2/relation-menu/relation-menu.js"></script> -<script src="scripts/directives/info-tooltip/info-tooltip.js"></script> -<script src="scripts/directives/invalid-characters/invalid-characters.js"></script> -<script src="scripts/directives/layout/top-nav/top-nav.js"></script> -<script src="scripts/directives/layout/top-progress/top-progress.js"></script> -<script src="scripts/directives/loader/loader-directive.js"></script> -<script src="scripts/directives/modal/sdc-modal.js"></script> -<script src="scripts/directives/page-scroller/page-scroller.js"></script> -<script src="scripts/directives/perfect-scrollbar/angular-perfect-scrollbar.js"></script> -<script src="scripts/directives/print-graph-screen/print-graph-screen.js"></script> -<script src="scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.js"></script> -<script src="scripts/directives/property-types/type-list/type-list-directive.js"></script> -<script src="scripts/directives/property-types/type-map/type-map-directive.js"></script> -<script src="scripts/directives/punch-out/punch-out.js"></script> -<script src="scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.js"></script> -<script src="scripts/directives/sdc-tabs/sdc-tabs-directive.js"></script> -<script src="scripts/directives/structure-tree/structure-tree-directive.js"></script> -<script src="scripts/directives/tag/tag-directive.js"></script> -<script src="scripts/directives/tutorial/tutorial-directive.js"></script> -<script src="scripts/directives/user-header-details/user-header-details-directive.js"></script> -<script src="scripts/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.js"></script> -<script src="scripts/directives/utils/expand-collapse/expand-collapse.js"></script> -<script src="scripts/directives/utils/page-selector/page-selector.js"></script> -<script src="scripts/directives/utils/sdc-keyboard-events/sdc-keyboard-events.js"></script> -<script src="scripts/directives/utils/sdc-tags/sdc-tags.js"></script> -<script src="scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.js"></script> -<script src="scripts/directives/utils/sdc_messages/sdc-message.js"></script> -<script src="scripts/directives/utils/sdc_messages/sdc-messages.js"></script> -<script src="scripts/directives/utils/smart-tooltip/smart-tooltip.js"></script> -<script src="scripts/directives/utils/wizard_steps/sdc-wizard-steps.js"></script> -<!-- endinjector:js_directives --> -<script src="scripts/modules/directive-module.js"></script> - -<!-- injector:js_services --> -<script src="scripts/services/activity-log-service.js"></script> -<script src="scripts/services/angular-js-bridge-service.js"></script> -<script src="scripts/services/available-icons-service.js"></script> -<script src="scripts/services/cache-service.js"></script> -<script src="scripts/services/category-resource-service.js"></script> -<script src="scripts/services/components/component-service.js"></script> -<script src="scripts/services/components/product-service.js"></script> -<script src="scripts/services/components/resource-service.js"></script> -<script src="scripts/services/components/service-service.js"></script> -<script src="scripts/services/components/utils/composition-left-palette-service.js"></script> -<script src="scripts/services/configuration-ui-service.js"></script> -<script src="scripts/services/cookie-service.js"></script> -<script src="scripts/services/data-types-service.js"></script> -<script src="scripts/services/ecomp-service.js"></script> -<script src="scripts/services/entity-service.js"></script> -<script src="scripts/services/event-listener-service.js"></script> -<script src="scripts/services/header-interceptor.js"></script> -<script src="scripts/services/http-error-interceptor.js"></script> -<script src="scripts/services/loader-service.js"></script> -<script src="scripts/services/onboarding-service.js"></script> -<script src="scripts/services/progress-service.js"></script> -<script src="scripts/services/relation-icons-service.js"></script> -<script src="scripts/services/sdc-version-service.js"></script> -<script src="scripts/services/sharing-service.js"></script> -<script src="scripts/services/url-tobase64-service.js"></script> -<script src="scripts/services/user-resource-service.js"></script> -<!-- endinjector:js_services --> -<script src="scripts/modules/service-module.js"></script> - -<!-- injector:js_view_models --> -<script src="scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.js"></script> -<script src="scripts/view-models/admin-dashboard/admin-dashboard-view-model.js"></script> -<script src="scripts/view-models/admin-dashboard/category-management/category-management-view-model.js"></script> -<script src="scripts/view-models/admin-dashboard/user-management/user-management-view-model.js"></script> -<script src="scripts/view-models/catalog/catalog-view-model.js"></script> -<script src="scripts/view-models/component-viewer/component-viewer-view-model.js"></script> -<script src="scripts/view-models/dashboard/cover/dashboard-cover-view-model.js"></script> -<script src="scripts/view-models/dashboard/dashboard-view-model.js"></script> -<script src="scripts/view-models/forms/artifact-form/artifact-form-view-model.js"></script> -<script src="scripts/view-models/forms/attribute-form/attribute-from-view-model.js"></script> -<script src="scripts/view-models/forms/env-parameters-form/env-parameters-form.js"></script> -<script src="scripts/view-models/forms/property-form/property-form-view-model.js"></script> -<script src="scripts/view-models/forms/resource-instance-name-form/resource-instance-name-model.js"></script> -<script src="scripts/view-models/modals/confirmation-modal/confirmation-modal-view-model.js"></script> -<script src="scripts/view-models/modals/email-modal/email-modal-view-model.js"></script> -<script src="scripts/view-models/modals/error-modal/error-view-model.js"></script> -<script src="scripts/view-models/modals/message-modal/message-base-modal-model.js"></script> -<script src="scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.js"></script> -<script src="scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.js"></script> -<script src="scripts/view-models/modals/onboarding-modal/onboarding-modal-view-model.js"></script> -<script src="scripts/view-models/onboard-vendor/onboard-vendor-view-model.js"></script> -<script src="scripts/view-models/preloading/preloading-view.js"></script> -<script src="scripts/view-models/support/support-view-model.js"></script> -<script src="scripts/view-models/tabs/hierarchy/hierarchy-view-model.js"></script> -<script src="scripts/view-models/tutorial-end/tutorial-end.js"></script> -<script src="scripts/view-models/welcome/welcome-steps-controller.js"></script> -<script src="scripts/view-models/welcome/welcome-view.js"></script> -<script src="scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.js"></script> -<script src="scripts/view-models/wizard/artifact-form-step/artifact-form-step-view-model.js"></script> -<script src="scripts/view-models/wizard/artifact-information-step/artifact-information-step.js"></script> -<script src="scripts/view-models/wizard/general-step/general-step.js"></script> -<script src="scripts/view-models/wizard/hierarchy-step/hierarchy-step.js"></script> -<script src="scripts/view-models/wizard/icons-step/icons-step.js"></script> -<script src="scripts/view-models/wizard/properties-step/properties-step.js"></script> -<script src="scripts/view-models/wizard/property-form/property-form-view-model.js"></script> -<script src="scripts/view-models/wizard/wizard-creation-base.js"></script> -<script src="scripts/view-models/wizard/wizard-state/create-wizard.js"></script> -<script src="scripts/view-models/wizard/wizard-state/edit-wizard.js"></script> -<script src="scripts/view-models/wizard/wizard-state/import-wizard.js"></script> -<script src="scripts/view-models/workspace/tabs/activity-log/activity-log.js"></script> -<script src="scripts/view-models/workspace/tabs/attributes/attributes-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/composition-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/tabs/details/details-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.js"></script> -<script src="scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/deployment/deployment-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/distribution/distribution-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/general/general-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/icons/icons-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/management-workflow/management-workflow-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/properties/properties-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.js"></script> -<script src="scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.js"></script> -<script src="scripts/view-models/workspace/workspace-view-model.js"></script> -<!-- endinjector:js_view_models --> -<script src="scripts/modules/view-model-module.js"></script> - -<!--init --> -<script src="scripts/modules/configurations.js"></script> -<script src="scripts/app.js"></script> -<script src="scripts/templates.js"></script> - -<!-- endbuild --> - -<script src="/onboarding/punch-outs_en.js" async></script> - -<!-- include: "type": "js", "files": "scripts/*.js" --> - -<!-- /include --> -</body> -</html> diff --git a/catalog-ui/app/scripts/app.ts b/catalog-ui/app/scripts/app.ts deleted file mode 100644 index 513810595b..0000000000 --- a/catalog-ui/app/scripts/app.ts +++ /dev/null @@ -1,936 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="./references"/> -/* - SD&C Web Portal Wireframes – Designer Home Page and Create New Service Flow - */ -//libraries variables to prevent compile errors -declare let jsPDF:any; - -module Sdc { - import User = Sdc.Models.User; - import UserResourceService = Sdc.Services.UserResourceService; - - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - let moduleName:string = 'sdcApp'; - let viewModelsModuleName:string = 'Sdc.ViewModels'; - let directivesModuleName:string = 'Sdc.Directives'; - let servicesModuleName:string = 'Sdc.Services'; - let filtersModuleName:string = 'Sdc.Filters'; - let utilsModuleName: string = 'Sdc.Utils'; - let dependentModules:Array<string> = [ - 'ui.router', - 'ui.bootstrap', - 'ngDragDrop', - 'ui-notification', - 'ngResource', - 'ngSanitize', - 'Sdc.Config', - 'naif.base64', - 'base64', - 'uuid4', - 'checklist-model', - 'angular.filter', - 'pascalprecht.translate', - '720kb.tooltips', - 'restangular', - 'angular-clipboard', - 'angularResizable', - 'infinite-scroll', - viewModelsModuleName, - directivesModuleName, - servicesModuleName, - filtersModuleName, - utilsModuleName - ]; - - let appModule:ng.IModule = angular.module(moduleName, dependentModules); - - appModule.config([ - '$stateProvider', - '$translateProvider', - '$urlRouterProvider', - '$httpProvider', - 'tooltipsConfigProvider', - 'NotificationProvider', - ($stateProvider:any, - $translateProvider:any, - $urlRouterProvider:ng.ui.IUrlRouterProvider, - $httpProvider:ng.IHttpProvider, - tooltipsConfigProvider:any, - NotificationProvider:any):void => { - - NotificationProvider.setOptions({ - delay: 10000, - startTop: 10, - startRight: 10, - closeOnClick: true, - verticalSpacing: 20, - horizontalSpacing: 20, - positionX: 'right', - positionY: 'top' - }); - - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - console.info('appModule.config: ', viewModelsHtmlBasePath); - - $translateProvider.useStaticFilesLoader({ - prefix: 'languages/', - langKey: '', - suffix: '.json?d=' + (new Date()).getTime() - }); - $translateProvider.useSanitizeValueStrategy('escaped'); - $translateProvider.preferredLanguage('en_US_OS'); // For open source changed to en_US_OS - - $httpProvider.interceptors.push('Sdc.Services.HeaderInterceptor'); - $httpProvider.interceptors.push('Sdc.Services.HttpErrorInterceptor'); - - $urlRouterProvider.otherwise('welcome'); - - $stateProvider.state( - 'dashboard', { - url: '/dashboard?show&folder', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'dashboard/dashboard-view.html'); - }], - controller: viewModelsModuleName + '.DashboardViewModel', - - } - ); - - $stateProvider.state( - 'welcome', { - url: '/welcome', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'welcome/welcome-view.html'); - }], - controller: viewModelsModuleName + '.WelcomeViewModel' - } - ); - - $stateProvider.state( - 'dashboard.cover', { - url: '/cover', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'dashboard/cover/dashboard-cover-view.html'); - }], - controller: viewModelsModuleName + '.DashboardCoverViewModel' - } - ); - - $stateProvider.state( - 'dashboard.tutorial-end', { - url: '/tutorial-end', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'tutorial-end/tutorial-end.html'); - }], - controller: viewModelsModuleName + '.TutorialEndViewModel' - } - ); - - $stateProvider.state( - 'additionalInformation', { - url: '/additionalInformation', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'additional-information/additional-information-view.html'); - }], - controller: viewModelsModuleName + '.AdditionalInformationViewModel' - } - ); - - let componentsParam:Array<any> = ['$stateParams', 'Sdc.Services.EntityService','Sdc.Services.CacheService' , ($stateParams:any, EntityService:Sdc.Services.EntityService, cacheService:Services.CacheService) => { - if(cacheService.get('breadcrumbsComponents')){ - return cacheService.get('breadcrumbsComponents'); - } else { - return EntityService.getCatalog(); //getAllComponents() doesnt return components from catalog - } - }]; - - - $stateProvider.state ( - 'workspace', { - url: '/workspace/:id/:type/', - params: {'importedFile':null,'componentCsar':null,'resourceType': null, 'disableButtons': null}, //'vspComponent': null, - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/workspace-view.html'); - }], - controller: viewModelsModuleName + '.WorkspaceViewModel', - resolve: { - injectComponent: ['$stateParams', 'ComponentFactory' , function ($stateParams, ComponentFactory) { - /* - if($stateParams.vspComponent){ - return $stateParams.vspComponent; - } else - */ - if($stateParams.id){ - return ComponentFactory.getComponentFromServer($stateParams.type.toUpperCase(), $stateParams.id); - } else if ($stateParams.componentCsar && $stateParams.componentCsar.csarUUID) { - return $stateParams.componentCsar; - } else { - let emptyComponent = ComponentFactory.createEmptyComponent($stateParams.type.toUpperCase()); - if (emptyComponent.isResource() && $stateParams.resourceType){ - // Set the resource type - (<Resource>emptyComponent).resourceType = $stateParams.resourceType; - } - if($stateParams.importedFile){ - (<Models.Components.Resource>emptyComponent).importedFile = $stateParams.importedFile; - } - return emptyComponent; - } - }], - components: componentsParam - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_GENERAL, { - url: 'general', - parent: 'workspace', - controller: viewModelsModuleName + '.GeneralViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/general/general-view.html'); - }], - data: {unsavedChanges:false,bodyClass:'general'} - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_ICONS, { - url: 'icons', - parent: 'workspace', - controller: viewModelsModuleName + '.IconsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/icons/icons-view.html'); - }], - data: {unsavedChanges:false,bodyClass:'icons'} - - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_ACTIVITY_LOG, { - url: 'activity_log', - parent: 'workspace', - controller: viewModelsModuleName + '.ActivityLogViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/activity-log/activity-log.html'); - }], - data: {unsavedChanges:false} - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_DEPLOYMENT_ARTIFACTS, { - url: 'deployment_artifacts', - parent: 'workspace', - controller: viewModelsModuleName + '.DeploymentArtifactsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/deployment-artifacts/deployment-artifacts-view.html'); - }], - data:{ - bodyClass:'deployment_artifacts' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_HIERARCHY, { - url: 'hierarchy', - parent: 'workspace', - controller: viewModelsModuleName + '.ProductHierarchyViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/product-hierarchy/product-hierarchy-view.html'); - }] - - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_INFORMATION_ARTIFACTS, { - url: 'information_artifacts', - parent: 'workspace', - controller: viewModelsModuleName + '.InformationArtifactsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/information-artifacts/information-artifacts-view.html'); - }], - data:{ - bodyClass:'information_artifacts' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_TOSCA_ARTIFACTS, { - url: 'tosca_artifacts', - parent: 'workspace', - controller: viewModelsModuleName + '.ToscaArtifactsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/tosca-artifacts/tosca-artifacts-view.html'); - }], - data:{ - bodyClass:'tosca_artifacts' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_PROPERTIES, { - url: 'properties', - parent: 'workspace', - controller: viewModelsModuleName + '.PropertiesViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/properties/properties-view.html'); - }], - data:{ - bodyClass:'properties' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_SERVICE_INPUTS, { - url: 'service_inputs', - parent: 'workspace', - controller: viewModelsModuleName + '.ServiceInputsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/inputs/service-input/service-inputs-view.html'); - }], - data:{ - bodyClass:'workspace-inputs' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_RESOURCE_INPUTS, { - url: 'resource_inputs', - parent: 'workspace', - controller: viewModelsModuleName + '.ResourceInputsViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/inputs/resource-input/resource-inputs-view.html'); - }], - data:{ - bodyClass:'workspace-inputs' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_ATTRIBUTES, { - url: 'attributes', - parent: 'workspace', - controller: viewModelsModuleName + '.AttributesViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/attributes/attributes-view.html'); - }], - data:{ - bodyClass:'attributes' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_REQUIREMENTS_AND_CAPABILITIES, { - url: 'req_and_capabilities', - parent: 'workspace', - controller: viewModelsModuleName + '.ReqAndCapabilitiesViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/req-and-capabilities/req-and-capabilities-view.html'); - }], - data:{ - bodyClass:'attributes' - } - } - ); - - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_MANAGEMENT_WORKFLOW, { - parent: 'workspace', - url: 'management_workflow', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/management-workflow/management-workflow-view.html'); - }], - controller: viewModelsModuleName + '.ManagementWorkflowViewModel' - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_NETWORK_CALL_FLOW, { - parent: 'workspace', - url: 'network_call_flow', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/network-call-flow/network-call-flow-view.html'); - }], - controller: viewModelsModuleName + '.NetworkCallFlowViewModel' - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_DISTRIBUTION, { - parent: 'workspace', - url: 'distribution', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/distribution/distribution-view.html'); - }], - controller: viewModelsModuleName + '.DistributionViewModel' - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_COMPOSITION, { - url: 'composition/', - parent: 'workspace', - controller: viewModelsModuleName + '.CompositionViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/composition-view.html'); - }], - data:{ - bodyClass:'composition' - } - } - ); - - $stateProvider.state( - Utils.Constants.States.WORKSPACE_DEPLOYMENT, { - url: 'deployment/', - parent: 'workspace', - controller: viewModelsModuleName + '.DeploymentViewModel', - templateProvider: ['$templateCache', ($templateCache:ng.ITemplateCacheService):string => { - - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/deployment/deployment-view.html'); - }], - data:{ - bodyClass:'composition' - } - } - ); - - $stateProvider.state( - 'workspace.composition.details', { - url: 'details', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/details/details-view.html'); - }], - controller: viewModelsModuleName + '.DetailsViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.properties', { - url: 'properties', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html'); - }], - controller: viewModelsModuleName + '.ResourcePropertiesViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.artifacts', { - url: 'artifacts', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/artifacts/artifacts-view.html'); - }], - controller: viewModelsModuleName + '.ResourceArtifactsViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.relations', { - url: 'relations', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/relations/relations-view.html'); - }], - controller: viewModelsModuleName + '.RelationsViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.relationships', { - url: 'relationships', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'resource-relationships/resource-relationships-view.html'); - }], - controller: viewModelsModuleName + '.ResourceRelationshipsViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.structure', { - url: 'structure', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/structure/structure-view.html'); - }], - controller: viewModelsModuleName + '.StructureViewModel' - } - ); - $stateProvider.state( - 'workspace.composition.lifecycle', { - url: 'lifecycle', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/artifacts/artifacts-view.html'); - }], - controller: viewModelsModuleName + '.ResourceArtifactsViewModel' - } - ); - - $stateProvider.state( - 'workspace.composition.api', { - url: 'api', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/artifacts/artifacts-view.html'); - }], - controller: viewModelsModuleName + '.ResourceArtifactsViewModel' - } - ); - $stateProvider.state( - 'workspace.composition.deployment', { - url: 'deployment', - parent: 'workspace.composition', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'workspace/tabs/composition/tabs/artifacts/artifacts-view.html'); - }], - controller: viewModelsModuleName + '.ResourceArtifactsViewModel' - } - ); - - $stateProvider.state( - 'edit-resource', { - url: '/edit-resource/:id', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'entity-handler/resource-form/resource-form-view.html'); - }], - controller: viewModelsModuleName + '.ResourceFormViewModel' - } - ); - - $stateProvider.state( - 'edit-product', { - url: '/edit-product/:id', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'entity-handler/product-form/product-form-view.html'); - }], - controller: viewModelsModuleName + '.ProductFormViewModel' - } - ); - - $stateProvider.state( - 'adminDashboard', { - url: '/adminDashboard', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'admin-dashboard/admin-dashboard-view.html'); - }], - controller: viewModelsModuleName + '.AdminDashboardViewModel', - permissions: ['ADMIN'] - } - ); - - $stateProvider.state( - 'onboardVendor', { - url: '/onboardVendor', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'onboard-vendor/onboard-vendor-view.html'); - }], - controller: viewModelsModuleName + '.OnboardVendorViewModel'//, - //resolve: { - // auth: ["$q", "Sdc.Services.UserResourceService", function ($q:any, userResourceService:Sdc.Services.IUserResourceClass) { - // let userInfo:Sdc.Services.IUserResource = userResourceService.getLoggedinUser(); - // if (userInfo) { - // return $q.when(userInfo); - // } else { - // return $q.reject({authenticated: false}); - // } - // }] - //} - } - ); - - $stateProvider.state( - 'catalog', { - url: '/catalog', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'catalog/catalog-view.html'); - }], - controller: viewModelsModuleName + '.CatalogViewModel', - resolve: { - auth: ["$q", "Sdc.Services.UserResourceService", function ($q:any, userResourceService:Sdc.Services.IUserResourceClass) { - let userInfo:Sdc.Services.IUserResource = userResourceService.getLoggedinUser(); - if (userInfo) { - return $q.when(userInfo); - } else { - return $q.reject({authenticated: false}); - } - }] - } - } - ); - - $stateProvider.state( - 'distribution', { - url: '/distribution', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'distribution/distribution-view.html'); - }], - controller: viewModelsModuleName + '.DistributionViewModel' - } - ); - - $stateProvider.state( - 'support', { - url: '/support', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'support/support-view.html'); - }], - controller: viewModelsModuleName + '.SupportViewModel' - } - ); - - $stateProvider.state( - 'error-403', { - url: '/error-403', - templateProvider: ['$templateCache', ($templateCache):string => { - return $templateCache.get(viewModelsHtmlBasePath + 'modals/error-modal/error-403-view.html'); - }], - controller: viewModelsModuleName + '.ErrorViewModel' - } - ); - - tooltipsConfigProvider.options({ - - side:'bottom', - delay: '600', - class: 'tooltip-custom', - lazy:0, - try:0 - - }); - - } - ]) - .run(['AngularJSBridge', (AngularJSBridge)=>{ - - }]); - appModule.value('ValidationPattern', /^[\s\w\&_.:-]{1,1024}$/); - appModule.value('PropertyNameValidationPattern', /^[a-zA-Z0-9_:-]{1,50}$/);// DE210977 - appModule.value('TagValidationPattern', /^[\s\w_.-]{1,50}$/); - // appModule.value('VendorValidationPattern', /^[^?\\<>:"/|*]{1,25}$/); - appModule.value('VendorValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,25}$/); - appModule.value('ContactIdValidationPattern', /^[\s\w-]{1,50}$/); - appModule.value('UserIdValidationPattern',/^[\s\w-]{1,50}$/); - appModule.value('ProjectCodeValidationPattern', /^[\s\w-]{1,50}$/); - appModule.value('LabelValidationPattern', /^[\sa-zA-Z0-9+-]{1,25}$/); - appModule.value('UrlValidationPattern', /^(https?|ftp):\/\/(((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([A-Za-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([A-Za-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/); - appModule.value('IntegerValidationPattern', /^(([-+]?\d+)|([-+]?0x[0-9a-fA-F]+))$/); - appModule.value('IntegerNoLeadingZeroValidationPattern', /^(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)$/); - appModule.value('FloatValidationPattern', /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?$/); - appModule.value('NumberValidationPattern', /^((([-+]?\d+)|([-+]?0x[0-9a-fA-F]+))|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))$/); - appModule.value('KeyValidationPattern', /^[\s\w-]{1,50}$/); - appModule.value('CommentValidationPattern', /^[\u0000-\u00BF]*$/); - appModule.value('BooleanValidationPattern', /^([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])$/); - - - appModule.run([ - '$http', - 'Sdc.Services.CacheService', - 'Sdc.Services.CookieService', - 'Sdc.Services.ConfigurationUiService', - 'Sdc.Services.UserResourceService', - 'Sdc.Services.CategoryResourceService', - 'Sdc.Services.SdcVersionService', - '$state', - '$rootScope', - '$location', - 'sdcConfig', - 'sdcMenu', - 'ModalsHandler', - 'Sdc.Services.EcompHeaderService', - 'LeftPaletteLoaderService', - ($http:ng.IHttpService, - cacheService:Services.CacheService, - cookieService:Services.CookieService, - ConfigurationUi:Services.ConfigurationUiService, - UserResourceClass:Services.IUserResourceClass, - categoryResourceService:Sdc.Services.ICategoryResourceClass, - sdcVersionService:Services.SdcVersionService, - $state:ng.ui.IStateService, - $rootScope:ng.IRootScopeService, - $location: ng.ILocationService, - sdcConfig: Models.IAppConfigurtaion, - sdcMenu: Models.IAppMenu, - ModalsHandler:Utils.ModalsHandler, - ecompHeaderService:Sdc.Services.EcompHeaderService, - LeftPaletteLoaderService:Services.Components.LeftPaletteLoaderService - ):void => { - - //handle cache data - version - let initSdcVersion:Function = ():void => { - - let onFailed = (response) => { - console.info('onFailed initSdcVersion', response); - cacheService.set('version', 'N/A'); - }; - - let onSuccess = (version:any) => { - console.log("Version returned from server: " + version); - let tmpVerArray = version.version.split("."); - let ver = tmpVerArray[0] + "." + tmpVerArray[1] + "." + tmpVerArray[2]; - cacheService.set('version', ver); - }; - - sdcVersionService.getVersion().then(onSuccess, onFailed); - - }; - - let initEcompMenu:Function = (user):void => { - ecompHeaderService.getMenuItems(user.userId).then((data)=> { - $rootScope['menuItems'] = data; - }); - }; - - let initConfigurationUi:Function = ():void => { - ConfigurationUi - .getConfigurationUi() - .then((configurationUi:any) => { - cacheService.set('UIConfiguration', configurationUi); - }); - }; - - let initCategories:Function = ():void => { - let onError = ():void => { - console.log('Failed to init categories'); - }; - - categoryResourceService.getAllCategories({types: 'services'}, (categories:Array<Models.IMainCategory>):void => { - cacheService.set('serviceCategories', categories); - }, onError); - - categoryResourceService.getAllCategories({types: 'resources'}, (categories:Array<Models.IMainCategory>):void => { - cacheService.set('resourceCategories', categories); - }, onError); - - categoryResourceService.getAllCategories({types: 'products'}, (categories:Array<Models.IMainCategory>):void => { - cacheService.set('productCategories', categories); - }, onError); - }; - - let initBaseUrl:Function = ():void => { - let env:string = sdcConfig.environment; - let baseUrl:string = $location.absUrl(); - console.log("baseUrl="+baseUrl); - - if(baseUrl) { - sdcConfig.api.baseUrl = baseUrl; - - if(env==='prod'){ - //let tempUrl = $location.absUrl().split('/sdc1/'); - var mainUrl = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: ''); - console.log("mainUrl="+mainUrl); - sdcConfig.api.root = mainUrl + sdcConfig.api.root; - console.log("sdcConfig.api.root="+sdcConfig.api.root); - } - } - }; - - let initLeftPalette:Function = ():void => { - LeftPaletteLoaderService.loadLeftPanel(); - }; - - //handle http config - $http.defaults.withCredentials = true; - $http.defaults.headers.common[cookieService.getUserIdSuffix()] = cookieService.getUserId(); - - initBaseUrl(); - initSdcVersion(); - initConfigurationUi(); - Utils.Constants.IMAGE_PATH = sdcConfig.imagesPath; - initLeftPalette(); - - //handle stateChangeStart - let internalDeregisterStateChangeStartWatcher:Function = ():void => { - if (deregisterStateChangeStartWatcher) { - deregisterStateChangeStartWatcher(); - deregisterStateChangeStartWatcher = null; - } - }; - - let removeLoader:Function = ():void => { - $(".sdc-loading-page .main-loader").addClass("animated fadeOut"); - $(".sdc-loading-page .caption1").addClass("animated fadeOut"); - $(".sdc-loading-page .caption2").addClass("animated fadeOut"); - window.setTimeout(():void=>{ - $(".sdc-loading-page .main-loader").css("display", "none"); - $(".sdc-loading-page .caption1").css("display", "none"); - $(".sdc-loading-page .caption2").css("display", "none"); - $(".sdc-loading-page").addClass("animated fadeOut"); - },1000); - }; - - let onNavigateOut:Function = (toState, toParams):void => { - let onOk = ():void => { - $state.current.data.unsavedChanges = false; - $state.go(toState.name, toParams); - }; - - let data = sdcMenu.alertMessages.exitWithoutSaving; - //open notify to user if changes are not saved - ModalsHandler.openAlertModal(data.title, data.message).then(onOk); - }; - - let onStateChangeStart:Function = (event, toState, toParams, fromState, fromParams):void => { - console.info((new Date()).getTime()); - console.info('$stateChangeStart', toState.name); - //set body class - $rootScope['bodyClass'] = 'default-class'; - if(toState.data && toState.data.bodyClass){ - $rootScope['bodyClass'] = toState.data.bodyClass; - } - - // Workaround in case we are entering other state then workspace (user move to catalog) - // remove the changeComponentCsarVersion, user should open again the VSP list and select one for update. - if (toState.name.indexOf('workspace') === -1) { - if (cacheService.contains(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG)){ - cacheService.remove(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG); - } - } - - //saving last state to params , for breadcrumbs - if (['dashboard', 'catalog', 'onboardVendor'].indexOf(fromState.name) > -1) { - toParams.previousState = fromState.name; - } else { - toParams.previousState = fromParams.previousState; - } - - if (toState.name !== 'error-403' && !UserResourceClass.getLoggedinUser()) { - internalDeregisterStateChangeStartWatcher(); - event.preventDefault(); - - UserResourceClass.authorize().$promise.then((user:Services.IUserResource) => { - if(!doesUserHasAccess(toState, user)){ - $state.go('error-403'); - console.info('User has no permissions'); - registerStateChangeStartWatcher(); - return; - } - UserResourceClass.setLoggedinUser(user); - cacheService.set('user', user); - initCategories(); - // initEcompMenu(user); - setTimeout(function () { - - removeLoader(); - - // initCategories(); - if(UserResourceClass.getLoggedinUser().role === 'ADMIN'){ - // toState.name = "adminDashboard"; - $state.go("adminDashboard", toParams); - registerStateChangeStartWatcher(); - return; - } - - // After user authorized init categories - window.setTimeout(():void=>{ - //if ($state.current.name==='' || $state.current.name==='preloading') { - if ($state.current.name === "welcome" && sdcConfig.openSource) { - event.preventDefault(); - $state.go("dashboard"); - registerStateChangeStartWatcher(); - } - else if ($state.current.name==='') { - $state.go(toState.name, toParams); - } - - console.log("------$state.current.name=" + $state.current.name); - console.info('-----registerStateChangeStartWatcher authorize $stateChangeStart'); - registerStateChangeStartWatcher(); - - },1000); - - }, 0); - - }, () => { - $state.go('error-403'); - - console.info('registerStateChangeStartWatcher error-403 $stateChangeStart'); - registerStateChangeStartWatcher(); - }); - } - else if(UserResourceClass.getLoggedinUser()){ - internalDeregisterStateChangeStartWatcher(); - if(!doesUserHasAccess(toState, UserResourceClass.getLoggedinUser())){ - event.preventDefault(); - $state.go('error-403'); - console.info('User has no permissions'); - } - if(toState.name === "welcome") { - $state.go("dashboard"); - } - registerStateChangeStartWatcher(); - //if form is dirty and not save - notify to user - if(fromState.data && fromState.data.unsavedChanges && fromParams.id != toParams.id){ - event.preventDefault(); - onNavigateOut(toState, toParams); - } - } - - }; - - let doesUserHasAccess:Function = (toState, user):boolean =>{ - - let isUserHasAccess = true; - if(toState.permissions && toState.permissions.length > 0) { - isUserHasAccess = _.includes(toState.permissions, user.role); - } - return isUserHasAccess; - }; - let deregisterStateChangeStartWatcher:Function; - - let registerStateChangeStartWatcher:Function = ():void => { - internalDeregisterStateChangeStartWatcher(); - console.info('registerStateChangeStartWatcher $stateChangeStart'); - deregisterStateChangeStartWatcher = $rootScope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams):void => { - onStateChangeStart(event, toState, toParams, fromState, fromParams); - }); - }; - - registerStateChangeStartWatcher(); - - }]); - - - -} - diff --git a/catalog-ui/app/scripts/directives/clicked-outside/clicked-outside-directive.ts b/catalog-ui/app/scripts/directives/clicked-outside/clicked-outside-directive.ts deleted file mode 100644 index 1b0af4ef99..0000000000 --- a/catalog-ui/app/scripts/directives/clicked-outside/clicked-outside-directive.ts +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - - class ClickedOutsideModel{ - - private clickedOutsideContainerSelector: string; - private onClickedOutsideGetter: Function; - private clickedOutsideEnableGetter: Function; - - constructor(clickedOutsideData: any) { - this.clickedOutsideContainerSelector = clickedOutsideData.clickedOutsideContainerSelector; - this.onClickedOutsideGetter = clickedOutsideData.onClickedOutsideGetter; - this.clickedOutsideEnableGetter = clickedOutsideData.clickedOutsideEnableGetter; - } - - public getClickedOutsideContainerSelector = (): string => { - return this.clickedOutsideContainerSelector; - } - - public getOnClickedOutsideGetter = (): Function => { - return this.onClickedOutsideGetter; - } - - public getClickedOutsideEnableGetter = (): Function => { - return this.clickedOutsideEnableGetter; - } - } - - export interface IClickedOutsideDirectiveScope extends ng.IScope{} - - export class ClickedOutsideDirective implements ng.IDirective { - - constructor(private $document: JQuery, private $parse: ng.IParseService) {} - - restrict = 'A'; - - link = (scope:IClickedOutsideDirectiveScope, element: JQuery, attrs) => { - - let container: HTMLElement; - let attrsAfterEval = scope.$eval(attrs.clickedOutside); - attrsAfterEval.onClickedOutsideGetter = this.$parse(attrsAfterEval.onClickedOutside); - attrsAfterEval.clickedOutsideEnableGetter = this.$parse(attrsAfterEval.clickedOutsideEnable); - - let clickedOutsideModel: ClickedOutsideModel = new ClickedOutsideModel(attrsAfterEval); - - - let getContainer: Function = ():HTMLElement => { - if(!container){ - let clickedOutsideContainerSelector: string = clickedOutsideModel.getClickedOutsideContainerSelector(); - if(!angular.isUndefined(clickedOutsideContainerSelector) && clickedOutsideContainerSelector !== ''){ - container = element.parents(clickedOutsideContainerSelector+':first')[0]; - if(!container){ - container = element[0]; - } - }else{ - container = element[0]; - } - } - return container; - }; - - - let onClickedOutside = (event: JQueryEventObject) => { - let containerDomElement: HTMLElement = getContainer(); - let targetDomElementJq: JQuery = angular.element(event.target); - if(targetDomElementJq.hasClass('tooltip') || targetDomElementJq.parents('.tooltip:first').length){ - return; - } - let targetDomElement: HTMLElement = targetDomElementJq[0]; - if (!containerDomElement.contains(targetDomElement)){ - scope.$apply(() => { - let onClickedOutsideGetter:Function = clickedOutsideModel.getOnClickedOutsideGetter(); - onClickedOutsideGetter(scope); - }); - } - }; - - let attachDomEvents: Function = () => { - this.$document.on('mousedown', onClickedOutside); - }; - - let detachDomEvents: Function = () => { - this.$document.off('mousedown', onClickedOutside); - }; - - // - scope.$on('$destroy', () => { - detachDomEvents(); - }); - - - scope.$watch(() => { - let clickedOutsideEnableGetter: Function = clickedOutsideModel.getClickedOutsideEnableGetter(); - return clickedOutsideEnableGetter(scope); - }, (newValue: boolean) => { - if(newValue){ - attachDomEvents(); - return; - } - detachDomEvents(); - }); - - - } - - public static factory = ($document: JQuery, $parse: ng.IParseService) => { - return new ClickedOutsideDirective($document, $parse); - } - } - - ClickedOutsideDirective.factory.$inject = ['$document', '$parse']; -} diff --git a/catalog-ui/app/scripts/directives/custom-validation/custom-validation.ts b/catalog-ui/app/scripts/directives/custom-validation/custom-validation.ts deleted file mode 100644 index e2f831ed53..0000000000 --- a/catalog-ui/app/scripts/directives/custom-validation/custom-validation.ts +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - - export interface ICustomValidationScope extends ng.IScope { - validationFunc: Function; - } - - export class CustomValidationDirective implements ng.IDirective { - - constructor() {} - - require = 'ngModel'; - restrict = 'A'; - - scope = { - validationFunc: '=' - }; - - link = (scope:ICustomValidationScope, elem, attrs, ngModel) => { - - ngModel.$validators.customValidation = (modelValue, viewValue) :boolean => { - return scope.validationFunc(viewValue); - }; - - }; - - public static factory = ()=> { - return new CustomValidationDirective(); - }; - - } - - CustomValidationDirective.factory.$inject = []; -} diff --git a/catalog-ui/app/scripts/directives/download-artifact/download-artifact.ts b/catalog-ui/app/scripts/directives/download-artifact/download-artifact.ts deleted file mode 100644 index 49bf14618c..0000000000 --- a/catalog-ui/app/scripts/directives/download-artifact/download-artifact.ts +++ /dev/null @@ -1,141 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class DOWNLOAD_CSS_CLASSES { - static DOWNLOAD_ICON = "table-download-btn tosca"; - static LOADER_ICON = "tlv-loader small loader"; - } - - export interface IDownloadArtifactScope extends ng.IScope { - $window:any; - artifact: Models.ArtifactModel; - component: Models.Components.Component; - instance:boolean; - download: Function; - showLoader:boolean; - updateDownloadIcon:Function; - } - - export class DownloadArtifactDirective implements ng.IDirective { - - constructor(private $window:any,private cacheService:Services.CacheService, private EventListenerService:Services.EventListenerService, private fileUtils:Sdc.Utils.FileUtils) {} - - scope = { - artifact: '=', - component: '=', - instance:'=', - showLoader:'=' - }; - restrict = 'EA'; - - link = (scope:IDownloadArtifactScope, element:any) => { - scope.$window = this.$window; - - element.on("click", function() { - scope.download(scope.artifact); - }); - - - let initDownloadLoader = ()=>{ - //if the artifact is in a middle of download progress register form callBack & change icon from download to loader - if(scope.showLoader && this.cacheService.get(scope.artifact.uniqueId)){ - this.EventListenerService.registerObserverCallback(Utils.Constants.EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId, scope.updateDownloadIcon); - window.setTimeout(():void => { - if(this.cacheService.get(scope.artifact.uniqueId)){ - element[0].className = DOWNLOAD_CSS_CLASSES.LOADER_ICON; - } - },1000); - - } - }; - - let setDownloadedFileLoader = ()=> { - if(scope.showLoader){ - //set in cache service thet the artifact is in download progress - this.cacheService.set(scope.artifact.uniqueId,true); - initDownloadLoader(); - } - }; - - let removeDownloadedFileLoader = ()=> { - if (scope.showLoader) { - this.cacheService.set(scope.artifact.uniqueId, false); - this.EventListenerService.notifyObservers(Utils.Constants.EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId); - } - }; - - - //replace the loader to download icon - scope.updateDownloadIcon = () =>{ - element[0].className = DOWNLOAD_CSS_CLASSES.DOWNLOAD_ICON; - }; - - - initDownloadLoader(); - - scope.download = (artifact:Models.ArtifactModel):void => { - - let onFaild = (response):void => { - console.info('onFaild', response); - removeDownloadedFileLoader(); - }; - - let onSuccess = (data:Models.IFileDownload):void => { - downloadFile(data); - removeDownloadedFileLoader(); - }; - - setDownloadedFileLoader(); - - if(scope.instance){ - scope.component.downloadInstanceArtifact(artifact.uniqueId).then(onSuccess, onFaild); - }else { - scope.component.downloadArtifact(artifact.uniqueId).then(onSuccess, onFaild); - } - }; - - let downloadFile = (file:Models.IFileDownload):void => { - if (file){ - let blob = this.fileUtils.base64toBlob(file.base64Contents,''); - let fileName = file.artifactName; - this.fileUtils.downloadFile(blob, fileName); - } - }; - - element.on('$destroy', ()=>{ - //remove listener of download event - if(scope.artifact && scope.artifact.uniqueId){ - this.EventListenerService.unRegisterObserver(Utils.Constants.EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId); - } - }); - - }; - - public static factory = ($window:any,cacheService:Sdc.Services.CacheService,EventListenerService:Services.EventListenerService, fileUtils:Sdc.Utils.FileUtils)=> { - return new DownloadArtifactDirective($window,cacheService,EventListenerService, fileUtils); - }; - - } - - DownloadArtifactDirective.factory.$inject = ['$window', 'Sdc.Services.CacheService', 'EventListenerService', 'FileUtils']; -} diff --git a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.ts b/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.ts deleted file mode 100644 index 7102c810ba..0000000000 --- a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.ts +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class MenuItem { - menuId:number; - column:number; - text:string; - parentMenuId:number; - url:string; - children:Array<MenuItem> - } - - export interface IEcompHeaderDirectiveScope extends ng.IScope { - menuData:Array<MenuItem>; - version:string; - clickableLogo:string; - contactUsUrl:string; - getAccessUrl:string; - megaMenuDataObjectTemp:Array<any>; - megaMenuDataObject:Array<any>; - - selectedTopMenu:MenuItem; - selectedSubMenu:MenuItem; - - firstMenuLevelClick:Function; - subMenuEnterAction:Function; - subMenuLeaveAction:Function; - - memuItemClick:Function; - user: Models.IUser; - } - - export class EcompHeaderDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $http:ng.IHttpService, - private sdcConfig:Models.IAppConfigurtaion, - private UserResourceClass:Services.IUserResourceClass) { - - } - - scope = { - menuData: '=', - version: '@', - clickableLogo: '@?' - }; - - public replace = true; - public restrict = 'E'; - public controller = EcompHeaderController; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/ecomp-header/ecomp-header.html'); - }; - - link = ($scope:IEcompHeaderDirectiveScope, $elem:JQuery, attr:any) => { - - if (!$scope.clickableLogo){ - $scope.clickableLogo="true"; - } - - let findMenuItemById = (menuId):MenuItem => { - let selectedMenuItem:MenuItem = _.find($scope.menuData, (item:MenuItem)=>{ - if (item.menuId === menuId){ - return item; - } - }); - return selectedMenuItem; - }; - - let initUser = ():void => { - let defaultUserId:string; - let user:Services.IUserResource = this.UserResourceClass.getLoggedinUser(); - if (!user) { - defaultUserId = this.$http.defaults.headers.common[this.sdcConfig.cookie.userIdSuffix]; - user = this.UserResourceClass.get({id: defaultUserId}, ():void => { - $scope.user = new Models.User(user); - }); - } else { - $scope.user = new Models.User(user); - } - }; - - $scope.firstMenuLevelClick = (menuId:number):void => { - let selectedMenuItem:MenuItem = _.find($scope.megaMenuDataObjectTemp, (item:MenuItem)=>{ - if (item.menuId === menuId){ - return item; - } - }); - if (selectedMenuItem) { - $scope.selectedTopMenu = selectedMenuItem; - //console.log("Selected menu item: " + selectedMenuItem.text); - } - }; - - $scope.subMenuEnterAction = (menuId:number):void => { - $scope.selectedSubMenu = findMenuItemById(menuId); - }; - - $scope.subMenuLeaveAction = (menuId:number):void => { - $scope.selectedTopMenu = undefined; - }; - - $scope.memuItemClick = (menuItem:MenuItem):void => { - if (menuItem.url){ - window.location.href=menuItem.url; - } else { - console.log("Menu item: " + menuItem.text + " does not have defined URL!"); - } - }; - - initUser(); - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, - $http:ng.IHttpService, - sdcConfig:Models.IAppConfigurtaion, - UserResourceClass:Services.IUserResourceClass)=> { - return new EcompHeaderDirective($templateCache, $http, sdcConfig, UserResourceClass); - }; - - } - - export class EcompHeaderController { - - messages:any; - getAttachId:Function; - render:any; - reRender:Function; - register:Function; - deregister:Function; - head:any; - - static '$inject' = [ - '$element', - '$scope', - '$attrs', - '$animate' - ]; - - constructor(private $element:JQuery, - private $scope:IEcompHeaderDirectiveScope, - private $attrs:ng.IAttributes, - private $animate:any) { - - this.$scope = $scope; - - this.$scope.$watch('menuData', (newVal, oldVal) => { - if (newVal){ - this.init(); - } - }); - - } - - init = ():void => { - - this.$scope.contactUsUrl = "https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home"; - this.$scope.getAccessUrl = "http://ecomp-tlv-dev2.uccentral.att.com:8080/ecompportal/get_access"; - - let unflatten = ( array, parent?, tree? ) => { - tree = typeof tree !== 'undefined' ? tree : []; - parent = typeof parent !== 'undefined' ? parent : { menuId: null }; - let children = _.filter( array, function(child){ return child["parentMenuId"] == parent.menuId; }); - if( !_.isEmpty( children ) ){ - if( parent.menuId === null ){ - tree = children; - }else{ - parent['children'] = children - } - _.each( children, function( child ){ unflatten( array, child ) } ); - } - return tree; - }; - - let menuStructureConvert = (menuItems) => { - console.log(menuItems); - this.$scope.megaMenuDataObjectTemp = [ - { - menuId: 1001, - text: "ECOMP", - children: menuItems - }, - { - menuId: 1002, - text: "Help", - children: [ - { - text:"Contact Us", - url: this.$scope.contactUsUrl - }] - } - ]; - - /*{ - text:"Get Access", - url: this.$scope.getAccessUrl - }*/ - return this.$scope.megaMenuDataObjectTemp; - }; - - let a = unflatten(this.$scope.menuData); - this.$scope.megaMenuDataObject = menuStructureConvert(a); - //console.log(this.$scope.megaMenuDataObject); - }; - } - - EcompHeaderDirective.factory.$inject = ['$templateCache', '$http', 'sdcConfig', 'Sdc.Services.UserResourceService']; - -} - - - - diff --git a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-directive.ts b/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-directive.ts deleted file mode 100644 index a033df054b..0000000000 --- a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-directive.ts +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface IEditNamePopoverDirectiveScope extends ng.IScope { - isOpen: boolean; - templateUrl: string; - module: any; - direction: string; - header: string; - heatNameValidationPattern:RegExp; - originalName:string; - onSave:any; - - closePopover(isCancel:boolean):void; - validateField(field:any, originalName:string):boolean; - updateHeatName(heatName:string):void; - onInit():void; - } - - export class EditNamePopoverDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, private ValidationPattern:RegExp) { - } - - scope = { - direction: "@?", - module: "=", - header: "@?", - onSave: "&" - }; - - link = (scope:IEditNamePopoverDirectiveScope) => { - if(!scope.direction) { - scope.direction = 'top'; - } - - scope.originalName = ''; - scope.templateUrl = "/app/scripts/directives/edit-name-popover/edit-module-name-popover.html"; - scope.isOpen = false; - - scope.closePopover = (isCancel:boolean = true) => { - scope.isOpen = !scope.isOpen; - - if(isCancel) { - scope.module.heatName = scope.originalName; - } - }; - - scope.onInit = () => { - scope.originalName = scope.module.heatName; - }; - - scope.validateField = (field:any):boolean => { - return !!(field && field.$dirty && field.$invalid); - }; - - scope.heatNameValidationPattern = this.ValidationPattern; - - scope.updateHeatName = () => { - scope.closePopover(false); - scope.onSave(); - } - - }; - - replace = true; - restrict = 'E'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/edit-name-popover/edit-name-popover-view.html'); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, ValidationPattern:RegExp)=> { - return new EditNamePopoverDirective($templateCache, ValidationPattern); - } - } - - EditNamePopoverDirective.factory.$inject = ['$templateCache', 'ValidationPattern']; -} diff --git a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-view.html b/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-view.html deleted file mode 100644 index 17beead6b3..0000000000 --- a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover-view.html +++ /dev/null @@ -1 +0,0 @@ -<div uib-popover-template="templateUrl" popover-title="{{header}}" popover-placement="{{direction}}" popover-is-open="isOpen" popover-append-to-body="true"></div> diff --git a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.ts b/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.ts deleted file mode 100644 index c45a9d92e1..0000000000 --- a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ICheckboxElementScope extends ng.IScope { - elemId: string; - text: string; - sdcChecklistModel: any; - sdcChecklistValue: string; - disabled:boolean; - } - - export class CheckboxElementDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService) { - } - - public replace = true; - public restrict = 'E'; - public transclude = false; - - scope = { - elemId: '@', - text: '@', - disabled: '=', - sdcChecklistModel: '=', - sdcChecklistValue: '=' - }; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/elements/checkbox/checkbox.html'); - }; - - public link = (scope:ICheckboxElementScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { - //$elem.removeAttr("id") - //console.log(scope.sdcChecklistValue); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $filter:ng.IFilterService)=> { - return new CheckboxElementDirective($templateCache, $filter); - }; - - } - - CheckboxElementDirective.factory.$inject = ['$templateCache', '$filter']; -} diff --git a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.ts b/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.ts deleted file mode 100644 index 9fe58d8f8b..0000000000 --- a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.ts +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - import INgModelController = angular.INgModelController; - 'use strict'; - - export interface IRadiobuttonElementScope extends ng.IScope { - elemId: string; - elemName: string; - text: string; - sdcModel: any; - value: any; - disabled: boolean; - onValueChange:Function; - } - - export class RadiobuttonElementDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService) { - } - - public replace = true; - public restrict = 'E'; - public transclude = false; - - scope = { - elemId: '@', - elemName: '@', - text: '@', - sdcModel: '=', - value: '@', - disabled: '=', - onValueChange: '&' - }; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/elements/radiobutton/radiobutton.html'); - }; - - public link = (scope:IRadiobuttonElementScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { - //$elem.removeAttr("id") - //console.log(scope.sdcChecklistValue); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $filter:ng.IFilterService)=> { - return new RadiobuttonElementDirective($templateCache, $filter); - }; - - } - - RadiobuttonElementDirective.factory.$inject = ['$templateCache', '$filter']; -} diff --git a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.ts b/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.ts deleted file mode 100644 index a5ccf248e0..0000000000 --- a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.ts +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - export interface IEllipsisScope extends ng.IScope { - ellipsis: string; - maxChars: number; - toggleText(): void; - collapsed: boolean; - actualText: string; - - } - - export class EllipsisDirective implements ng.IDirective { - - constructor(private $templateCache: ng.ITemplateCacheService) {} - - scope = { - ellipsis: '=', - moreClass: '@', - maxChars: '=' - }; - - replace = false; - restrict = 'A'; - template = (): string => { - return this.$templateCache.get('/app/scripts/directives/ellipsis/ellipsis-directive.html'); - }; - - link = (scope:IEllipsisScope, $elem:any) => { - - - scope.collapsed = true; - - scope.toggleText = (): void => { - if(scope.ellipsis && scope.collapsed) { - scope.actualText = scope.ellipsis.substr(0, scope.maxChars); - scope.actualText += scope.ellipsis.length > scope.maxChars ? '...' : ''; - } - else - { - scope.actualText = scope.ellipsis; - } - }; - - scope.$watch("ellipsis", function(){ - scope.collapsed = true; - scope.toggleText(); - }); - - - - }; - - public static factory = ($templateCache: ng.ITemplateCacheService)=> { - return new EllipsisDirective($templateCache); - }; - - } - - EllipsisDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/events/on-last-repeat/on-last-repeat.ts b/catalog-ui/app/scripts/directives/events/on-last-repeat/on-last-repeat.ts deleted file mode 100644 index 0fb682d202..0000000000 --- a/catalog-ui/app/scripts/directives/events/on-last-repeat/on-last-repeat.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - /** - * Usage: - * In data-ng-repeat html: <ol ng-repeat="record in records" on-last-repeat> - * In the controller, catch the last repeat: - * $scope.$on('onRepeatLast', function(scope, element, attrs){ - * //work your magic - * }); - */ - export interface IOnLastRepeatDirectiveScope extends ng.IScope { - $last:any; - } - - export class OnLastRepeatDirective implements ng.IDirective { - - constructor() {} - - scope = {}; - - restrict = 'AE'; - replace = true; - - link = (scope:IOnLastRepeatDirectiveScope, element:any, attrs:any) => { - let s:any = scope.$parent; // repeat scope - if (s.$last) { - setTimeout(function(){ - s.$emit('onRepeatLast', element, attrs); - }, 1); - } - }; - - public static factory = ()=> { - return new OnLastRepeatDirective(); - }; - - } - - OnLastRepeatDirective.factory.$inject = []; -} diff --git a/catalog-ui/app/scripts/directives/file-opener/file-opener.ts b/catalog-ui/app/scripts/directives/file-opener/file-opener.ts deleted file mode 100644 index b7e3e1804c..0000000000 --- a/catalog-ui/app/scripts/directives/file-opener/file-opener.ts +++ /dev/null @@ -1,77 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface IFileOpenerScope extends ng.IScope { - importFile:any; - testsId:any; - extensions:string; - - onFileSelect():void; - onFileUpload(file:any):void; - getExtensionsWithDot():string; - } - - export class FileOpenerDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $compile:ng.ICompileService) { - } - - scope = { - onFileUpload: '&', - testsId: '@', - extensions: '@' - }; - - restrict = 'AE'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/file-opener/file-opener.html'); - }; - - link = (scope:IFileOpenerScope, element:any) => { - - scope.onFileSelect = () => { - scope.onFileUpload({file: scope.importFile}); - element.html(this.$templateCache.get('/app/scripts/directives/file-opener/file-opener.html')); - this.$compile(element.contents())(scope); - }; - - scope.getExtensionsWithDot = ():string => { - let ret = []; - _.each(scope.extensions.split(','), function(item){ - ret.push("." + item.toString()); - }); - return ret.join(","); - }; - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $compile:ng.ICompileService)=> { - return new FileOpenerDirective($templateCache, $compile); - }; - - } - - FileOpenerDirective.factory.$inject = ['$templateCache', '$compile']; -} diff --git a/catalog-ui/app/scripts/directives/file-type/file-type.ts b/catalog-ui/app/scripts/directives/file-type/file-type.ts deleted file mode 100644 index e7dee17960..0000000000 --- a/catalog-ui/app/scripts/directives/file-type/file-type.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class FileTypeDirective implements ng.IDirective { - - constructor() {} - - require = 'ngModel'; - - link = (scope, elem, attrs, ngModel) => { - - let typesToApprove = ""; - - attrs.$observe('fileType', (val:string) => { - typesToApprove = val; - validate(ngModel.$viewValue); - }); - - let validate: Function = function (value) { - let fileName:string = elem.val(), valid:boolean = true; - - if (fileName && value && typesToApprove) { - let extension:string = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); - valid = typesToApprove.split(',').indexOf(extension) > -1; - } - - ngModel.$setValidity('filetype', valid); - if(!value) { - ngModel.$setPristine(); - } - return value; - }; - - //For DOM -> model validation - ngModel.$parsers.unshift(validate); - - }; - - public static factory = ()=> { - return new FileTypeDirective(); - }; - - } - - FileTypeDirective.factory.$inject = []; -} diff --git a/catalog-ui/app/scripts/directives/file-upload/file-upload.ts b/catalog-ui/app/scripts/directives/file-upload/file-upload.ts deleted file mode 100644 index 16db3e7e21..0000000000 --- a/catalog-ui/app/scripts/directives/file-upload/file-upload.ts +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 1/27/2016. - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class FileUploadModel { - filetype: string; - filename: string; - filesize: number; - base64: string; - } - - export interface IFileUploadScope extends ng.IScope { - fileModel: FileUploadModel; - formElement:ng.IFormController; - extensions: string; - elementDisabled: string; - elementName: string; - elementRequired: string; - myFileModel: any; // From the ng bind to <input type=file - defaultText: string; - onFileChangedInDirective:Function; - - getExtensionsWithDot():string; - onFileChange():void - onFileClick(element:any):void; - setEmptyError(element):void; - validateField(field:any):boolean; - cancel():void; - } - - - export class FileUploadDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, private sdcConfig:Models.IAppConfigurtaion) { - } - - scope = { - fileModel: '=', - formElement: '=', - extensions: '@', - elementDisabled: '@', - elementName: '@', - elementRequired: '@', - onFileChangedInDirective: '=?', - defaultText: '=', - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/file-upload/file-upload.html'); - }; - - link = (scope:IFileUploadScope, element:any, $attr:any) => { - - // In case the browse has filename, set it valid. - // When editing artifact the file is not sent again, so if we have filename I do not want to show error. - if (scope.fileModel && scope.fileModel.filename && scope.fileModel.filename!==''){ - scope.formElement[scope.elementName].$setValidity('required', true); - } - - scope.getExtensionsWithDot = ():string => { - let ret = []; - if(scope.extensions) { - _.each(scope.extensions.split(','), function (item) { - ret.push("." + item.toString()); - }); - } - return ret.join(","); - }; - - scope.onFileChange = ():void => { - if (scope.onFileChangedInDirective) { - scope.onFileChangedInDirective(); - } - if (scope.myFileModel) { - scope.fileModel = scope.myFileModel; - scope.formElement[scope.elementName].$setValidity('required', true); - } - }; - - scope.setEmptyError = (element):void => { - if(element.files[0].size){ - scope.formElement[scope.elementName].$setValidity('emptyFile', true); - }else{ - scope.formElement[scope.elementName].$setValidity('emptyFile', false); - scope.fileModel = undefined; - } - - }; - - // Workaround, in case user select a file then cancel (X) then select the file again, the event onChange is not fired. - // This is a workaround to fix this issue. - scope.onFileClick = (element:any):void => { - element.value = null; - }; - - scope.cancel = ():void => { - scope.fileModel.filename = ''; - scope.formElement[scope.elementName].$pristine; - scope.formElement[scope.elementName].$setValidity('required', false); - } - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, sdcConfig:Models.IAppConfigurtaion)=> { - return new FileUploadDirective($templateCache, sdcConfig); - }; - - } - - FileUploadDirective.factory.$inject = ['$templateCache', 'sdcConfig']; -} diff --git a/catalog-ui/app/scripts/directives/graphs-v2/common/common-graph-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/common/common-graph-utils.ts deleted file mode 100644 index e01e455e93..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/common/common-graph-utils.ts +++ /dev/null @@ -1,361 +0,0 @@ -/** - * Created by obarda on 12/21/2016. - */ -/** - * Created by obarda on 12/13/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Graph.Utils { - - export class CommonGraphUtils { - - constructor(private NodesFactory:Sdc.Utils.NodesFactory, private LinksFactory:Sdc.Utils.LinksFactory) { - - } - - public safeApply = (scope:ng.IScope, fn:any) => { //todo remove to general utils - let phase = scope.$root.$$phase; - if (phase == '$apply' || phase == '$digest') { - if (fn && (typeof(fn) === 'function')) { - fn(); - } - } else { - scope.$apply(fn); - } - }; - - /** - * Draw node on the graph - * @param cy - * @param compositionGraphNode - * @param position - * @returns {CollectionElements} - */ - public addNodeToGraph(cy:Cy.Instance, compositionGraphNode:Models.Graph.CommonNodeBase, position?:Cy.Position):Cy.CollectionElements { - - var node = cy.add(<Cy.ElementDefinition> { - group: 'nodes', - position: position, - data: compositionGraphNode, - classes: compositionGraphNode.classes - }); - - if(!node.data().isUcpe) { //ucpe should not have tooltip - this.initNodeTooltip(node); - } - return node; - }; - - /** - * The function will create a component instance node by the componentInstance position. - * If the node is UCPE the function will create all cp lan&wan for the ucpe - * @param cy - * @param compositionGraphNode - * @returns {Cy.CollectionElements} - */ - public addComponentInstanceNodeToGraph(cy:Cy.Instance, compositionGraphNode:Models.Graph.CompositionCiNodeBase):Cy.CollectionElements { - - let nodePosition = { - x: +compositionGraphNode.componentInstance.posX, - y: +compositionGraphNode.componentInstance.posY - }; - - let node = this.addNodeToGraph(cy, compositionGraphNode, nodePosition); - if (compositionGraphNode.isUcpe) { - this.createUcpeCpNodes(cy, node); - } - return node; - }; - - /** - * This function will create CP_WAN & CP_LAN for the UCPE. this is a special node on the group that will behave like ports on the ucpe - * @param cy - * @param ucpeGraphNode - */ - private createUcpeCpNodes(cy:Cy.Instance, ucpeGraphNode:Cy.CollectionNodes):void { - - let requirementsArray:Array<any> = ucpeGraphNode.data().componentInstance.requirements["tosca.capabilities.Node"]; - //show only LAN or WAN requirements - requirementsArray = _.reject(requirementsArray, (requirement:any) => { - let name:string = requirement.ownerName.toLowerCase(); - return name.indexOf('lan') === -1 && name.indexOf('wan') === -1; - }); - requirementsArray.sort(function (a, b) { - let nameA = a.ownerName.toLowerCase().match(/[^ ]+/)[0]; - let nameB = b.ownerName.toLowerCase().match(/[^ ]+/)[0]; - let numA = _.last(a.ownerName.toLowerCase().split(' ')); - let numB = _.last(b.ownerName.toLowerCase().split(' ')); - - if (nameA === nameB) return numA > numB ? 1 : -1; - return nameA < nameB ? 1 : -1; - }); - let position = angular.copy(ucpeGraphNode.boundingbox()); - //add CP nodes to group - let topCps:number = 0; - for (let i = 0; i < requirementsArray.length; i++) { - - let cpNode = this.NodesFactory.createUcpeCpNode(angular.copy(ucpeGraphNode.data().componentInstance)); - cpNode.componentInstance.capabilities = requirementsArray[i]; - cpNode.id = requirementsArray[i].ownerId; - cpNode.group = ucpeGraphNode.data().componentInstance.uniqueId; - cpNode.name = requirementsArray[i].ownerName; //for tooltip - cpNode.displayName = requirementsArray[i].ownerName; - cpNode.displayName = cpNode.displayName.length > 5 ? cpNode.displayName.substring(0, 5) + '...' : cpNode.displayName; - - - if (cpNode.name.toLowerCase().indexOf('lan') > -1) { - cpNode.textPosition = "top"; - cpNode.componentInstance.posX = position.x1 + (i * 90) - (topCps * 90) + 53; - cpNode.componentInstance.posY = position.y1 + 400 + 27; - } else { - cpNode.textPosition = "bottom"; - cpNode.componentInstance.posX = position.x1 + (topCps * 90) + 53; - cpNode.componentInstance.posY = position.y1 + 27; - topCps++; - } - let cyCpNode = this.addComponentInstanceNodeToGraph(cy, cpNode); - cyCpNode.lock(); - } - }; - - /** - * - * @param nodes - all nodes in graph in order to find the edge connecting the two nodes - * @param fromNodeId - * @param toNodeId - * @returns {boolean} true/false if the edge is certified (from node and to node are certified) - */ - public isRelationCertified(nodes:Cy.CollectionNodes, fromNodeId:string, toNodeId:string):boolean { - let resourceTemp = _.filter(nodes, function (node:Cy.CollectionFirst) { - return node.data().id === fromNodeId || node.data().id === toNodeId; - }); - let certified:boolean = true; - - _.forEach(resourceTemp, (item) => { - certified = certified && item.data().certified; - }); - - return certified; - } - - /** - * Add link to graph - only draw the link - * @param cy - * @param link - */ - public insertLinkToGraph = (cy:Cy.Instance, link:Models.CompositionCiLinkBase) => { - - if (!this.isRelationCertified(cy.nodes(), link.source, link.target)) { - link.classes = 'not-certified-link'; - } - cy.add({ - group: 'edges', - data: link, - classes: link.classes - }); - - }; - - /** - * go over the relations and draw links on the graph - * @param cy - * @param instancesRelations - */ - public initGraphLinks(cy:Cy.Instance, instancesRelations:Array<Models.RelationshipModel>) { - - if (instancesRelations) { - _.forEach(instancesRelations, (relationshipModel:Models.RelationshipModel) => { - _.forEach(relationshipModel.relationships, (relationship:Models.Relationship) => { - let linkToCreate = this.LinksFactory.createGraphLink(cy, relationshipModel, relationship); - this.insertLinkToGraph(cy, linkToCreate); - }); - }); - } - } - - /** - * Determine which nodes are in the UCPE and set child data for them. - * @param cy - */ - public initUcpeChildren(cy:Cy.Instance){ - let ucpe:Cy.CollectionNodes = cy.nodes('[?isUcpe]'); // Get ucpe on graph if exist - _.each(cy.edges('.ucpe-host-link'), (link)=>{ - - let ucpeChild:Cy.CollectionNodes = (link.source().id() == ucpe.id())? link.target() : link.source(); - this.initUcpeChildData(ucpeChild, ucpe); - - //vls dont have ucpe-host-link connection, so need to find them and iterate separately - let connectedVLs = ucpeChild.connectedEdges().connectedNodes('.vl-node'); - _.forEach(connectedVLs, (vl)=>{ //all connected vls must be UCPE children because not allowed to connect to a VL outside of the UCPE - this.initUcpeChildData(vl, ucpe); - }); - }); - } - - /** - * Set properties for nodes contained by the UCPE - * @param childNode- node contained in UCPE - * @param ucpe- ucpe container node - */ - public initUcpeChildData(childNode:Cy.CollectionNodes, ucpe:Cy.CollectionNodes){ - - if(!childNode.data('isInsideGroup')){ - this.updateUcpeChildPosition(childNode, ucpe); - childNode.data({isInsideGroup: true}); - } - - } - - /** - * Updates UCPE child node offset, which allows child nodes to be dragged in synchronization with ucpe - * @param childNode- node contained in UCPE - * @param ucpe- ucpe container node - */ - public updateUcpeChildPosition(childNode:Cy.CollectionNodes, ucpe:Cy.CollectionNodes){ - let childPos:Cy.Position = childNode.relativePosition(); - let ucpePos:Cy.Position = ucpe.relativePosition(); - let offset:Cy.Position = { - x: childPos.x - ucpePos.x, - y: childPos.y - ucpePos.y - }; - childNode.data("ucpeOffset", offset); - } - - /** - * Removes ucpe-child properties from the node - * @param childNode- node being removed from UCPE - */ - public removeUcpeChildData(childNode:Cy.CollectionNodes){ - childNode.removeData("ucpeOffset"); - childNode.data({isInsideGroup: false}); - - } - - - public HTMLCoordsToCytoscapeCoords(cytoscapeBoundingBox:Cy.Extent, mousePos:Cy.Position):Cy.Position { - return {x: mousePos.x + cytoscapeBoundingBox.x1, y: mousePos.y + cytoscapeBoundingBox.y1} - }; - - - public getCytoscapeNodePosition = (cy: Cy.Instance, event:IDragDropEvent):Cy.Position => { - let targetOffset = $(event.target).offset(); - let x = event.pageX - targetOffset.left; - let y = event.pageY - targetOffset.top; - - return this.HTMLCoordsToCytoscapeCoords(cy.extent(), { - x: x, - y: y - }); - }; - - - public getNodePosition(node:Cy.CollectionFirstNode):Cy.Position{ - let nodePosition = node.relativePoint(); - if(node.data().isUcpe){ //UCPEs use bounding box and not relative point. - nodePosition = {x: node.boundingbox().x1, y: node.boundingbox().y1}; - } - - return nodePosition; - } - - /** - * return true/false if first node contains in second - this used in order to verify is node is entirely inside ucpe - * @param firstBox - * @param secondBox - * @returns {boolean} - */ - public isFirstBoxContainsInSecondBox(firstBox:Cy.BoundingBox, secondBox:Cy.BoundingBox) { - - return firstBox.x1 > secondBox.x1 && firstBox.x2 < secondBox.x2 && firstBox.y1 > secondBox.y1 && firstBox.y2 < secondBox.y2; - - }; - - - /** - * Check if node node bounds position is inside any ucpe on graph, and return the ucpe - * @param {diagram} the diagram. - * @param {nodeActualBounds} the actual bound position of the node. - * @return the ucpe if found else return null - */ - public isInUcpe = (cy: Cy.Instance, nodeBounds: Cy.BoundingBox): Cy.CollectionElements => { - - let ucpeNodes = cy.nodes('[?isUcpe]').filterFn((ucpeNode) => { - return this.isFirstBoxContainsInSecondBox(nodeBounds, ucpeNode.boundingbox()); - }); - return ucpeNodes; - }; - - /** - * - * @param cy - * @param node - * @returns {Array} - */ - public getLinkableNodes(cy:Cy.Instance, node:Cy.CollectionFirstNode):Array<Models.Graph.CompositionCiNodeBase>{ - let compatibleNodes = []; - _.each(cy.nodes(), (tempNode)=>{ - if(this.nodeLocationsCompatible(cy, node, tempNode)){ - compatibleNodes.push(tempNode.data()); - } - }); - return compatibleNodes; - } - - /** - * Checks whether node locations are compatible in reference to UCPEs. - * Returns true if both nodes are in UCPE or both nodes out, or one node is UCPEpart. - * @param node1 - * @param node2 - */ - public nodeLocationsCompatible(cy:Cy.Instance, node1:Cy.CollectionFirstNode, node2:Cy.CollectionFirstNode){ - - let ucpe = cy.nodes('[?isUcpe]'); - if(!ucpe.length){ return true; } - if(node1.data().isUcpePart || node2.data().isUcpePart) { return true; } - - return (this.isFirstBoxContainsInSecondBox(node1.boundingbox(), ucpe.boundingbox()) == this.isFirstBoxContainsInSecondBox(node2.boundingbox(), ucpe.boundingbox())); - - } - - /** - * This function will init qtip tooltip on the node - * @param node - the node we want the tooltip to apply on - */ - public initNodeTooltip(node:Cy.CollectionNodes) { - - let opts = { - content: function () { - return this.data('name'); - }, - position: { - my: 'top center', - at: 'bottom center', - adjust: {x:0, y:-5} - }, - style: { - classes: 'qtip-dark qtip-rounded qtip-custom', - tip: { - width: 16, - height: 8 - } - }, - show: { - event: 'mouseover', - delay: 1000 - }, - hide: {event: 'mouseout mousedown'}, - includeLabels: true - }; - - if (node.data().isUcpePart){ //fix tooltip positioning for UCPE-cps - opts.position.adjust = {x:0, y:20}; - } - - node.qtip(opts); - }; - }; - - - - CommonGraphUtils.$inject = ['NodesFactory', 'LinksFactory']; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.directive.ts b/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.directive.ts deleted file mode 100644 index 708f1d091a..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.directive.ts +++ /dev/null @@ -1,555 +0,0 @@ -/// <reference path="../../../references"/> -module Sdc.Directives { - - import ComponentFactory = Sdc.Utils.ComponentFactory; - import LoaderService = Sdc.Services.LoaderService; - import GRAPH_EVENTS = Sdc.Utils.Constants.GRAPH_EVENTS; - - interface ICompositionGraphScope extends ng.IScope { - - component:Models.Components.Component; - isViewOnly:boolean; - // Link menu - create link menu - relationMenuDirectiveObj:Models.RelationMenuDirectiveObj; - isLinkMenuOpen:boolean; - createLinkFromMenu:(chosenMatch:Models.MatchBase, vl:Models.Components.Component)=>void; - - //modify link menu - for now only delete menu - relationMenuTimeout:ng.IPromise<any>; - linkMenuObject:Models.LinkMenu; - - //left palette functions callbacks - dropCallback(event:JQueryEventObject, ui:any):void; - beforeDropCallback(event:IDragDropEvent):void; - verifyDrop(event:JQueryEventObject, ui:any):void; - - //Links menus - deleteRelation(link:Cy.CollectionEdges):void; - hideRelationMenu(); - } - - export class CompositionGraph implements ng.IDirective { - private _cy:Cy.Instance; - private _currentlyCLickedNodePosition:Cy.Position; - private $document:JQuery = $(document); - private dragElement:JQuery; - private dragComponent: Sdc.Models.ComponentsInstances.ComponentInstance; - - constructor(private $q:ng.IQService, - private $filter:ng.IFilterService, - private $log:ng.ILogService, - private $timeout:ng.ITimeoutService, - private NodesFactory:Sdc.Utils.NodesFactory, - private CompositionGraphLinkUtils:Sdc.Graph.Utils.CompositionGraphLinkUtils, - private GeneralGraphUtils:Graph.Utils.CompositionGraphGeneralUtils, - private ComponentInstanceFactory:Utils.ComponentInstanceFactory, - private NodesGraphUtils:Sdc.Graph.Utils.CompositionGraphNodesUtils, - private eventListenerService:Services.EventListenerService, - private ComponentFactory:ComponentFactory, - private LoaderService:LoaderService, - private commonGraphUtils:Graph.Utils.CommonGraphUtils, - private matchCapabilitiesRequirementsUtils:Graph.Utils.MatchCapabilitiesRequirementsUtils) { - - } - - restrict = 'E'; - templateUrl = '/app/scripts/directives/graphs-v2/composition-graph/composition-graph.html'; - scope = { - component: '=', - isViewOnly: '=' - }; - - link = (scope:ICompositionGraphScope, el:JQuery) => { - this.loadGraph(scope, el); - - scope.$on('$destroy', () => { - this._cy.destroy(); - _.forEach(GRAPH_EVENTS, (event) => { - this.eventListenerService.unRegisterObserver(event); - }); - }); - - }; - - private loadGraph = (scope:ICompositionGraphScope, el:JQuery) => { - - - let graphEl = el.find('.sdc-composition-graph-wrapper'); - this.initGraph(graphEl, scope.isViewOnly); - this.initGraphNodes(scope.component.componentInstances, scope.isViewOnly); - this.commonGraphUtils.initGraphLinks(this._cy, scope.component.componentInstancesRelations); - this.commonGraphUtils.initUcpeChildren(this._cy); - this.initDropZone(scope); - this.registerCytoscapeGraphEvents(scope); - this.registerCustomEvents(scope, el); - this.initViewMode(scope.isViewOnly); - - }; - - private initGraph(graphEl:JQuery, isViewOnly:boolean) { - - this._cy = cytoscape({ - container: graphEl, - style: Sdc.Graph.Utils.ComponentIntanceNodesStyle.getCompositionGraphStyle(), - zoomingEnabled: false, - selectionType: 'single', - boxSelectionEnabled: true, - autolock: isViewOnly, - autoungrabify: isViewOnly - }); - } - - private initViewMode(isViewOnly:boolean) { - - if (isViewOnly) { - //remove event listeners - this._cy.off('drag'); - this._cy.off('handlemouseout'); - this._cy.off('handlemouseover'); - this._cy.edges().unselectify(); - } - }; - - private registerCustomEvents(scope:ICompositionGraphScope, el:JQuery) { - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, (component:Models.DisplayComponent) => { - this.$log.info(`composition-graph::registerEventServiceEvents:: palette hover on component: ${component.uniqueId}`); - - let nodesData = this.NodesGraphUtils.getAllNodesData(this._cy.nodes()); - let nodesLinks = this.GeneralGraphUtils.getAllCompositionCiLinks(this._cy); - - if (this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.containsKey(component.uniqueId)) { - let cacheComponent = this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.getValue(component.uniqueId); - let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(cacheComponent, nodesData, nodesLinks); - - this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy); - this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy); - - return; - } - - component.component.updateRequirementsCapabilities() - .then((res) => { - component.component.capabilities = res.capabilities; - component.component.requirements = res.requirements; - - let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(component.component, nodesData, nodesLinks); - this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy); - this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy) - }); - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT, () => { - this._cy.emit('hidehandles'); - this.matchCapabilitiesRequirementsUtils.resetFadedNodes(this._cy); - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_START, (dragElement, dragComponent) => { - - this.dragElement = dragElement; - this.dragComponent = this.ComponentInstanceFactory.createComponentInstanceFromComponent(dragComponent); - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_ACTION, (event:IDragDropEvent) => { - this._onComponentDrag(event); - - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_COMPONENT_INSTANCE_NAME_CHANGED, (component:Models.ComponentsInstances.ComponentInstance) => { - - let selectedNode = this._cy.getElementById(component.uniqueId); - selectedNode.data().componentInstance.name = component.name; - selectedNode.data('displayName', selectedNode.data().getDisplayName()); - - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, (componentInstance:Models.ComponentsInstances.ComponentInstance) => { - let nodeToDelete = this._cy.getElementById(componentInstance.uniqueId); - this.NodesGraphUtils.deleteNode(this._cy, scope.component, nodeToDelete); - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_MULTIPLE_COMPONENTS, () => { - - this._cy.$('node:selected').each((i:number, node:Cy.CollectionNodes) => { - this.NodesGraphUtils.deleteNode(this._cy, scope.component, node); - }); - - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_EDGE, (releaseLoading:boolean, linksToDelete:Cy.CollectionEdges) => { - this.CompositionGraphLinkUtils.deleteLink(this._cy, scope.component, releaseLoading, linksToDelete); - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, (node:Cy.CollectionNodes, ucpe:Cy.CollectionNodes, updateExistingNode: boolean) => { - - this.commonGraphUtils.initUcpeChildData(node, ucpe); - //check if item is a VL, and if so, skip adding the binding to ucpe - if(!(node.data() instanceof Sdc.Models.Graph.CompositionCiNodeVl)){ - this.CompositionGraphLinkUtils.createVfToUcpeLink(scope.component, this._cy, ucpe.data(), node.data()); //create link from the node to the ucpe - } - - if(updateExistingNode){ - let vlsPendingDeletion:Cy.CollectionNodes = this.NodesGraphUtils.deleteNodeVLsUponMoveToOrFromUCPE(scope.component, node.cy(), node); //delete connected VLs that no longer have 2 links - this.CompositionGraphLinkUtils.deleteLinksWhenNodeMovedFromOrToUCPE(scope.component, node.cy(), node, vlsPendingDeletion); //delete all connected links if needed - this.GeneralGraphUtils.pushUpdateComponentInstanceActionToQueue(scope.component, true, node.data().componentInstance); //update componentInstance position - } - - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, (node:Cy.CollectionNodes, ucpe:Cy.CollectionNodes) => { - this.commonGraphUtils.removeUcpeChildData(node); - let vlsPendingDeletion:Cy.CollectionNodes = this.NodesGraphUtils.deleteNodeVLsUponMoveToOrFromUCPE(scope.component, node.cy(), node); - this.CompositionGraphLinkUtils.deleteLinksWhenNodeMovedFromOrToUCPE(scope.component, node.cy(), node, vlsPendingDeletion); //delete all connected links if needed - this.GeneralGraphUtils.pushUpdateComponentInstanceActionToQueue(scope.component, true, node.data().componentInstance); //update componentInstance position - }); - - this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_VERSION_CHANGED, (component:Models.Components.Component) => { - scope.component = component; - this.loadGraph(scope, el); - }); - - - scope.createLinkFromMenu = (chosenMatch:Models.MatchBase, vl:Models.Components.Component):void => { - scope.isLinkMenuOpen = false; - - this.CompositionGraphLinkUtils.createLinkFromMenu(this._cy, chosenMatch, vl, scope.component); - }; - - scope.hideRelationMenu = () => { - this.commonGraphUtils.safeApply(scope, () => { - scope.linkMenuObject = null; - this.$timeout.cancel(scope.relationMenuTimeout); - }); - }; - - - scope.deleteRelation = (link:Cy.CollectionEdges) => { - scope.hideRelationMenu(); - - //if multiple edges selected, delete the VL itself so edges get deleted automatically - if (this._cy.$('edge:selected').length > 1) { - this.NodesGraphUtils.deleteNode(this._cy, scope.component, this._cy.$('node:selected')); - } else { - this.CompositionGraphLinkUtils.deleteLink(this._cy, scope.component, true, link); - } - }; - } - - - private registerCytoscapeGraphEvents(scope:ICompositionGraphScope) { - - this._cy.on('addedgemouseup', (event, data) => { - scope.relationMenuDirectiveObj = this.CompositionGraphLinkUtils.onLinkDrawn(this._cy, data.source, data.target); - if (scope.relationMenuDirectiveObj != null) { - scope.$apply(() => { - scope.isLinkMenuOpen = true; - }); - } - }); - this._cy.on('tapstart', 'node', (event:Cy.EventObject) => { - this._currentlyCLickedNodePosition = angular.copy(event.cyTarget[0].position()); //update node position on drag - if(event.cyTarget.data().isUcpe){ - this._cy.nodes('.ucpe-cp').unlock(); - event.cyTarget.style('opacity', 0.5); - } - }); - - this._cy.on('drag', 'node', (event:Cy.EventObject) => { - - if (event.cyTarget.data().isDraggable) { - event.cyTarget.style({'overlay-opacity': 0.24}); - if (this.GeneralGraphUtils.isValidDrop(this._cy, event.cyTarget)) { - event.cyTarget.style({'overlay-color': Utils.Constants.GraphColors.NODE_BACKGROUND_COLOR}); - } else { - event.cyTarget.style({'overlay-color': Utils.Constants.GraphColors.NODE_OVERLAPPING_BACKGROUND_COLOR}); - } - } - - if(event.cyTarget.data().isUcpe){ - let pos = event.cyTarget.position(); - - this._cy.nodes('[?isInsideGroup]').positions((i, node)=>{ - return { - x: pos.x + node.data("ucpeOffset").x, - y: pos.y + node.data("ucpeOffset").y - } - }); - } - }); - - - this._cy.on('handlemouseover', (event, payload) => { - - if (payload.node.grabbed()) { //no need to add opacity while we are dragging and hovering othe nodes - return; - } - - let nodesData = this.NodesGraphUtils.getAllNodesData(this._cy.nodes()); - let nodesLinks = this.GeneralGraphUtils.getAllCompositionCiLinks(this._cy); - - let linkableNodes = this.commonGraphUtils.getLinkableNodes(this._cy, payload.node); - let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(payload.node.data().componentInstance, linkableNodes, nodesLinks); - this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy); - this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy, payload.node.data()); - - }); - - this._cy.on('handlemouseout', () => { - this._cy.emit('hidehandles'); - this.matchCapabilitiesRequirementsUtils.resetFadedNodes(this._cy); - }); - - - this._cy.on('tapend', (event:Cy.EventObject) => { - - if (event.cyTarget === this._cy) { //On Background clicked - if (this._cy.$('node:selected').length === 0) { //if the background click but not dragged - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED); - } - scope.hideRelationMenu(); - } - - else if (event.cyTarget.isEdge()) { //On Edge clicked - if (scope.isViewOnly) return; - this.CompositionGraphLinkUtils.handleLinkClick(this._cy, event); - this.openModifyLinkMenu(scope, this.CompositionGraphLinkUtils.getModifyLinkMenu(event.cyTarget[0], event), 6000); - } - - else { //On Node clicked - this._cy.nodes(':grabbed').style({'overlay-opacity': 0}); - - let isUcpe:boolean = event.cyTarget.data().isUcpe; - let newPosition = event.cyTarget[0].position(); - //node position changed (drop after drag event) - we need to update position - if (this._currentlyCLickedNodePosition.x !== newPosition.x || this._currentlyCLickedNodePosition.y !== newPosition.y) { - let nodesMoved:Cy.CollectionNodes = this._cy.$(':grabbed'); - if(isUcpe){ - nodesMoved = nodesMoved.add(this._cy.nodes('[?isInsideGroup]:free')); //'child' nodes will not be recognized as "grabbed" elements within cytoscape. manually add them to collection of nodes moved. - } - this.NodesGraphUtils.onNodesPositionChanged(this._cy, scope.component, nodesMoved); - } else { - this.$log.debug('composition-graph::onNodeSelectedEvent:: fired'); - scope.$apply(() => { - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_NODE_SELECTED, event.cyTarget.data().componentInstance); - }); - } - - if(isUcpe){ - this._cy.nodes('.ucpe-cp').lock(); - event.cyTarget.style('opacity', 1); - } - - } - }); - - this._cy.on('boxselect', 'node', (event:Cy.EventObject) => { - this.eventListenerService.notifyObservers(Utils.Constants.GRAPH_EVENTS.ON_NODE_SELECTED, event.cyTarget.data().componentInstance); - }); - } - - private openModifyLinkMenu = (scope:ICompositionGraphScope, linkMenuObject:Models.LinkMenu, timeOutInMilliseconds?:number) => { - - this.commonGraphUtils.safeApply(scope, () => { - scope.linkMenuObject = linkMenuObject; - }); - - scope.relationMenuTimeout = this.$timeout(() => { - scope.hideRelationMenu(); - }, timeOutInMilliseconds ? timeOutInMilliseconds : 6000); - }; - - private initGraphNodes(componentInstances:Models.ComponentsInstances.ComponentInstance[], isViewOnly:boolean) { - - if (!isViewOnly) { //Init nodes handle extension - enable dynamic links - setTimeout(()=> { - let handles = new CytoscapeEdgeEditation; - handles.init(this._cy, 18); - handles.registerHandle(Sdc.Graph.Utils.ComponentIntanceNodesStyle.getBasicNodeHanlde()); - handles.registerHandle(Sdc.Graph.Utils.ComponentIntanceNodesStyle.getBasicSmallNodeHandle()); - handles.registerHandle(Sdc.Graph.Utils.ComponentIntanceNodesStyle.getUcpeCpNodeHandle()); - }, 0); - } - - _.each(componentInstances, (instance) => { - let compositionGraphNode:Models.Graph.CompositionCiNodeBase = this.NodesFactory.createNode(instance); - this.commonGraphUtils.addComponentInstanceNodeToGraph(this._cy, compositionGraphNode); - }); - - - - } - - - private initDropZone(scope:ICompositionGraphScope) { - - if (scope.isViewOnly) { - return; - } - scope.dropCallback = (event:IDragDropEvent) => { - this.$log.debug(`composition-graph::dropCallback:: fired`); - this.addNode(event, scope); - }; - - scope.verifyDrop = (event:JQueryEventObject) => { - - if(this.dragElement.hasClass('red')){ - return false; - } - return true; - }; - - scope.beforeDropCallback = (event:IDragDropEvent): ng.IPromise<void> => { - let deferred: ng.IDeferred<void> = this.$q.defer<void>(); - if(this.dragElement.hasClass('red')){ - deferred.reject(); - } else { - deferred.resolve(); - } - - return deferred.promise; - } - } - - private _getNodeBBox(event:IDragDropEvent, position?:Cy.Position) { - let bbox = <Cy.BoundingBox>{}; - if (!position) { - position = this.commonGraphUtils.getCytoscapeNodePosition(this._cy, event); - } - let cushionWidth:number = 40; - let cushionHeight:number = 40; - - bbox.x1 = position.x - cushionWidth / 2; - bbox.y1 = position.y - cushionHeight / 2; - bbox.x2 = position.x + cushionWidth / 2; - bbox.y2 = position.y + cushionHeight / 2; - return bbox; - } - - private createComponentInstanceOnGraphFromComponent(fullComponent:Models.Components.Component, event:IDragDropEvent, scope:ICompositionGraphScope) { - - let componentInstanceToCreate:Models.ComponentsInstances.ComponentInstance = this.ComponentInstanceFactory.createComponentInstanceFromComponent(fullComponent); - let cytoscapePosition:Cy.Position = this.commonGraphUtils.getCytoscapeNodePosition(this._cy, event); - - componentInstanceToCreate.posX = cytoscapePosition.x; - componentInstanceToCreate.posY = cytoscapePosition.y; - - - let onFailedCreatingInstance:(error:any) => void = (error:any) => { - this.LoaderService.hideLoader('composition-graph'); - }; - - //on success - update node data - let onSuccessCreatingInstance = (createInstance:Models.ComponentsInstances.ComponentInstance):void => { - - this.LoaderService.hideLoader('composition-graph'); - - createInstance.name = this.$filter('resourceName')(createInstance.name); - createInstance.requirements = new Models.RequirementsGroup(fullComponent.requirements); - createInstance.capabilities = new Models.CapabilitiesGroup(fullComponent.capabilities); - createInstance.componentVersion = fullComponent.version; - createInstance.icon = fullComponent.icon; - createInstance.setInstanceRC(); - - let newNode:Models.Graph.CompositionCiNodeBase = this.NodesFactory.createNode(createInstance); - let cyNode:Cy.CollectionNodes = this.commonGraphUtils.addComponentInstanceNodeToGraph(this._cy, newNode); - - //check if node was dropped into a UCPE - let ucpe:Cy.CollectionElements = this.commonGraphUtils.isInUcpe(this._cy, cyNode.boundingbox()); - if (ucpe.length > 0) { - this.eventListenerService.notifyObservers(Utils.Constants.GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, cyNode, ucpe, false); - } - - }; - - // Create the component instance on server - this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIAction(() => { - scope.component.createComponentInstance(componentInstanceToCreate).then(onSuccessCreatingInstance, onFailedCreatingInstance); - }); - } - - private _onComponentDrag(event:IDragDropEvent) { - - if(event.clientX < Sdc.Utils.Constants.GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET || event.clientY < Sdc.Utils.Constants.GraphUIObjects.DIAGRAM_HEADER_OFFSET){ //hovering over palette. Dont bother computing validity of drop - this.dragElement.removeClass('red'); - return; - } - - let offsetPosition = {x: event.clientX - Sdc.Utils.Constants.GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET, y: event.clientY - Sdc.Utils.Constants.GraphUIObjects.DIAGRAM_HEADER_OFFSET} - let bbox = this._getNodeBBox(event, offsetPosition); - - if (this.GeneralGraphUtils.isPaletteDropValid(this._cy, bbox, this.dragComponent)) { - this.dragElement.removeClass('red'); - } else { - this.dragElement.addClass('red'); - } - } - - private addNode(event:IDragDropEvent, scope:ICompositionGraphScope) { - this.LoaderService.showLoader('composition-graph'); - - this.$log.debug('composition-graph::addNode:: fired'); - let draggedComponent:Models.Components.Component = event.dataTransfer.component; - - if (this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.containsKey(draggedComponent.uniqueId)) { - this.$log.debug('composition-graph::addNode:: capabilities found in cache, creating component'); - let fullComponent = this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.getValue(draggedComponent.uniqueId); - this.createComponentInstanceOnGraphFromComponent(fullComponent, event, scope); - return; - } - - this.$log.debug('composition-graph::addNode:: capabilities not found, requesting from server'); - this.ComponentFactory.getComponentFromServer(draggedComponent.getComponentSubType(), draggedComponent.uniqueId) - .then((fullComponent:Models.Components.Component) => { - this.createComponentInstanceOnGraphFromComponent(fullComponent, event, scope); - }); - } - - public static factory = ($q, - $filter, - $log, - $timeout, - NodesFactory, - LinksGraphUtils, - GeneralGraphUtils, - ComponentInstanceFactory, - NodesGraphUtils, - EventListenerService, - ComponentFactory, - LoaderService, - CommonGraphUtils, - MatchCapabilitiesRequirementsUtils) => { - return new CompositionGraph( - $q, - $filter, - $log, - $timeout, - NodesFactory, - LinksGraphUtils, - GeneralGraphUtils, - ComponentInstanceFactory, - NodesGraphUtils, - EventListenerService, - ComponentFactory, - LoaderService, - CommonGraphUtils, - MatchCapabilitiesRequirementsUtils); - } - } - - CompositionGraph.factory.$inject = [ - '$q', - '$filter', - '$log', - '$timeout', - 'NodesFactory', - 'CompositionGraphLinkUtils', - 'CompositionGraphGeneralUtils', - 'ComponentInstanceFactory', - 'CompositionGraphNodesUtils', - 'EventListenerService', - 'ComponentFactory', - 'LoaderService', - 'CommonGraphUtils', - 'MatchCapabilitiesRequirementsUtils' - ]; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts deleted file mode 100644 index 495a243d75..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts +++ /dev/null @@ -1,243 +0,0 @@ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils { - - import Dictionary = Sdc.Utils.Dictionary; - - export class CompositionGraphGeneralUtils { - - public componentRequirementsAndCapabilitiesCaching = new Dictionary<string, Models.Components.Component>(); - protected static graphUtilsUpdateQueue: Sdc.Utils.Functions.QueueUtils; - - constructor(private $q: ng.IQService, - private LoaderService: Services.LoaderService, - private commonGraphUtils: Sdc.Graph.Utils.CommonGraphUtils, - private matchCapabilitiesRequirementsUtils: Graph.Utils.MatchCapabilitiesRequirementsUtils) { - CompositionGraphGeneralUtils.graphUtilsUpdateQueue = new Sdc.Utils.Functions.QueueUtils(this.$q); - } - - - /** - * Get the offset for the link creation Menu - * @param point - * @returns {Cy.Position} - */ - public calcMenuOffset: Function = (point: Cy.Position): Cy.Position => { - point.x = point.x + 60; - point.y = point.y + 105; - return point; - }; - - /** - * return the top left position of the link menu - * @param cy - * @param targetNodePosition - * @returns {Cy.Position} - */ - public getLinkMenuPosition = (cy: Cy.Instance, targetNodePosition: Cy.Position) => { - let menuPosition: Cy.Position = this.calcMenuOffset(targetNodePosition); //get the link mid point - if (document.body.scrollHeight < menuPosition.y + Sdc.Utils.Constants.GraphUIObjects.LINK_MENU_HEIGHT + $(document.getElementsByClassName('sdc-composition-graph-wrapper')).offset().top) { // if position menu is overflow bottom - menuPosition.y = document.body.scrollHeight - Sdc.Utils.Constants.GraphUIObjects.TOP_HEADER_HEIGHT - Sdc.Utils.Constants.GraphUIObjects.LINK_MENU_HEIGHT; - } - return menuPosition; - }; - - - /** - * will return true/false if two nodes overlapping - * - * @param graph node - */ - private isNodesOverlapping(node: Cy.CollectionFirstNode, draggedNode: Cy.CollectionFirstNode): boolean { - - let nodeBoundingBox: Cy.BoundingBox = node.renderedBoundingBox(); - let secondNodeBoundingBox: Cy.BoundingBox = draggedNode.renderedBoundingBox(); - - return this.isBBoxOverlapping(nodeBoundingBox, secondNodeBoundingBox); - } - - /** - * Checks whether the bounding boxes of two nodes are overlapping on any side - * @param nodeOneBBox - * @param nodeTwoBBox - * @returns {boolean} - */ - private isBBoxOverlapping(nodeOneBBox: Cy.BoundingBox, nodeTwoBBox: Cy.BoundingBox) { - return (((nodeOneBBox.x1 < nodeTwoBBox.x1 && nodeOneBBox.x2 > nodeTwoBBox.x1) || - (nodeOneBBox.x1 < nodeTwoBBox.x2 && nodeOneBBox.x2 > nodeTwoBBox.x2) || - (nodeTwoBBox.x1 < nodeOneBBox.x1 && nodeTwoBBox.x2 > nodeOneBBox.x2)) && - ((nodeOneBBox.y1 < nodeTwoBBox.y1 && nodeOneBBox.y2 > nodeTwoBBox.y1) || - (nodeOneBBox.y1 < nodeTwoBBox.y2 && nodeOneBBox.y2 > nodeTwoBBox.y2) || - (nodeTwoBBox.y1 < nodeOneBBox.y1 && nodeTwoBBox.y2 > nodeOneBBox.y2))) - } - - - /** - * Checks whether a specific component instance can be hosted on the UCPE instance - * @param cy - Cytoscape instance - * @param fromUcpeInstance - * @param toComponentInstance - * @returns {Models.MatchReqToCapability} - */ - public canBeHostedOn(cy: Cy.Instance, fromUcpeInstance: Models.ComponentsInstances.ComponentInstance, toComponentInstance: Models.ComponentsInstances.ComponentInstance): Models.MatchReqToCapability { - - let matches: Array<Models.MatchBase> = this.matchCapabilitiesRequirementsUtils.getMatchedRequirementsCapabilities(fromUcpeInstance, toComponentInstance, this.getAllCompositionCiLinks(cy)); - let hostedOnMatch: Models.MatchBase = _.find(matches, (match: Models.MatchReqToCapability) => { - return match.requirement.capability.toLowerCase() === 'tosca.capabilities.container'; - }); - - return <Models.MatchReqToCapability>hostedOnMatch; - }; - - - /** - * Checks whether node can be dropped into UCPE - * @param cy - * @param nodeToInsert - * @param ucpeNode - * @returns {boolean} - */ - private isValidDropInsideUCPE(cy: Cy.Instance, nodeToInsert: Models.ComponentsInstances.ComponentInstance, ucpeNode: Models.ComponentsInstances.ComponentInstance): boolean { - - let hostedOnMatch: Models.MatchReqToCapability = this.canBeHostedOn(cy, ucpeNode, nodeToInsert); - let result: boolean = !angular.isUndefined(hostedOnMatch) || nodeToInsert.isVl(); //group validation - return result; - - }; - - - /** - * For drops from palette, checks whether the node can be dropped. If node is being held over another node, check if capable of hosting - * @param cy - * @param pseudoNodeBBox - * @param paletteComponentInstance - * @returns {boolean} - */ - public isPaletteDropValid(cy: Cy.Instance, pseudoNodeBBox: Cy.BoundingBox, paletteComponentInstance:Sdc.Models.ComponentsInstances.ComponentInstance) { - - let componentIsUCPE:boolean = (paletteComponentInstance.capabilities && paletteComponentInstance.capabilities['tosca.capabilities.Container'] && paletteComponentInstance.name.toLowerCase().indexOf('ucpe') > -1); - - if(componentIsUCPE && cy.nodes('[?isUcpe]').length > 0) { //second UCPE not allowed - return false; - } - - let illegalOverlappingNodes = _.filter(cy.nodes("[isSdcElement]"), (graphNode: Cy.CollectionFirstNode) => { - - if(this.isBBoxOverlapping(pseudoNodeBBox, graphNode.renderedBoundingBox())){ - if (!componentIsUCPE && graphNode.data().isUcpe) { - return !this.isValidDropInsideUCPE(cy, paletteComponentInstance, graphNode.data().componentInstance); //if this is valid insert into ucpe, we return false - no illegal overlapping nodes - } - return true; - } - - return false; - }); - - return illegalOverlappingNodes.length === 0; - } - - /** - * will return true/false if a drop of a single node is valid - * - * @param graph node - */ - public isValidDrop(cy: Cy.Instance, draggedNode: Cy.CollectionFirstNode): boolean { - - let illegalOverlappingNodes = _.filter(cy.nodes("[isSdcElement]"), (graphNode: Cy.CollectionFirstNode) => { //all sdc nodes, removing child nodes (childe node allways collaps - - if (draggedNode.data().isUcpe && (graphNode.isChild() || graphNode.data().isInsideGroup)) { //ucpe cps always inside ucpe, no overlapping - return false; - } - if(draggedNode.data().isInsideGroup && (!draggedNode.active() || graphNode.data().isUcpe)) { - return false; - } - - if (!draggedNode.data().isUcpe && !(draggedNode.data() instanceof Sdc.Models.Graph.CompositionCiNodeUcpeCp) && graphNode.data().isUcpe) { //case we are dragging a node into UCPE - let isEntirelyInUCPE:boolean = this.commonGraphUtils.isFirstBoxContainsInSecondBox(draggedNode.renderedBoundingBox(), graphNode.renderedBoundingBox()); - if (isEntirelyInUCPE){ - if(this.isValidDropInsideUCPE(cy, draggedNode.data().componentInstance, graphNode.data().componentInstance)){ //if this is valid insert into ucpe, we return false - no illegal overlapping nodes - return false; - } - } - } - return graphNode.data().id !== draggedNode.data().id && this.isNodesOverlapping(draggedNode, graphNode); - - }); - // return false; - return illegalOverlappingNodes.length === 0; - }; - - /** - * will return true/false if the move of the nodes is valid (no node overlapping and verifying if insert into UCPE is valid) - * - * @param nodesArray - the selected drags nodes - */ - public isGroupValidDrop(cy: Cy.Instance, nodesArray: Cy.CollectionNodes): boolean { - var filterDraggedNodes = nodesArray.filter('[?isDraggable]'); - let isValidDrop = _.every(filterDraggedNodes, (node: Cy.CollectionFirstNode) => { - return this.isValidDrop(cy, node); - - }); - return isValidDrop; - }; - - /** - * get all links in diagram - * @param cy - * @returns {any[]|boolean[]} - */ - public getAllCompositionCiLinks = (cy: Cy.Instance): Array<Models.CompositionCiLinkBase> => { - return _.map(cy.edges("[isSdcElement]"), (edge: Cy.CollectionEdges) => { - return edge.data(); - }); - }; - - - /** - * Get Graph Utils server queue - * @returns {Sdc.Utils.Functions.QueueUtils} - */ - public getGraphUtilsServerUpdateQueue(): Sdc.Utils.Functions.QueueUtils { - return CompositionGraphGeneralUtils.graphUtilsUpdateQueue; - } - ; - - /** - * - * @param blockAction - true/false if this is a block action - * @param instances - * @param component - */ - public pushMultipleUpdateComponentInstancesRequestToQueue = (blockAction: boolean, instances: Array<Models.ComponentsInstances.ComponentInstance>, component: Models.Components.Component): void => { - if (blockAction) { - this.getGraphUtilsServerUpdateQueue().addBlockingUIAction( - () => component.updateMultipleComponentInstances(instances) - ); - } else { - this.getGraphUtilsServerUpdateQueue().addNonBlockingUIAction( - () => component.updateMultipleComponentInstances(instances), - () => this.LoaderService.hideLoader('composition-graph')); - } - }; - - /** - * this function will update component instance data - * @param blockAction - true/false if this is a block action - * @param updatedInstance - */ - public pushUpdateComponentInstanceActionToQueue = (component: Models.Components.Component, blockAction: boolean, updatedInstance: Models.ComponentsInstances.ComponentInstance): void => { - - if (blockAction) { - this.LoaderService.showLoader('composition-graph'); - this.getGraphUtilsServerUpdateQueue().addBlockingUIAction( - () => component.updateComponentInstance(updatedInstance) - ); - } else { - this.getGraphUtilsServerUpdateQueue().addNonBlockingUIAction( - () => component.updateComponentInstance(updatedInstance), - () => this.LoaderService.hideLoader('composition-graph')); - } - }; - } - - CompositionGraphGeneralUtils.$inject = ['$q', 'LoaderService', 'CommonGraphUtils', 'MatchCapabilitiesRequirementsUtils']; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts deleted file mode 100644 index 602e6b6def..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts +++ /dev/null @@ -1,347 +0,0 @@ -/** - * Created by obarda on 6/28/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils { - - import ImageCreatorService = Sdc.Utils.ImageCreatorService; - import Module = Sdc.Models.Module; - export class CompositionGraphLinkUtils { - - private p2pVL:Models.Components.Component; - private mp2mpVL:Models.Components.Component; - - constructor(private linksFactory:Sdc.Utils.LinksFactory, - private loaderService:Services.LoaderService, - private generalGraphUtils:Sdc.Graph.Utils.CompositionGraphGeneralUtils, - private leftPaletteLoaderService:Services.Components.LeftPaletteLoaderService, - private componentInstanceFactory:Sdc.Utils.ComponentInstanceFactory, - private nodesFactory:Sdc.Utils.NodesFactory, - private commonGraphUtils: Sdc.Graph.Utils.CommonGraphUtils, - private matchCapabilitiesRequirementsUtils: Graph.Utils.MatchCapabilitiesRequirementsUtils) { - - this.initScopeVls(); - - } - - - /** - * Delete the link on server and then remove it from graph - * @param component - * @param releaseLoading - true/false release the loader when finished - * @param link - the link to delete - */ - public deleteLink = (cy:Cy.Instance, component:Models.Components.Component, releaseLoading:boolean, link:Cy.CollectionEdges) => { - - this.loaderService.showLoader('composition-graph'); - let onSuccessDeleteRelation = (response) => { - cy.remove(link); - }; - - if (!releaseLoading) { - this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIAction( - () => component.deleteRelation(link.data().relation).then(onSuccessDeleteRelation) - ); - } else { - this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( - () => component.deleteRelation(link.data().relation).then(onSuccessDeleteRelation), - () => this.loaderService.hideLoader('composition-graph')); - } - }; - - /** - * create the link on server and than draw it on graph - * @param link - the link to create - * @param cy - * @param component - */ - public createLink = (link:Models.CompositionCiLinkBase, cy:Cy.Instance, component:Models.Components.Component):void => { - - this.loaderService.showLoader('composition-graph'); - - let onSuccess:(response:Models.RelationshipModel) => void = (relation:Models.RelationshipModel) => { - link.setRelation(relation); - this.commonGraphUtils.insertLinkToGraph(cy, link); - }; - - link.updateLinkDirection(); - - this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( - () => component.createRelation(link.relation).then(onSuccess), - () => this.loaderService.hideLoader('composition-graph') - ); - }; - - - public initScopeVls = ():void => { - - let vls = this.leftPaletteLoaderService.getFullDataComponentList(Sdc.Utils.Constants.ResourceType.VL); - vls.forEach((item) => { - let key = _.find(Object.keys(item.capabilities), (key) => { - return _.includes(key.toLowerCase(), 'linkable'); - }); - let linkable = item.capabilities[key]; - if (linkable) { - if (linkable[0].maxOccurrences == '2') { - this.p2pVL = _.find(vls, (component:Models.Components.Component) => { - return component.uniqueId === item.uniqueId; - }); - - } else {//assuming unbounded occurrences - this.mp2mpVL = _.find(vls, (component:Models.Components.Component) => { - return component.uniqueId === item.uniqueId; - }); - } - } - }); - }; - - private setVLlinks = (match:Models.MatchReqToReq, vl:Models.ComponentsInstances.ComponentInstance):Array<Models.RelationshipModel> => { - - let relationship1 = new Models.Relationship(); - let relationship2 = new Models.Relationship(); - let newRelationshipModel1 = new Models.RelationshipModel(); - let newRelationshipModel2 = new Models.RelationshipModel(); - - let capability:Models.Capability = vl.capabilities.findValueByKey('linkable')[0]; - relationship1.setRelationProperties(capability, match.requirement); - relationship2.setRelationProperties(capability, match.secondRequirement); - - newRelationshipModel1.setRelationshipModelParams(match.fromNode, vl.uniqueId, [relationship1]); - newRelationshipModel2.setRelationshipModelParams(match.toNode, vl.uniqueId, [relationship2]); - - return [newRelationshipModel1, newRelationshipModel2]; - }; - - private createVlinks = (cy:Cy.Instance, component:Models.Components.Component, matchReqToReq:Models.MatchReqToReq, vl:Models.Components.Component):void => { - - let componentInstance:Models.ComponentsInstances.ComponentInstance = this.componentInstanceFactory.createComponentInstanceFromComponent(vl); - let fromNodePosition:Cy.Position = cy.getElementById(matchReqToReq.fromNode).relativePosition(); - let toNodePosition:Cy.Position = cy.getElementById(matchReqToReq.toNode).relativePosition(); - let location:Cy.Position = { - x: 0.5 * (fromNodePosition.x + toNodePosition.x), - y: 0.5 * (fromNodePosition.y + toNodePosition.y) - } - - componentInstance.posX = location.x; - componentInstance.posY = location.y; - - let onFailed:(error:any) => void = (error:any) => { - this.loaderService.hideLoader('composition-graph'); - console.info('onFailed', error); - }; - - let onSuccess = (response:Models.ComponentsInstances.ComponentInstance):void => { - - console.info('onSuccses', response); - response.requirements = new Models.RequirementsGroup(vl.requirements); - response.capabilities = new Models.CapabilitiesGroup(vl.capabilities); - response.componentVersion = vl.version; - response.setInstanceRC(); - - let newLinks = this.setVLlinks(matchReqToReq, response); - let newNode = this.nodesFactory.createNode(response); - - this.commonGraphUtils.addComponentInstanceNodeToGraph(cy, newNode); - - _.forEach(newLinks, (link) => { - let linkObg:Models.CompositionCiLinkBase = this.linksFactory.createGraphLink(cy, link, link.relationships[0]); - this.createLink(linkObg, cy, component); - }); - }; - component.createComponentInstance(componentInstance).then(onSuccess, onFailed); - }; - - private createSimpleLink = (match:Models.MatchReqToCapability, cy:Cy.Instance, component:Models.Components.Component):void => { - let newRelation:Models.RelationshipModel = match.matchToRelationModel(); - let linkObg:Models.CompositionCiLinkBase = this.linksFactory.createGraphLink(cy,newRelation, newRelation.relationships[0]); - this.createLink(linkObg, cy, component); - }; - - public createLinkFromMenu = (cy:Cy.Instance, chosenMatch:Models.MatchBase, vl:Models.Components.Component, component:Models.Components.Component):void => { - - if (chosenMatch) { - if (chosenMatch && chosenMatch instanceof Models.MatchReqToReq) { - this.createVlinks(cy, component, chosenMatch, vl); //TODO orit implement - } - if (chosenMatch && chosenMatch instanceof Models.MatchReqToCapability) { - this.createSimpleLink(chosenMatch, cy, component); - } - } - }; - - - /** - * Filters the matches for UCPE links so that shown requirements and capabilites are only related to the selected ucpe-cp - * @param fromNode - * @param toNode - * @param matchesArray - * @returns {Array<Models.MatchBase>} - */ - public filterUcpeLinks(fromNode: Models.Graph.CompositionCiNodeBase, toNode: Models.Graph.CompositionCiNodeBase, matchesArray: Array<Models.MatchBase>): any { - - let matchLink: Array<Models.MatchBase>; - - if (fromNode.isUcpePart) { - matchLink = _.filter(matchesArray, (match: Models.MatchBase) => { - return match.isOwner(fromNode.id); - }); - } - - if (toNode.isUcpePart) { - matchLink = _.filter(matchesArray, (match: Models.MatchBase) => { - return match.isOwner(toNode.id); - }); - } - return matchLink ? matchLink : matchesArray; - } - - - /** - * open the connect link menu if the link drawn is valid - match requirements & capabilities - * @param cy - * @param fromNode - * @param toNode - * @returns {any} - */ - public onLinkDrawn(cy:Cy.Instance, fromNode:Cy.CollectionFirstNode, toNode:Cy.CollectionFirstNode):Models.RelationMenuDirectiveObj { - - if(!this.commonGraphUtils.nodeLocationsCompatible(cy, fromNode, toNode)){ return null; } - let linkModel:Array<Models.CompositionCiLinkBase> = this.generalGraphUtils.getAllCompositionCiLinks(cy); - - let possibleRelations:Array<Models.MatchBase> = this.matchCapabilitiesRequirementsUtils.getMatchedRequirementsCapabilities(fromNode.data().componentInstance, - toNode.data().componentInstance, linkModel, this.mp2mpVL); //TODO orit - add p2p and mp2mp - - //filter relations found to limit to specific ucpe-cp - possibleRelations = this.filterUcpeLinks(fromNode.data(), toNode.data(), possibleRelations); - - //if found possibleRelations between the nodes we create relation menu directive and open the link menu - if (possibleRelations.length) { - let menuPosition = this.generalGraphUtils.getLinkMenuPosition(cy, toNode.renderedPoint()); - return new Models.RelationMenuDirectiveObj(fromNode.data(), toNode.data(), this.mp2mpVL, this.p2pVL, menuPosition, possibleRelations); - } - return null; - }; - - - /** - * when we drag instance in to UCPE or out of UCPE - get all links we need to delete - one node in ucpe and one node outside of ucpe - * @param node - the node we dragged into or out of the ucpe - */ - public deleteLinksWhenNodeMovedFromOrToUCPE(component:Models.Components.Component, cy:Cy.Instance, nodeMoved:Cy.CollectionNodes, vlsPendingDeletion?:Cy.CollectionNodes):void { - - - let linksToDelete:Cy.CollectionElements = cy.collection(); - _.forEach(nodeMoved.neighborhood('node'), (neighborNode)=>{ - - if(neighborNode.data().isUcpePart){ //existing connections to ucpe or ucpe-cp - we want to delete even though nodeLocationsCompatible will technically return true - linksToDelete = linksToDelete.add(nodeMoved.edgesWith(neighborNode)); // This will delete the ucpe-host-link, or the vl-ucpe-link if nodeMoved is vl - } else if(!this.commonGraphUtils.nodeLocationsCompatible(cy, nodeMoved, neighborNode)){ //connection to regular node or vl - check if locations are compatible - if(!vlsPendingDeletion || !vlsPendingDeletion.intersect(neighborNode).length){ //Check if this is a link to a VL pending deletion, to prevent double deletion of between the node moved and vl - linksToDelete = linksToDelete.add(nodeMoved.edgesWith(neighborNode)); - } - } - }); - - - - linksToDelete.each((i, link)=>{ - this.deleteLink(cy, component, false, link); - }); - - }; - - - /** - * Creates a hostedOn link between a VF and UCPE - * @param component - * @param cy - * @param ucpeNode - * @param vfNode - */ - public createVfToUcpeLink = (component: Models.Components.Component, cy:Cy.Instance, ucpeNode:Models.Graph.NodeUcpe, vfNode:Models.Graph.CompositionCiNodeVf):void => { - let hostedOnMatch:Models.MatchReqToCapability = this.generalGraphUtils.canBeHostedOn(cy, ucpeNode.componentInstance, vfNode.componentInstance); - /* create relation */ - let newRelation = new Models.RelationshipModel(); - newRelation.fromNode = ucpeNode.id; - newRelation.toNode = vfNode.id; - - let link:Models.CompositionCiLinkBase = this.linksFactory.createUcpeHostLink(newRelation); - link.relation = hostedOnMatch.matchToRelationModel(); - this.createLink(link, cy, component); - }; - - - /** - * Handles click event on links. - * If one edge selected: do nothing. - /*Two edges selected - always select all - /* Three or more edges: first click - select all, secondary click - select single. - * @param cy - * @param event - */ - public handleLinkClick(cy:Cy.Instance, event : Cy.EventObject) { - if(cy.$('edge:selected').length > 2 && event.cyTarget[0].selected()) { - cy.$(':selected').unselect(); - } else { - - let vl: Cy.CollectionNodes = event.cyTarget[0].target('.vl-node'); - let connectedEdges:Cy.CollectionEdges = vl.connectedEdges(); - if (vl.length && connectedEdges.length > 1) { - - setTimeout(() => { - vl.select(); - connectedEdges.select(); - }, 0); - } - } - - } - - - /** - * Calculates the position for the menu that modifies an existing link - * @param event - * @param elementWidth - * @param elementHeight - * @returns {Sdc.Models.Graph.Point} - */ - public calculateLinkMenuPosition(event, elementWidth, elementHeight): Sdc.Models.Graph.Point { - let point: Sdc.Models.Graph.Point = new Sdc.Models.Graph.Point(event.originalEvent.x,event.originalEvent.y); - if(event.originalEvent.view.screen.height-elementHeight<point.y){ - point.y = event.originalEvent.view.screen.height-elementHeight; - } - if(event.originalEvent.view.screen.width-elementWidth<point.x){ - point.x = event.originalEvent.view.screen.width-elementWidth; - } - return point; - }; - - - /** - * Gets the menu that is displayed when you click an existing link. - * @param link - * @param event - * @returns {Models.LinkMenu} - */ - public getModifyLinkMenu(link:Cy.CollectionFirstEdge, event:Cy.EventObject):Models.LinkMenu{ - let point:Sdc.Models.Graph.Point = this.calculateLinkMenuPosition(event,Sdc.Utils.Constants.GraphUIObjects.MENU_LINK_VL_WIDTH_OFFSET,Sdc.Utils.Constants.GraphUIObjects.MENU_LINK_VL_HEIGHT_OFFSET); - let menu:Models.LinkMenu = new Models.LinkMenu(point, true, link); - return menu; - }; - - } - - - - CompositionGraphLinkUtils.$inject = [ - 'LinksFactory', - 'LoaderService', - 'CompositionGraphGeneralUtils', - 'LeftPaletteLoaderService', - 'ComponentInstanceFactory', - 'NodesFactory', - 'CommonGraphUtils', - 'MatchCapabilitiesRequirementsUtils' - ]; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts deleted file mode 100644 index 95c31d16b1..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Created by obarda on 11/9/2016. - */ - -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils { - - export class CompositionGraphNodesUtils { - constructor(private NodesFactory:Sdc.Utils.NodesFactory, private $log:ng.ILogService, - private GeneralGraphUtils:Graph.Utils.CompositionGraphGeneralUtils, - private commonGraphUtils: Sdc.Graph.Utils.CommonGraphUtils, - private eventListenerService: Services.EventListenerService, - private loaderService:Services.LoaderService) { - - } - - /** - * Returns component instances for all nodes passed in - * @param nodes - Cy nodes - * @returns {any[]} - */ - public getAllNodesData(nodes:Cy.CollectionNodes) { - return _.map(nodes, (node:Cy.CollectionFirstNode)=> { - return node.data(); - }) - }; - - /** - * Deletes component instances on server and then removes it from the graph as well - * @param cy - * @param component - * @param nodeToDelete - */ - public deleteNode(cy: Cy.Instance, component:Models.Components.Component, nodeToDelete:Cy.CollectionNodes):void { - - this.loaderService.showLoader('composition-graph'); - let onSuccess:(response:Models.ComponentsInstances.ComponentInstance) => void = (response:Models.ComponentsInstances.ComponentInstance) => { - console.info('onSuccess', response); - - //if node to delete is a UCPE, remove all children (except UCPE-CPs) and remove their "hostedOn" links - if (nodeToDelete.data().isUcpe){ - _.each(cy.nodes('[?isInsideGroup]'), (node)=>{ - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node, nodeToDelete); - }); - } - - //check whether the node is connected to any VLs that only have one other connection. If so, delete that VL as well - if(!(nodeToDelete.data() instanceof Sdc.Models.Graph.CompositionCiNodeVl)){ - let connectedVls:Array<Cy.CollectionFirstNode> = this.getConnectedVlToNode(nodeToDelete); - this.handleConnectedVlsToDelete(connectedVls); - } - - //update UI - cy.remove(nodeToDelete); - - }; - - let onFailed:(response:any) => void = (response:any) => { - console.info('onFailed', response); - }; - - - this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( - () => component.deleteComponentInstance(nodeToDelete.data().componentInstance.uniqueId).then(onSuccess, onFailed), - () => this.loaderService.hideLoader('composition-graph') - ); - - }; - - - /** - * Finds all VLs connected to a single node - * @param node - * @returns {Array<Cy.CollectionFirstNode>} - */ - public getConnectedVlToNode = (node: Cy.CollectionNodes): Array<Cy.CollectionFirstNode> => { - let connectedVls: Array<Cy.CollectionFirstNode> = new Array<Cy.CollectionFirstNode>(); - _.forEach(node.connectedEdges().connectedNodes(), (node: Cy.CollectionFirstNode) => { - if (node.data() instanceof Models.Graph.CompositionCiNodeVl) { - connectedVls.push(node); - } - }); - return connectedVls; - }; - - - /** - * Delete all VLs that have only two connected nodes (this function is called when deleting a node) - * @param connectedVls - */ - public handleConnectedVlsToDelete = (connectedVls: Array<Cy.CollectionFirstNode>) => { - _.forEach(connectedVls, (vlToDelete: Cy.CollectionNodes) => { - - if (vlToDelete.connectedEdges().length === 2) { // if vl connected only to 2 nodes need to delete the vl - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, vlToDelete.data().componentInstance); - } - }); - }; - - - /** - * This function is called when moving a node in or out of UCPE. - * Deletes all connected VLs that have less than 2 valid connections remaining after the move - * Returns the collection of vls that are in the process of deletion (async) to prevent duplicate calls while deletion is in progress - * @param component - * @param cy - * @param node - node that was moved in/out of ucpe - */ - public deleteNodeVLsUponMoveToOrFromUCPE = (component:Models.Components.Component, cy:Cy.Instance, node:Cy.CollectionNodes):Cy.CollectionNodes =>{ - if(node.data() instanceof Models.Graph.CompositionCiNodeVl){ return;} - - let connectedVLsToDelete:Cy.CollectionNodes = cy.collection(); - _.forEach(node.neighborhood('node'), (connectedNode) => { - - //Find all neighboring nodes that are VLs - if(connectedNode.data() instanceof Models.Graph.CompositionCiNodeVl){ - - //check VL's neighbors to see if it has 2 or more nodes whose location is compatible with VL (regardless of whether VL is in or out of UCPE) - let compatibleNodeCount = 0; - let vlNeighborhood = connectedNode.neighborhood('node'); - _.forEach(vlNeighborhood, (vlNeighborNode)=>{ - if(this.commonGraphUtils.nodeLocationsCompatible(cy, connectedNode, vlNeighborNode)) { - compatibleNodeCount ++; - } - }); - - if(compatibleNodeCount < 2) { - connectedVLsToDelete = connectedVLsToDelete.add(connectedNode); - } - } - }); - - connectedVLsToDelete.each((i, vlToDelete:Cy.CollectionNodes)=>{ - this.deleteNode(cy, component, vlToDelete); - }); - return connectedVLsToDelete; - }; - - /** - * This function will update nodes position. if the new position is into or out of ucpe, the node will trigger the ucpe events - * @param cy - * @param component - * @param nodesMoved - the node/multiple nodes now moved by the user - */ - public onNodesPositionChanged = (cy: Cy.Instance, component:Models.Components.Component, nodesMoved: Cy.CollectionNodes): void => { - - if (nodesMoved.length === 0) { - return; - } - - let isValidMove:boolean = this.GeneralGraphUtils.isGroupValidDrop(cy, nodesMoved); - if (isValidMove) { - - this.$log.debug(`composition-graph::ValidDrop:: updating node position`); - let instancesToUpdateInNonBlockingAction:Array<Models.ComponentsInstances.ComponentInstance> = new Array<Models.ComponentsInstances.ComponentInstance>(); - - _.each(nodesMoved, (node:Cy.CollectionFirstNode)=> { //update all nodes new position - - if(node.data().isUcpePart && !node.data().isUcpe){ return; }//No need to update UCPE-CPs - - //update position - let newPosition:Cy.Position = this.commonGraphUtils.getNodePosition(node); - node.data().componentInstance.updatePosition(newPosition.x, newPosition.y); - - //check if node moved to or from UCPE - let ucpe = this.commonGraphUtils.isInUcpe(node.cy(), node.boundingbox()); - if(node.data().isInsideGroup || ucpe.length) { - this.handleUcpeChildMove(node, ucpe, instancesToUpdateInNonBlockingAction); - } else { - instancesToUpdateInNonBlockingAction.push(node.data().componentInstance); - } - - }); - - if (instancesToUpdateInNonBlockingAction.length > 0) { - this.GeneralGraphUtils.pushMultipleUpdateComponentInstancesRequestToQueue(false, instancesToUpdateInNonBlockingAction, component); - } - } else { - this.$log.debug(`composition-graph::notValidDrop:: node return to latest position`); - //reset nodes position - nodesMoved.positions((i, node) => { - return { - x: +node.data().componentInstance.posX, - y: +node.data().componentInstance.posY - }; - }) - } - - this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback(() => { - }, () => { - this.loaderService.hideLoader('composition-graph'); - }); - - }; - - /** - * Checks whether the node has been added or removed from UCPE and triggers appropriate events - * @param node - node moved - * @param ucpeContainer - UCPE container that the node has been moved to. When moving a node out of ucpe, param will be empty - * @param instancesToUpdateInNonBlockingAction - */ - public handleUcpeChildMove(node:Cy.CollectionFirstNode, ucpeContainer:Cy.CollectionElements, instancesToUpdateInNonBlockingAction:Array<Models.ComponentsInstances.ComponentInstance>){ - - if(node.data().isInsideGroup){ - if(ucpeContainer.length){ //moving node within UCPE. Simply update position - this.commonGraphUtils.updateUcpeChildPosition(<Cy.CollectionNodes>node, ucpeContainer); - instancesToUpdateInNonBlockingAction.push(node.data().componentInstance); - } else { //removing node from UCPE. Notify observers - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node, ucpeContainer); - } - } else if(!node.data().isInsideGroup && ucpeContainer.length && !node.data().isUcpePart){ //adding node to UCPE - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, node, ucpeContainer, true); - } - } - - } - - - CompositionGraphNodesUtils.$inject = ['NodesFactory', '$log', 'CompositionGraphGeneralUtils', 'CommonGraphUtils', 'EventListenerService', 'LoaderService']; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts deleted file mode 100644 index 5a401df317..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts +++ /dev/null @@ -1,265 +0,0 @@ -/** - * Created by obarda on 1/1/2017. - */ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils { - - export class MatchCapabilitiesRequirementsUtils { - - constructor() { - } - - - - public static linkable(requirement1:Models.Requirement, requirement2:Models.Requirement, vlCapability:Models.Capability):boolean { - return MatchCapabilitiesRequirementsUtils.isMatch(requirement1, vlCapability) && MatchCapabilitiesRequirementsUtils.isMatch(requirement2, vlCapability); - }; - - - /** - * Shows + icon in corner of each node passed in - * @param filteredNodesData - * @param cy - */ - public highlightMatchingComponents(filteredNodesData, cy:Cy.Instance) { - _.each(filteredNodesData, (data:any) => { - let node = cy.getElementById(data.id); - cy.emit('showhandle', [node]); - }); - } - - /** - * Adds opacity to each node that cannot be linked to hovered node - * @param filteredNodesData - * @param nodesData - * @param cy - * @param hoveredNodeData - */ - public fadeNonMachingComponents(filteredNodesData, nodesData, cy:Cy.Instance, hoveredNodeData?) { - let fadeNodes = _.xorWith(nodesData, filteredNodesData, (node1, node2) => { - return node1.id === node2.id; - }); - if (hoveredNodeData) { - _.remove(fadeNodes, hoveredNodeData); - } - cy.batch(()=> { - _.each(fadeNodes, (node) => { - cy.getElementById(node.id).style({'background-image-opacity': 0.4}); - }); - }) - } - - /** - * Resets all nodes to regular opacity - * @param cy - */ - public resetFadedNodes(cy:Cy.Instance) { - cy.batch(()=> { - cy.nodes().style({'background-image-opacity': 1}); - }) - } - - // -------------------------------------------ALL FUNCTIONS NEED REFACTORING---------------------------------------------------------------// - - private static requirementFulfilled(fromNodeId:string, requirement:any, links:Array<Models.CompositionCiLinkBase>):boolean { - return _.some(links, { - 'relation': { - 'fromNode': fromNodeId, - 'relationships': [{ - 'requirementOwnerId': requirement.ownerId, - 'requirement': requirement.name, - 'relationship': { - 'type': requirement.relationship - } - } - ] - } - }); - }; - - private static isMatch(requirement:Models.Requirement, capability:Models.Capability):boolean { - if (capability.type === requirement.capability) { - if (requirement.node) { - if (_.includes(capability.capabilitySources, requirement.node)) { - return true; - } - } else { - return true; - } - } - return false; - }; - - private getFromToMatches(requirements1:Models.RequirementsGroup, - requirements2:Models.RequirementsGroup, - capabilities:Models.CapabilitiesGroup, - links:Array<Models.CompositionCiLinkBase>, - fromId:string, - toId:string, - vlCapability?:Models.Capability):Array<Models.MatchBase> { - let matches:Array<Models.MatchBase> = new Array<Models.MatchBase>(); - _.forEach(requirements1, (requirementValue:Array<Models.Requirement>, key) => { - _.forEach(requirementValue, (requirement:Models.Requirement) => { - if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromId, requirement, links)) { - _.forEach(capabilities, (capabilityValue:Array<Models.Capability>, key) => { - _.forEach(capabilityValue, (capability:Models.Capability) => { - if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { - let match:Models.MatchReqToCapability = new Models.MatchReqToCapability(requirement, capability, true, fromId, toId); - matches.push(match); - } - }); - }); - if (vlCapability) { - _.forEach(requirements2, (requirement2Value:Array<Models.Requirement>, key) => { - _.forEach(requirement2Value, (requirement2:Models.Requirement) => { - if (!MatchCapabilitiesRequirementsUtils.requirementFulfilled(toId, requirement2, links) && MatchCapabilitiesRequirementsUtils.linkable(requirement, requirement2, vlCapability)) { - let match:Models.MatchReqToReq = new Models.MatchReqToReq(requirement, requirement2, true, fromId, toId); - matches.push(match); - } - }); - }); - } - } - }); - }); - return matches; - } - - private getToFromMatches(requirements:Models.RequirementsGroup, capabilities:Models.CapabilitiesGroup, links:Array<Models.CompositionCiLinkBase>, fromId:string, toId:string):Array<Models.MatchReqToCapability> { - let matches:Array<Models.MatchReqToCapability> = []; - _.forEach(requirements, (requirementValue:Array<Models.Requirement>, key) => { - _.forEach(requirementValue, (requirement:Models.Requirement) => { - if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(toId, requirement, links)) { - _.forEach(capabilities, (capabilityValue:Array<Models.Capability>, key) => { - _.forEach(capabilityValue, (capability:Models.Capability) => { - if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { - let match:Models.MatchReqToCapability = new Models.MatchReqToCapability(requirement, capability, false, toId, fromId); - matches.push(match); - } - }); - }); - } - }); - }); - return matches; - } - - public getMatchedRequirementsCapabilities(fromComponentInstance:Models.ComponentsInstances.ComponentInstance, - toComponentInstance:Models.ComponentsInstances.ComponentInstance, - links:Array<Models.CompositionCiLinkBase>, - vl?:Models.Components.Component):Array<Models.MatchBase> {//TODO allow for VL array - let linkCapability; - if (vl) { - let linkCapabilities:Array<Models.Capability> = vl.capabilities.findValueByKey('linkable'); - if (linkCapabilities) { - linkCapability = linkCapabilities[0]; - } - } - let fromToMatches:Array<Models.MatchBase> = this.getFromToMatches(fromComponentInstance.requirements, - toComponentInstance.requirements, - toComponentInstance.capabilities, - links, - fromComponentInstance.uniqueId, - toComponentInstance.uniqueId, - linkCapability); - let toFromMatches:Array<Models.MatchReqToCapability> = this.getToFromMatches(toComponentInstance.requirements, - fromComponentInstance.capabilities, - links, - fromComponentInstance.uniqueId, - toComponentInstance.uniqueId); - - return fromToMatches.concat(toFromMatches); - } - - - - - - /** - * Step I: Check if capabilities of component match requirements of nodeDataArray - * 1. Get component capabilities and loop on each capability - * 2. Inside the loop, perform another loop on all nodeDataArray, and fetch the requirements for each one - * 3. Loop on the requirements, and verify match (see in code the rules) - * - * Step II: Check if requirements of component match capabilities of nodeDataArray - * 1. Get component requirements and loop on each requirement - * 2. - * - * @param component - this is the hovered resource of the left panel of composition screen - * @param nodeDataArray - Array of resource instances that are on the canvas - * @param links -getMatchedRequirementsCapabilities - * @param vl - - * @returns {any[]|T[]} - */ - public findByMatchingCapabilitiesToRequirements(component:Models.Components.Component, - nodeDataArray:Array<Models.Graph.CompositionCiNodeBase>, - links:Array<Models.CompositionCiLinkBase>, - vl?:Models.Components.Component):Array<any> {//TODO allow for VL array - let res = []; - - // STEP I - { - let capabilities:any = component.capabilities; - _.forEach(capabilities, (capabilityValue:Array<any>, capabilityKey)=> { - _.forEach(capabilityValue, (capability)=> { - _.forEach(nodeDataArray, (node:Models.Graph.CompositionCiNodeBase)=> { - if (node && node.componentInstance) { - let requirements:any = node.componentInstance.requirements; - let fromNodeId:string = node.componentInstance.uniqueId; - _.forEach(requirements, (requirementValue:Array<any>, requirementKey)=> { - _.forEach(requirementValue, (requirement)=> { - if (requirement.name !== "dependency" && MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability) - && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromNodeId, requirement, links)) { - res.push(node); - } - }); - }); - } - }); - }); - }); - } - - // STEP II - { - let requirements:any = component.requirements; - let fromNodeId:string = component.uniqueId; - let linkCapability:Array<Models.Capability> = vl ? vl.capabilities.findValueByKey('linkable') : undefined; - - _.forEach(requirements, (requirementValue:Array<any>, requirementKey)=> { - _.forEach(requirementValue, (requirement)=> { - if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromNodeId, requirement, links)) { - _.forEach(nodeDataArray, (node:any)=> { - if (node && node.componentInstance && node.category !== 'groupCp') { - let capabilities:any = node.componentInstance.capabilities; - _.forEach(capabilities, (capabilityValue:Array<any>, capabilityKey)=> { - _.forEach(capabilityValue, (capability)=> { - if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { - res.push(node); - } - }); - }); - if (linkCapability) { - let linkRequirements = node.componentInstance.requirements; - _.forEach(linkRequirements, (value:Array<any>, key)=> { - _.forEach(value, (linkRequirement)=> { - if (!MatchCapabilitiesRequirementsUtils.requirementFulfilled(node.componentInstance.uniqueId, linkRequirement, links) - && MatchCapabilitiesRequirementsUtils.linkable(requirement, linkRequirement, linkCapability[0])) { - res.push(node); - } - }); - }); - } - } - }); - } - }); - }); - } - - return _.uniq(res); - }; - } - - MatchCapabilitiesRequirementsUtils.$inject = []; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts b/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts deleted file mode 100644 index d6d4aef374..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Created by obarda on 12/19/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - - import Util = jasmine.Util; - - interface IDeploymentGraphScope extends ng.IScope { - component:Models.Components.Component; - } - - export class DeploymentGraph implements ng.IDirective { - private _cy:Cy.Instance; - - constructor(private NodesFactory:Utils.NodesFactory, private commonGraphUtils:Graph.Utils.CommonGraphUtils, - private deploymentGraphGeneralUtils:Graph.Utils.DeploymentGraphGeneralUtils, private ComponentInstanceFactory: Sdc.Utils.ComponentInstanceFactory) { - } - - restrict = 'E'; - templateUrl = '/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.html'; - scope = { - component: '=', - isViewOnly: '=' - }; - - link = (scope:IDeploymentGraphScope, el:JQuery) => { - if(scope.component.isResource()) { - this.loadGraph(scope, el); - this.registerGraphEvents(); - } - }; - - - public initGraphNodes = (cy:Cy.Instance, component:Models.Components.Component):void => { - if (component.groups) { // Init module nodes - _.each(component.groups, (groupModule:Models.Module) => { - let moduleNode = this.NodesFactory.createModuleNode(groupModule); - this.commonGraphUtils.addNodeToGraph(cy, moduleNode); - - }); - } - _.each(component.componentInstances, (instance:Models.ComponentsInstances.ComponentInstance) => { // Init component instance nodes - let componentInstanceNode = this.NodesFactory.createNode(instance); - componentInstanceNode.parent = this.deploymentGraphGeneralUtils.findInstanceModule(component.groups, instance.uniqueId); - if (componentInstanceNode.parent) { // we are not drawing instances that are not a part of a module - this.commonGraphUtils.addComponentInstanceNodeToGraph(cy, componentInstanceNode); - } - }); - - // This is a special functionality to pass the cytoscape default behavior - we can't create Parent module node without children's - // so we must add an empty dummy child node - _.each(this._cy.nodes('[?isGroup]'), (moduleNode: Cy.CollectionFirstNode) => { - if (!moduleNode.isParent()) { - let dummyInstance = this.ComponentInstanceFactory.createEmptyComponentInstance(); - let componentInstanceNode = this.NodesFactory.createNode(dummyInstance); - componentInstanceNode.parent = moduleNode.id(); - let dummyNode = this.commonGraphUtils.addNodeToGraph(cy, componentInstanceNode, moduleNode.position()); - dummyNode.addClass('dummy-node'); - } - }) - }; - - private registerGraphEvents() { - - this._cy.on('afterExpand', (event) => { - event.cyTarget.qtip({}); - }); - - this._cy.on('afterCollapse', (event) => { - this.commonGraphUtils.initNodeTooltip(event.cyTarget); - }); - } - - private loadGraph = (scope:IDeploymentGraphScope, el:JQuery) => { - - let graphEl = el.find('.sdc-deployment-graph-wrapper'); - this._cy = cytoscape({ - container: graphEl, - style: Sdc.Graph.Utils.ComponentIntanceNodesStyle.getCompositionGraphStyle().concat(Sdc.Graph.Utils.ModulesNodesStyle.getModuleGraphStyle()), - zoomingEnabled: false, - selectionType: 'single', - - }); - - //adding expand collapse extension - this._cy.expandCollapse({ - layoutBy: { - name: "grid", - animate: true, - randomize: false, - fit: true - }, - fisheye: false, - undoable: false, - expandCollapseCueSize: 18, - expandCueImage: Sdc.Utils.Constants.IMAGE_PATH + '/styles/images/resource-icons/' + 'closeModule.png', - collapseCueImage: Sdc.Utils.Constants.IMAGE_PATH + '/styles/images/resource-icons/' + 'openModule.png', - expandCollapseCueSensitivity: 2, - cueOffset: -20 - }); - - this.initGraphNodes(this._cy, scope.component); //creating instances nodes - this.commonGraphUtils.initGraphLinks(this._cy, scope.component.componentInstancesRelations); - this._cy.collapseAll(); - }; - - public static factory = (NodesFactory:Utils.NodesFactory, CommonGraphUtils:Graph.Utils.CommonGraphUtils, DeploymentGraphGeneralUtils:Graph.Utils.DeploymentGraphGeneralUtils, ComponentInstanceFactory: Utils.ComponentInstanceFactory) => { - return new DeploymentGraph(NodesFactory, CommonGraphUtils, DeploymentGraphGeneralUtils, ComponentInstanceFactory) - } - } - - DeploymentGraph.factory.$inject = ['NodesFactory', 'CommonGraphUtils', 'DeploymentGraphGeneralUtils', 'ComponentInstanceFactory']; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts b/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts deleted file mode 100644 index 3ad9da56be..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Created by obarda on 12/21/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils { - - export class DeploymentGraphGeneralUtils { - - constructor() { - - } - - public findInstanceModule = (groupsArray:Array<Models.Module>, componentInstanceId:string):string => { - let parentGroup:Sdc.Models.Module = _.find(groupsArray, (group:Sdc.Models.Module) => { - return _.find(group.members, (member) => { - return member === componentInstanceId; - }); - }); - return parentGroup ? parentGroup.uniqueId : ""; - }; - } - - DeploymentGraphGeneralUtils.$inject = []; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/image-creator/image-creator.service.ts b/catalog-ui/app/scripts/directives/graphs-v2/image-creator/image-creator.service.ts deleted file mode 100644 index e3b17e163d..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/image-creator/image-creator.service.ts +++ /dev/null @@ -1,46 +0,0 @@ -module Sdc.Utils { - export class ImageCreatorService { - static '$inject' = ['$q']; - private _canvas: HTMLCanvasElement; - - constructor(private $q: ng.IQService) { - this._canvas = <HTMLCanvasElement>$('<canvas>')[0]; - this._canvas.setAttribute('style', 'display:none'); - - let body = document.getElementsByTagName('body')[0]; - body.appendChild(this._canvas); - } - - getImageBase64(imageBaseUri: string, imageLayerUri: string): ng.IPromise<string> { - let deferred = this.$q.defer(); - let imageBase = new Image(); - let imageLayer = new Image(); - let imagesLoaded = 0; - let onImageLoaded = () => { - imagesLoaded++; - - if (imagesLoaded < 2) { - return; - } - this._canvas.setAttribute('width', imageBase.width.toString()); - this._canvas.setAttribute('height', imageBase.height.toString()); - - let canvasCtx = this._canvas.getContext('2d'); - canvasCtx.clearRect(0, 0, this._canvas.width, this._canvas.height); - - canvasCtx.drawImage(imageBase, 0, 0, imageBase.width, imageBase.height); - canvasCtx.drawImage(imageLayer, imageBase.width - imageLayer.width, 0, imageLayer.width, imageLayer.height); - - let base64Image = this._canvas.toDataURL(); - deferred.resolve(base64Image); - }; - - imageBase.onload = onImageLoaded; - imageLayer.onload = onImageLoaded; - imageBase.src = imageBaseUri; - imageLayer.src = imageLayerUri; - - return deferred.promise; - } - } -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.directive.ts b/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.directive.ts deleted file mode 100644 index c00da6d1df..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.directive.ts +++ /dev/null @@ -1,327 +0,0 @@ -/// <reference path="../../../references"/> - -module Sdc.Directives { - import Dictionary = Sdc.Utils.Dictionary; - import GRAPH_EVENTS = Sdc.Utils.Constants.GRAPH_EVENTS; - import ImageCreatorService = Sdc.Utils.ImageCreatorService; - interface IPaletteScope { - components: any; - currentComponent: any; - model: any; - displaySortedCategories: any; - expandedSection: string; - - p2pVL: Models.Components.Component; - mp2mpVL: Models.Components.Component; - vlType: string; - dragElement: JQuery; - dragbleNode: { - event: JQueryEventObject, - components: Models.DisplayComponent, - ui: any - } - - sectionClick: (section: string)=>void; - searchComponents: (searchText: string)=>void; - onMouseOver: (displayComponent: Models.DisplayComponent)=>void; - onMouseOut: (displayComponent: Models.DisplayComponent)=>void; - dragStartCallback: (event: JQueryEventObject, ui, displayComponent: Models.DisplayComponent)=>void; - dragStopCallback: ()=>void; - onDragCallback: (event:JQueryEventObject) => void; - setElementTemplate: (e: JQueryEventObject)=>void; - - isOnDrag: boolean; - isDragable: boolean; - isLoading: boolean; - isViewOnly: boolean; - } - - export class Palette implements ng.IDirective { - constructor(private $log: ng.ILogService, - private LeftPaletteLoaderService, - private sdcConfig, - private ComponentFactory, - private ComponentInstanceFactory: Utils.ComponentInstanceFactory, - private NodesFactory: Utils.NodesFactory, - private CompositionGraphGeneralUtils: Graph.Utils.CompositionGraphGeneralUtils, - private EventListenerService: Services.EventListenerService, - private sdcMenu: Models.IAppMenu) { - - } - - private fetchingComponentFromServer: boolean = false; - private nodeHtmlSubstitute: JQuery; - - scope = { - components: '=', - currentComponent: '=', - isViewOnly: '=', - isLoading: '=' - }; - restrict = 'E'; - templateUrl = '/app/scripts/directives/graphs-v2/palette/palette.html'; - - link = (scope: IPaletteScope, el: JQuery) => { - this.nodeHtmlSubstitute = $('<div class="node-substitute"><span></span><img /></div>'); - el.append(this.nodeHtmlSubstitute); - - this.initComponents(scope); - this.initScopeVls(scope); - this.initEvents(scope); - this.initDragEvents(scope); - this._initExpandedSection(scope, ''); - }; - - private leftPanelResourceFilter(resourcesNotAbstract: Array<Models.DisplayComponent>, resourceFilterTypes: Array<string>): Array<Models.DisplayComponent> { - let filterResources = _.filter(resourcesNotAbstract, (component) => { - return resourceFilterTypes.indexOf(component.getComponentSubType()) > -1; - }); - return filterResources; - } - - private initLeftPanel(leftPanelComponents: Array<Models.DisplayComponent>, resourceFilterTypes: Array<string>): Models.LeftPanelModel { - let leftPanelModel = new Models.LeftPanelModel(); - - if (resourceFilterTypes && resourceFilterTypes.length) { - leftPanelComponents = this.leftPanelResourceFilter(leftPanelComponents, resourceFilterTypes); - } - leftPanelModel.numberOfElements = leftPanelComponents && leftPanelComponents.length || 0; - - if (leftPanelComponents && leftPanelComponents.length) { - - let categories: any = _.groupBy(leftPanelComponents, 'mainCategory'); - for (let category in categories) - categories[category] = _.groupBy(categories[category], 'subCategory'); - - leftPanelModel.sortedCategories = categories; - } - return leftPanelModel; - } - - private initScopeVls(scope: IPaletteScope): void { - let vls = this.LeftPaletteLoaderService.getFullDataComponentList(Utils.Constants.ResourceType.VL); - scope.vlType = null; - vls.forEach((item) => { - let key = _.find(Object.keys(item.capabilities), (key) => { - return _.includes(key.toLowerCase(), 'linkable'); - }); - let linkable = item.capabilities[key]; - if (linkable) { - if (linkable[0].maxOccurrences == '2') { - scope.p2pVL = _.find(vls, (component: Models.Components.Component) => { - return component.uniqueId === item.uniqueId; - }); - - } else {//assuming unbounded occurrences - scope.mp2mpVL = _.find(vls, (component: Models.Components.Component) => { - return component.uniqueId === item.uniqueId; - }); - } - } - }); - }; - - private initEvents(scope: IPaletteScope) { - /** - * - * @param section - */ - scope.sectionClick = (section: string) => { - if (section === scope.expandedSection) { - scope.expandedSection = ''; - return; - } - scope.expandedSection = section; - }; - - scope.onMouseOver = (displayComponent: Models.DisplayComponent) => { - if (scope.isOnDrag) { - return; - } - scope.isOnDrag = true; - - this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, displayComponent); - this.$log.debug('palette::onMouseOver:: fired'); - - if (this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.containsKey(displayComponent.uniqueId)) { - this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} found in cache`); - let cacheComponent: Models.Components.Component = this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.getValue(displayComponent.uniqueId); - - //TODO: Danny: fire event to highlight matching nodes - //showMatchingNodes(cacheComponent); - return; - } - - this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} not found in cache, initiating server get`); - // This will bring the component from the server including requirements and capabilities - // Check that we do not fetch many times, because only in the success we add the component to componentRequirementsAndCapabilitiesCaching - if (this.fetchingComponentFromServer) { - return; - } - - this.fetchingComponentFromServer = true; - this.ComponentFactory.getComponentFromServer(displayComponent.componentSubType, displayComponent.uniqueId) - .then((component: Models.Components.Component) => { - this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} fetch success`); - this.LeftPaletteLoaderService.updateSpecificComponentLeftPalette(component, scope.currentComponent.componentType); - this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.setValue(component.uniqueId, component); - this.fetchingComponentFromServer = false; - - //TODO: Danny: fire event to highlight matching nodes - //showMatchingNodes(component); - }) - .catch(() => { - this.$log.debug('palette::onMouseOver:: component id fetch error'); - this.fetchingComponentFromServer = false; - }); - - - }; - - scope.onMouseOut = () => { - scope.isOnDrag = false; - this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT); - } - } - - private initComponents(scope: IPaletteScope) { - scope.searchComponents = (searchText: any): void => { - scope.displaySortedCategories = this._searchComponents(searchText, scope.model.sortedCategories); - this._initExpandedSection(scope, searchText); - }; - - scope.isDragable = scope.currentComponent.isComplex(); - let entityType: string = scope.currentComponent.componentType.toLowerCase(); - let resourceFilterTypes: Array<string> = this.sdcConfig.resourceTypesFilter[entityType]; - - scope.components = this.LeftPaletteLoaderService.getLeftPanelComponentsForDisplay(scope.currentComponent.componentType); - scope.model = this.initLeftPanel(scope.components, resourceFilterTypes); - scope.displaySortedCategories = angular.copy(scope.model.sortedCategories); - } - - private _initExpandedSection(scope: IPaletteScope, searchText: string): void { - if (searchText == '') { - let isContainingCategory: boolean = false; - let categoryToExpand: string; - if (scope.currentComponent && scope.currentComponent.categories && scope.currentComponent.categories[0]) { - categoryToExpand = this.sdcMenu.categoriesDictionary[scope.currentComponent.categories[0].name]; - for (let category in scope.model.sortedCategories) { - if (categoryToExpand == category) { - isContainingCategory = true; - break; - } - } - } - isContainingCategory ? scope.expandedSection = categoryToExpand : scope.expandedSection = 'Generic'; - } - else { - scope.expandedSection = Object.keys(scope.displaySortedCategories).sort()[0]; - } - }; - - private initDragEvents(scope: IPaletteScope) { - scope.dragStartCallback = (event: IDragDropEvent, ui, displayComponent: Models.DisplayComponent): void => { - if (scope.isLoading || !scope.isDragable || scope.isViewOnly) { - return; - } - - let component = _.find(this.LeftPaletteLoaderService.getFullDataComponentListWithVls(scope.currentComponent.componentType), (componentFullData: Models.DisplayComponent) => { - return displayComponent.uniqueId === componentFullData.uniqueId; - }); - this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_START, scope.dragElement, component); - - scope.isOnDrag = true; - - - - // this.graphUtils.showMatchingNodes(component, myDiagram, scope.sdcConfig.imagesPath); - // document.addEventListener('mousemove', moveOnDocument); - event.dataTransfer.component = component; - }; - - scope.dragStopCallback = () => { - scope.isOnDrag = false; - }; - - scope.onDragCallback = (event:IDragDropEvent): void => { - this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_ACTION, event); - }; - scope.setElementTemplate = (e) => { - let dragComponent: Models.Components.Component = _.find(this.LeftPaletteLoaderService.getFullDataComponentListWithVls(scope.currentComponent.componentType), - (fullComponent: Models.Components.Component) => { - return (<any>angular.element(e.currentTarget).scope()).component.uniqueId === fullComponent.uniqueId; - }); - let componentInstance: Models.ComponentsInstances.ComponentInstance = this.ComponentInstanceFactory.createComponentInstanceFromComponent(dragComponent); - let node: Models.Graph.CompositionCiNodeBase = this.NodesFactory.createNode(componentInstance); - - // myDiagram.dragFromPalette = node; - this.nodeHtmlSubstitute.find("img").attr('src', node.img); - scope.dragElement = this.nodeHtmlSubstitute.clone().show(); - - return scope.dragElement; - }; - } - - private _searchComponents = (searchText: string, categories: any): void => { - let displaySortedCategories = angular.copy(categories); - if (searchText != '') { - angular.forEach(categories, function (category: any, categoryKey) { - - angular.forEach(category, function (subcategory: Array<Models.DisplayComponent>, subcategoryKey) { - let filteredResources = []; - angular.forEach(subcategory, function (component: Models.DisplayComponent) { - - let resourceFilterTerm: string = component.searchFilterTerms; - if (resourceFilterTerm.indexOf(searchText.toLowerCase()) >= 0) { - filteredResources.push(component); - } - }); - if (filteredResources.length > 0) { - displaySortedCategories[categoryKey][subcategoryKey] = filteredResources; - } - else { - delete displaySortedCategories[categoryKey][subcategoryKey]; - } - }); - if (!(Object.keys(displaySortedCategories[categoryKey]).length > 0)) { - delete displaySortedCategories[categoryKey]; - } - - }); - } - return displaySortedCategories; - }; - - public static factory = ($log, - LeftPaletteLoaderService, - sdcConfig, - ComponentFactory, - ComponentInstanceFactory, - NodesFactory, - CompositionGraphGeneralUtils, - EventListenerService, - sdcMenu) => { - return new Palette($log, - LeftPaletteLoaderService, - sdcConfig, - ComponentFactory, - ComponentInstanceFactory, - NodesFactory, - CompositionGraphGeneralUtils, - EventListenerService, - sdcMenu); - }; - } - - Palette.factory.$inject = [ - '$log', - 'LeftPaletteLoaderService', - 'sdcConfig', - 'ComponentFactory', - 'ComponentInstanceFactory', - 'NodesFactory', - 'CompositionGraphGeneralUtils', - 'EventListenerService', - 'sdcMenu' - ]; -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.ts b/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.ts deleted file mode 100644 index 22a2d078b7..0000000000 --- a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.ts +++ /dev/null @@ -1,113 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - - export interface IRelationMenuScope extends ng.IScope { - relationMenuDirectiveObj:Models.RelationMenuDirectiveObj; - createRelation:Function; - isLinkMenuOpen:boolean; - hideRelationMatch:Function; - cancel:Function; - - saveRelation(); - showMatch(arr1:Array<Models.MatchBase>, arr2:Array<Models.MatchBase>):boolean; - hasMatchesToShow(matchesObj:Models.MatchBase, selectedMatch:Array<Models.MatchBase>); - updateSelectionText():void; - - } - - - export class RelationMenuDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService - ) { - } - - scope = { - relationMenuDirectiveObj: '=', - isLinkMenuOpen: '=', - createRelation: '&', - cancel:'&' - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/graphs-v2/relation-menu/relation-menu.html'); - }; - - link = (scope:IRelationMenuScope, element:JQuery, $attr:ng.IAttributes) => { - - scope.saveRelation = ():void=> { - let chosenMatches:Array<any> = _.intersection(scope.relationMenuDirectiveObj.rightSideLink.selectedMatch, scope.relationMenuDirectiveObj.leftSideLink.selectedMatch); - let chosenMatch:Models.MatchBase = chosenMatches[0]; - let chosenVL:Models.Components.Component; - if ("mptmp" === scope.relationMenuDirectiveObj.vlType) { - chosenVL = scope.relationMenuDirectiveObj.mp2mpVL; - } else { - chosenVL = scope.relationMenuDirectiveObj.p2pVL; - } - scope.createRelation()(chosenMatch,chosenVL); - }; - - - scope.hideRelationMatch = () => { - scope.isLinkMenuOpen = false; - scope.cancel(); - }; - - //to show options in link menu - scope.showMatch = (arr1:Array<Models.MatchBase>, arr2:Array<Models.MatchBase>):boolean => { - return !arr1 || !arr2 || _.intersection(arr1, arr2).length > 0; - }; - - //to show requirements/capabilities title - scope.hasMatchesToShow = (matchesObj:Models.MatchBase, selectedMatch:Array<Models.MatchBase>):boolean => { - let result:boolean = false; - _.forEach(matchesObj, (matchesArr:Array<Models.MatchBase>) => { - if (!result) { - result = scope.showMatch(matchesArr, selectedMatch); - } - }); - return result; - }; - - - scope.updateSelectionText = ():void => { - let left:string = scope.relationMenuDirectiveObj.leftSideLink.selectedMatch ? this.$filter('resourceName')(scope.relationMenuDirectiveObj.leftSideLink.selectedMatch[0].getDisplayText('left')) : ''; - let both:string = scope.relationMenuDirectiveObj.leftSideLink.selectedMatch && scope.relationMenuDirectiveObj.rightSideLink.selectedMatch ? ' - ' + - this.$filter('resourceName')(scope.relationMenuDirectiveObj.leftSideLink.selectedMatch[0].requirement.relationship) + ' - ' : ''; - let right:string = scope.relationMenuDirectiveObj.rightSideLink.selectedMatch ? this.$filter('resourceName')(scope.relationMenuDirectiveObj.rightSideLink.selectedMatch[0].getDisplayText('right')) : ''; - scope.relationMenuDirectiveObj.selectionText = left + both + right; - }; - - - } - public static factory = ($templateCache:ng.ITemplateCacheService , $filter:ng.IFilterService)=> { - return new RelationMenuDirective($templateCache, $filter); - }; - } - - RelationMenuDirective.factory.$inject = ['$templateCache', '$filter']; -} diff --git a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.ts b/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.ts deleted file mode 100644 index cd81b14ce8..0000000000 --- a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.ts +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/25/2016. - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface IInfoTooltipScope extends ng.IScope { - infoMessageTranslate:string; - direction:string; - } - - - export class InfoTooltipDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - infoMessageTranslate:'@', - direction:'@'//get 'right' or 'left', the default is 'right' - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/info-tooltip/info-tooltip.html'); - }; - - link = (scope:IInfoTooltipScope, element:any, $attr:any) => { - scope.direction = scope.direction || 'right'; - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new InfoTooltipDirective($templateCache); - }; - - } - - InfoTooltipDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/invalid-characters/invalid-characters.ts b/catalog-ui/app/scripts/directives/invalid-characters/invalid-characters.ts deleted file mode 100644 index 7ab98b0d23..0000000000 --- a/catalog-ui/app/scripts/directives/invalid-characters/invalid-characters.ts +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class InvalidCharactersDirective implements ng.IDirective { - - constructor() {} - - require = 'ngModel'; - - link = (scope, elem, attrs, ngModel) => { - - let invalidCharacters = []; - - attrs.$observe('invalidCharacters', (val:string) => { - invalidCharacters = val.split(''); - validate(ngModel.$viewValue); - }); - - let validate: Function = function (value) { - - let valid:boolean = true; - - if(value) { - for (let i = 0; i < invalidCharacters.length; i++) { - if (value.indexOf(invalidCharacters[i]) != - 1) { - valid = false; - } - } - } - - ngModel.$setValidity('invalidCharacters', valid); - if(!value) { - ngModel.$setPristine(); - } - return value; - }; - - //For DOM -> model validation - ngModel.$parsers.unshift(validate); - //For model -> DOM validation - ngModel.$formatters.unshift(validate); - - }; - - public static factory = ()=> { - return new InvalidCharactersDirective(); - }; - - } - - InvalidCharactersDirective.factory.$inject = []; -} diff --git a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.ts b/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.ts deleted file mode 100644 index 356e43b7f7..0000000000 --- a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.ts +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ITopNavScope extends ng.IScope { - topLvlSelectedIndex: number; - hideSearch: boolean; - searchBind: any; - menuModel: Array<Utils.MenuItemGroup>; - - topLvlMenu: Utils.MenuItemGroup; - goToState(state:string, params:Array<any>):ng.IPromise<boolean>; - menuItemClick: Function; - user: Models.IUserProperties; - version:string; - } - - - export class TopNavDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService, - private $state:ng.ui.IStateService, - private $q: ng.IQService, - private userResourceService: Sdc.Services.IUserResourceClass - ) { - } - - public replace = true; - public restrict = 'E'; - public transclude = false; - - - scope = { - topLvlSelectedIndex: '@?', - hideSearch: '=', - searchBind: '=', - version: '@', - notificationIconCallback: '=', - menuModel: '=?', - }; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/layout/top-nav/top-nav.html'); - }; - - public link = (scope:ITopNavScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { - - let getTopLvlSelectedIndexByState = ():number => { - if (!scope.topLvlMenu.menuItems) { - return 0; - } - - let result = -1; - - //set result to current state - scope.topLvlMenu.menuItems.forEach((item:Utils.MenuItem, index:number)=> { - if (item.state === this.$state.current.name) { - result = index; - } - }); - - //if it's a different state , checking previous state param - if (result === -1) { - scope.topLvlMenu.menuItems.forEach((item:Utils.MenuItem, index:number)=> { - if (item.state === this.$state.params['previousState']) { - result = index; - } - }); - } - - if (result === -1) { - result = 0; - } - - return result; - }; - - scope.user = this.userResourceService.getLoggedinUser(); - - let tmpArray:Array<Utils.MenuItem> = [ - new Utils.MenuItem(this.$filter('translate')("TOP_MENU_HOME_BUTTON"), null, "dashboard", "goToState", null, null), - new Utils.MenuItem(this.$filter('translate')("TOP_MENU_CATALOG_BUTTON"), null, "catalog", "goToState", null, null) - ]; - - // Only designer can perform onboarding - if (scope.user && scope.user.role === 'DESIGNER'){ - tmpArray.push(new Utils.MenuItem(this.$filter('translate')("TOP_MENU_ON_BOARD_BUTTON"), null, "onboardVendor", "goToState", null, null)); - } - - scope.topLvlMenu = new Utils.MenuItemGroup(0, tmpArray , true ); - scope.topLvlMenu.selectedIndex = isNaN(scope.topLvlSelectedIndex) ? getTopLvlSelectedIndexByState() : scope.topLvlSelectedIndex; - - let generateMenu = () => { - if (scope.menuModel && scope.menuModel[0] !== scope.topLvlMenu) { - scope.menuModel.unshift(scope.topLvlMenu); - } - }; - scope.$watch('menuModel', generateMenu); - - generateMenu(); - - /////scope functions//// - - scope.goToState = (state:string, params:Array<any>):ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - this.$state.go(state, params && params.length > 0 ? [0] : undefined); - deferred.resolve(true); - return deferred.promise; - }; - - scope.menuItemClick = (itemGroup:Utils.MenuItemGroup, item:Utils.MenuItem) => { - - itemGroup.itemClick = false; - - let onSuccess = ():void => { - itemGroup.selectedIndex = itemGroup.menuItems.indexOf(item); - }; - let onFailed = ():void => {}; - - if (item.callback) { - (item.callback.apply(undefined, item.params)).then(onSuccess, onFailed); - } else { - scope[item.action](item.state, item.params).then(onSuccess, onFailed); - } - }; - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $filter:ng.IFilterService, $state:ng.ui.IStateService, $q: ng.IQService, userResourceService: Sdc.Services.IUserResourceClass)=> { - return new TopNavDirective($templateCache, $filter, $state,$q, userResourceService); - }; - - } - - TopNavDirective.factory.$inject = ['$templateCache', '$filter', '$state','$q', 'Sdc.Services.UserResourceService']; -} diff --git a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.ts b/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.ts deleted file mode 100644 index 8e8a289281..0000000000 --- a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.ts +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ITopProgressScope extends ng.IScope { - progressValue:number; - progressMessage:string; - } - - export class TopProgressDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) {} - - public replace = true; - public restrict = 'E'; - public transclude = false; - - scope = { - progressValue: '=', - progressMessage: '=' - }; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/layout/top-progress/top-progress.html'); - }; - - public link = (scope:ITopProgressScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new TopProgressDirective($templateCache); - }; - - } - - TopProgressDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/loader/loader-directive.ts b/catalog-ui/app/scripts/directives/loader/loader-directive.ts deleted file mode 100644 index 77c8977ac5..0000000000 --- a/catalog-ui/app/scripts/directives/loader/loader-directive.ts +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - export interface ILoaderScope extends ng.IScope { - display: boolean; // Toggle show || hide scroll - size: string; // small || medium || large - elementSelector: string; // Jquery selector to hide and scroll inside - relative: boolean; // Will use the parent of <loader> element and hide it and scroll inside - loaderType: string; - } - - export class LoaderDirective implements ng.IDirective { - - constructor(private $templateCache: ng.ITemplateCacheService, private EventListenerService: Services.EventListenerService) { - } - - /* - * relative is used when inserting the HTML loader inside some div <loader data-display="isLoading" relative="true"></loader> - * elementSelector when we want to pass the Jquery selector of the loader. - */ - scope = { - display: '=', - size: '@?', - elementSelector: '@?', - relative: '=?', - loaderType: '@?' - }; - - public replace = false; - public restrict = 'E'; - template = (): string => { - return this.$templateCache.get('/app/scripts/directives/loader/loader-directive.html'); - }; - - link = (scope: ILoaderScope, element: any) => { - - let interval; - - this.EventListenerService.registerObserverCallback(Utils.Constants.EVENTS.SHOW_LOADER_EVENT, (loaderType)=> { - if (scope.loaderType !== loaderType) { - return; - } - scope.display = true; - }); - this.EventListenerService.registerObserverCallback(Utils.Constants.EVENTS.HIDE_LOADER_EVENT, (loaderType)=> { - if (scope.loaderType !== loaderType) { - return; - } - scope.display = false; - }); - - let calculateSizesForFixPosition = (positionStyle: string): void => { - // This is problematic, I do not want to change the parent position. - // set the loader on all the screen - let parentPosition = element.parent().position(); - let parentWidth = element.parent().width(); - let parentHeight = element.parent().height(); - element.css('position', positionStyle); - element.css('top', parentPosition.top); - element.css('left', parentPosition.left); - element.css('width', parentWidth); - element.css('height', parentHeight); - }; - - let setStyle = (positionStyle: string): void => { - - switch (positionStyle) { - case 'absolute': - case 'fixed': - // The parent size is not set yet, still loading, so need to use interval to update the size. - interval = window.setInterval(()=> { - calculateSizesForFixPosition(positionStyle); - }, 2000); - break; - default: - // Can change the parent position to relative without causing style issues. - element.parent().css('position', 'relative'); - break; - } - }; - - // This should be executed after the dom loaded - window.setTimeout((): void => { - - element.css('display', 'none'); - - if (scope.elementSelector) { - let elemParent = angular.element(scope.elementSelector); - let positionStyle: string = elemParent.css('position'); - setStyle(positionStyle); - } - - if (scope.relative === true) { - let positionStyle: string = element.parent().css('position'); - setStyle(positionStyle); - } - - if (!scope.size) { - scope.size = 'large'; - } - - }, 0); - - if (scope.elementSelector) { - - } - - function cleanUp() { - clearInterval(interval); - } - - scope.$watch("display", (newVal, oldVal) => { - element.css('display', 'none'); - if (newVal === true) { - window.setTimeout((): void => { - element.css('display', 'block'); - }, 500); - } else { - window.setTimeout((): void => { - element.css('display', 'none'); - }, 0); - } - }); - - scope.$on('$destroy', cleanUp); - - }; - - public static factory = ($templateCache: ng.ITemplateCacheService, EventListenerService: Services.EventListenerService)=> { - return new LoaderDirective($templateCache, EventListenerService); - }; - - } - - LoaderDirective.factory.$inject = ['$templateCache', 'EventListenerService']; -} diff --git a/catalog-ui/app/scripts/directives/modal/sdc-modal.ts b/catalog-ui/app/scripts/directives/modal/sdc-modal.ts deleted file mode 100644 index 338035c9f1..0000000000 --- a/catalog-ui/app/scripts/directives/modal/sdc-modal.ts +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISdcModalScope extends ng.IScope { - modal:ng.ui.bootstrap.IModalServiceInstance; - hideBackground:string; - ok():void; - close(result:any):void; - cancel(reason:any):void; - } - - export interface ISdcModalButton { - name:string; - css:string; - disabled?:boolean; - callback:Function; - } - - export class SdcModalDirective implements ng.IDirective { - - constructor( - private $templateCache: ng.ITemplateCacheService - ) {} - - scope = { - modal: '=', - type: '@', - header: '@', - headerTranslate: '@', - headerTranslateValues: '@', - showCloseButton: '@', - hideBackground: '@', - buttons: '=', - getCloseModalResponse: '=' - }; - - public replace = true; - public restrict = 'E'; - public transclude = true; - - template = (): string => { - return this.$templateCache.get('/app/scripts/directives/modal/sdc-modal.html'); - }; - - link = (scope:ISdcModalScope, $elem:any) => { - - if (scope.hideBackground==="true"){ - $(".modal-backdrop").css('opacity','0'); - } - - scope.close = function (result:any) { - scope.modal.close(result); - }; - - scope.ok = function () { - scope.modal.close(); - }; - - scope.cancel = function (reason:any) { - if(this.getCloseModalResponse) - scope.modal.dismiss(this.getCloseModalResponse()); - else { - scope.modal.dismiss(); - } - }; - - if (scope.modal) { - scope.modal.result.then(function (selectedItem) { - //$scope.selected = selectedItem; - }, function () { - //console.info('Modal dismissed at: ' + new Date()); - }); - } - } - - public static factory = ($templateCache: ng.ITemplateCacheService)=> { - return new SdcModalDirective($templateCache); - }; - - } - - SdcModalDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.html b/catalog-ui/app/scripts/directives/page-scroller/page-scroller.html deleted file mode 100644 index 7359386901..0000000000 --- a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.html +++ /dev/null @@ -1,22 +0,0 @@ -<div class="sdc-page-scroller"> - - <nav data-ng-if="showNav!==false" class="welcome-nav"> - <div data-ng-if="showCloseButton===true" data-ng-click="onCloseButtonClick()" class="asdc-welcome-close"></div> - <ul> - <li data-ng-repeat="slide in slidesData | orderBy:'+position'"><a href="#{{slide.id}}" data-ng-click="onNavButtonClick(slide)" class=""></a></li> - </ul> - </nav> - - <div class="nav-previous-next" data-ng-if="showPreviousNext===true"> - <span class="go-prev" data-ng-click="goToPrevSlide()">previous slide</span> - <span class="go-next" data-ng-click="goToNextSlide()">next slide</span> - </div> - - <div class="slides-container"> - <section data-ng-repeat="slide in slidesData | orderBy:'+position'" class="slide" id="{{slide.id}}" on-last-repeat> - <ng-include src="slide.url"></ng-include> - </section> - </div> - -</div> - diff --git a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.less b/catalog-ui/app/scripts/directives/page-scroller/page-scroller.less deleted file mode 100644 index 14f8568f07..0000000000 --- a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.less +++ /dev/null @@ -1,98 +0,0 @@ -.sdc-page-scroller { - - /****************** Navigation ***************/ - nav { - position: fixed; - top: 0; - right: 0; - z-index: 100; - display: flex; - flex-direction: column; - width: 100px; - bottom: 0; - background-color: #000; - align-items: center; - justify-content: center; - } - - nav ul { - list-style: none; - text-align: center; - margin-top: 0; - padding: 0; - } - - nav ul li { - display: block; - margin-bottom: 15px; - - } - - nav ul li:last-child { - - } - - nav a { - display: block; - height: 6px; - width: 6px; - border-radius: 50%; - background-color: #4a4c4d; - } - - nav a.active { - position: relative; - } - - nav a.active::after { - content: ''; - display: block; - position: absolute; - border: 2px solid #0198d1; - width: 16px; - height: 16px; - border-radius: 50%; - top: -5px; - left: -5px; - } - - /****************** Previous Next navigation ***************/ - .go-prev, .go-next { - cursor: pointer; - font-weight: bold; - text-decoration: underline; - } - - .slides-container { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - overflow-y: hidden; - z-index: 10; - } - - .slide { - position: relative; - width: 100%; - height: 100%; - overflow: hidden; - } - - .slide .centered { - width: 60%; - margin: 200px auto 0; - } - - .slide .centered h1 { - text-align: center; - } - - .slide .centered p { - text-align: center; - margin-top: 20px; - font-size: 20px; - } - -} diff --git a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.ts b/catalog-ui/app/scripts/directives/page-scroller/page-scroller.ts deleted file mode 100644 index bb89f9a55a..0000000000 --- a/catalog-ui/app/scripts/directives/page-scroller/page-scroller.ts +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface SlideData { - url: string; - id: string; - index: number; - callback: Function; - } - - export interface ISdcPageScrollDirectiveScope extends ng.IScope { - slidesData:Array<SlideData>; - showNav: boolean; - showPreviousNext: boolean; - currentSlide:SlideData; - showCloseButton:boolean; - closeButtonCallback:Function; - startSlideIndex:number; - - onNavButtonClick(slideName):void; - onCloseButtonClick():void; - goToPrevSlide():void; - goToNextSlide():void; - goToSlide(slide:SlideData):void; - onSlideChangeEnd():void; - onMouseWheel(event):void; - onKeyDown(event):void; - onResize(event):void; - gotoSlideIndex(index):void; - } - - export class SdcPageScrollDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - - } - - scope = { - slidesData: '=', - showNav: '=', - showPreviousNext: '=', - showCloseButton: '=', - closeButtonCallback: '=', - startSlideIndex: '=?' - }; - - public replace = true; - public restrict = 'E'; - private delayExec:any; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/page-scroller/page-scroller.html'); - }; - - link = ($scope:ISdcPageScrollDirectiveScope, $elem:JQuery, attr:any) => { - let isAnimating = false; //Animating flag - is our app animating - let pageHeight = $(window).innerHeight(); //The height of the window - let slidesContainer; - let navButtons; - let slides:any; //Only graph-links that starts with - - //Key codes for up and down arrows on keyboard. We'll be using this to navigate change slides using the keyboard - let keyCodes = { - UP : 38, - DOWN: 40 - }; - - $scope.onCloseButtonClick = ():void => { - if ($scope.closeButtonCallback){ - $scope.closeButtonCallback(); - }; - }; - - // Wait for the dom to load (after ngRepeat). - $scope.$on('onRepeatLast', (scope, element, attrs) => { - slides = $(".slide", slidesContainer); - slidesContainer = $(".slides-container"); - navButtons = $("nav a").filter("[href^='#']"); - - // Adding event listeners - $(window).on("resize", (e) => {$scope.onResize(e);}).resize(); - $(window).on("mousewheel DOMMouseScroll", (e) => {$scope.onMouseWheel(e);}); - $(document).on("keydown", (e) => {$scope.onKeyDown(e);}); - - //Going to the first slide - if ($scope.startSlideIndex){ - $scope.gotoSlideIndex($scope.startSlideIndex); - } else { - $scope.gotoSlideIndex(0); - } - - }); - - $scope.gotoSlideIndex = (index) => { - $scope.goToSlide($scope.slidesData[index]); - }; - - // When a button is clicked - first get the button href, and then slide to the container, if there's such a container - $scope.onNavButtonClick = (slide:SlideData):void => { - $scope.goToSlide(slide); - }; - - // If there's a previous slide, slide to it - $scope.goToPrevSlide = ():void => { - let previousSlide = $scope.slidesData[$scope.currentSlide.index-1]; - if (previousSlide) { - $scope.goToSlide(previousSlide); - } - }; - - // If there's a next slide, slide to it - $scope.goToNextSlide = ():void => { - let nextSlide = $scope.slidesData[$scope.currentSlide.index+1]; - if (nextSlide) { - $scope.goToSlide(nextSlide); - } - }; - - // Actual transition between slides - $scope.goToSlide = (slide:SlideData):void => { - //console.log("start goToSlide"); - //If the slides are not changing and there's such a slide - if(!isAnimating && slide) { - //setting animating flag to true - isAnimating = true; - $scope.currentSlide = slide; - $scope.currentSlide.callback(); - - //Sliding to current slide - let calculatedY = pageHeight * ($scope.currentSlide.index); - //console.log("$scope.currentSlide.index: " + $scope.currentSlide.index + " | calculatedY: " + calculatedY); - - $('.slides-container').animate( - { - scrollTop: calculatedY + 'px' - }, - { - duration: 1000, - specialEasing: { - width: "linear", - height: "easeInOutQuart" - }, - complete: function() { - $scope.onSlideChangeEnd(); - } - } - ); - - //Animating menu items - $(".sdc-page-scroller nav a.active").removeClass("active"); - $(".sdc-page-scroller nav [href='#" + $scope.currentSlide.id + "']").addClass("active"); - } - }; - - // Once the sliding is finished, we need to restore "isAnimating" flag. - // You can also do other things in this function, such as changing page title - $scope.onSlideChangeEnd = ():void => { - - - - isAnimating = false; - }; - - // When user scrolls with the mouse, we have to change slides - $scope.onMouseWheel = (event):void => { - //Normalize event wheel delta - let delta = event.originalEvent.wheelDelta / 30 || -event.originalEvent.detail; - - //If the user scrolled up, it goes to previous slide, otherwise - to next slide - if(delta < -1) { - this.delayAction($scope.goToNextSlide); - } else if(delta > 1) { - this.delayAction($scope.goToPrevSlide); - } - event.preventDefault(); - }; - - // Getting the pressed key. Only if it's up or down arrow, we go to prev or next slide and prevent default behaviour - // This way, if there's text input, the user is still able to fill it - $scope.onKeyDown = (event):void => { - let PRESSED_KEY = event.keyCode; - - if(PRESSED_KEY == keyCodes.UP){ - $scope.goToPrevSlide(); - event.preventDefault(); - } else if(PRESSED_KEY == keyCodes.DOWN){ - $scope.goToNextSlide(); - event.preventDefault(); - } - }; - - // When user resize it's browser we need to know the new height, so we can properly align the current slide - $scope.onResize = (event):void => { - //This will give us the new height of the window - let newPageHeight = $(window).innerHeight(); - - // If the new height is different from the old height ( the browser is resized vertically ), the slides are resized - if(pageHeight !== newPageHeight) { - pageHeight = newPageHeight; - } - }; - }; - - private initSlides = ():void => { - //pageHeight - }; - - private delayAction = (action:Function):void => { - clearTimeout(this.delayExec); - this.delayExec = setTimeout(function () { - action(); - }, 100); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcPageScrollDirective($templateCache); - }; - - } - - SdcPageScrollDirective.factory.$inject = ['$templateCache']; - -} - - - - diff --git a/catalog-ui/app/scripts/directives/perfect-scrollbar/angular-perfect-scrollbar.ts b/catalog-ui/app/scripts/directives/perfect-scrollbar/angular-perfect-scrollbar.ts deleted file mode 100644 index b53a059a40..0000000000 --- a/catalog-ui/app/scripts/directives/perfect-scrollbar/angular-perfect-scrollbar.ts +++ /dev/null @@ -1,159 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - - 'use strict'; - - export interface IPerfectScrollerScope extends ng.IScope { - //update(event:string): void; - } - - export class PerfectScrollerDirective implements ng.IDirective { - - constructor( - private $templateCache: ng.ITemplateCacheService, - private $parse:any, - private $window:any) { - - } - - replace = true; - restrict = 'EA'; - transclude = true; - - template = (): string => { - return '<div><div ng-transclude></div></div>'; - }; - - link = ($scope:IPerfectScrollerScope, $elem, $attr) => { - let self = this; - let options = {}; - - let psOptions = [ - 'wheelSpeed', 'wheelPropagation', 'minScrollbarLength', 'useBothWheelAxes', - 'useKeyboard', 'suppressScrollX', 'suppressScrollY', 'scrollXMarginOffset', - 'scrollYMarginOffset', 'includePadding'//, 'onScroll', 'scrollDown' - ]; - - for (let i=0, l=psOptions.length; i<l; i++) { - let opt = psOptions[i]; - if ($attr[opt] !== undefined) { - options[opt] = self.$parse($attr[opt])(); - } - } - - $scope.$evalAsync(function() { - $elem.perfectScrollbar(options); - let onScrollHandler = self.$parse($attr.onScroll) - $elem.scroll(function(){ - let scrollTop = $elem.scrollTop() - let scrollHeight = $elem.prop('scrollHeight') - $elem.height() - $scope.$apply(function() { - onScrollHandler($scope, { - scrollTop: scrollTop, - scrollHeight: scrollHeight - }) - }) - }); - }); - - /* - $scope.update = (event:string): void => { - $scope.$evalAsync(function() { - //if ($attr.scrollDown == 'true' && event != 'mouseenter') { - if (event != 'mouseenter') { - setTimeout(function () { - $($elem).scrollTop($($elem).prop("scrollHeight")); - }, 100); - } - $elem.perfectScrollbar('update'); - }); - }; - */ - - // This is necessary when you don't watch anything with the scrollbar - $elem.bind('mouseenter', function(){ - //console.log("mouseenter"); - $elem.perfectScrollbar('update'); - }); - - $elem.bind('mouseleave', function(){ - //console.log("mouseleave"); - setTimeout(function () { - $(window).trigger('mouseup'); - $elem.perfectScrollbar('update'); - }, 10); - }); - - $elem.bind('click', function(){ - //console.log("click"); - // Wait 500 milliseconds until the collapse finish closing and update. - setTimeout(function () { - $elem.perfectScrollbar('update'); - }, 500); - }); - - /** - * Check if the content of the scroller was changed, and if changed update the scroller. - * Because DOMSubtreeModified event is fire many time (while filling the content), I'm checking that - * there is at least 100 milliseconds between DOMSubtreeModified events to update the scrollbar. - * @type {boolean} - */ - let insideDOMSubtreeModified=false; - $elem.bind('DOMSubtreeModified', function(){ - if (insideDOMSubtreeModified==false) { - insideDOMSubtreeModified=true; - setTimeout(function () { - insideDOMSubtreeModified=false; - $elem.perfectScrollbar('update'); - }, 100); - } - }); - - // Possible future improvement - check the type here and use the appropriate watch for non-arrays - if ($attr.refreshOnChange) { - $scope.$watchCollection($attr.refreshOnChange, function() { - $elem.perfectScrollbar('update'); - }); - } - - /* - // this is from a pull request - I am not totally sure what the original issue is but seems harmless - if ($attr.refreshOnResize) { - self.$window.on('resize', function(e){$scope.update(e)}); - } - */ - - $elem.bind('$destroy', function() { - //self.$window.off('resize', function(e){$scope.update(e)}); - $elem.perfectScrollbar('destroy'); - }); - - }; - - public static factory = ($templateCache: ng.ITemplateCacheService, $parse:any, $window:any)=> { - return new PerfectScrollerDirective($templateCache, $parse, $window); - }; - - } - - PerfectScrollerDirective.factory.$inject = ['$templateCache','$parse','$window']; -} diff --git a/catalog-ui/app/scripts/directives/print-graph-screen/print-graph-screen.ts b/catalog-ui/app/scripts/directives/print-graph-screen/print-graph-screen.ts deleted file mode 100644 index 8204928e6f..0000000000 --- a/catalog-ui/app/scripts/directives/print-graph-screen/print-graph-screen.ts +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface IPrintGraphScreenScope extends ng.IScope { - entity:Models.Components.Component; - } - - - export class PrintGraphScreenDirective implements ng.IDirective { - - constructor( - private $filter: ng.IFilterService, - private sdcMenu:Models.IAppMenu, - private sdcConfig:Models.IAppConfigurtaion, - private urlToBase64Service:Sdc.Services.UrlToBase64Service - ) {} - - scope = { - entity: '=' - }; - restrict = 'A'; - link = (scope:IPrintGraphScreenScope, element:any) => { - - - element.bind('click', function() { - printScreen(); - }); - - - // TODO we need to implement export to PDF in cytoscape - let printScreen = ():void => { - - // - // let pdf :any = new jsPDF('landscape', 'mm', 'a4'); - // pdf.setProperties({ - // title: scope.entity.name, - // subject: 'Design Snapshot for ' + scope.entity.name, - // author: scope.entity.creatorFullName, - // keywords: scope.entity.tags.join(', '), - // creator: scope.entity.creatorFullName - // }); - // - // // A4 measures is 210 × 297 millimeters - // let pdfWidth :number = 297, - // pdfHeight :number = 210, - // leftColumnWidth :number = 80; - // - // //left bar background - // pdf.setDrawColor(0); - // pdf.setFillColor(248, 249, 251); - // pdf.rect(0, 0, leftColumnWidth, pdfHeight, 'F'); - // - // //entity name - // pdf.setFontSize(12); - // pdf.setTextColor(38, 61, 77); - // let splitTitle :any = pdf.splitTextToSize(scope.entity.name, 50); - // pdf.text(22, 15 - (splitTitle.length - 1) * 2, splitTitle); - // - // //line - // pdf.setLineWidth(0.2); - // pdf.setDrawColor(208, 209, 213); - // pdf.line(0, 28, leftColumnWidth, 28); - // - // - // pdf.setFontSize(10); - // let properties :any = getPdfProperties(); - // - // let topOffset :number = 39, lines; - // properties.forEach( (item:any) => { - // if (!item.value) { - // return; - // } - // if (item.title === 'Description:') { - // topOffset += 5; - // } - // - // pdf.setTextColor(38, 61, 77); - // pdf.text(5, topOffset, item.title); - // pdf.setTextColor(102, 102, 102); - // lines = pdf.splitTextToSize(item.value, 49); - // pdf.text(5 + item.offset, topOffset, lines[0]); - // if (lines.length > 1) { - // lines = pdf.splitTextToSize(item.value.substring(lines[0].length + 1), 65); - // if (lines.length > 8) { - // lines = lines.slice(0, 7); - // lines[lines.length - 1] += '...'; - // } - // pdf.text(5, topOffset + 4, lines); - // topOffset += 4 * (lines.length); - // } - // - // topOffset += 6; - // }); - // - // - // //another background in case the text was too long - // let declarationLineOffset :number = 176; - // pdf.setDrawColor(0); - // pdf.setFillColor(248, 249, 251); - // pdf.rect(0, declarationLineOffset, leftColumnWidth, pdfHeight - declarationLineOffset, 'F'); - // //line - // pdf.setLineWidth(0.2); - // pdf.setDrawColor(208, 209, 213); - // pdf.line(0, declarationLineOffset, leftColumnWidth, declarationLineOffset); - // - // //declaration - // pdf.setFontSize(10.5); - // pdf.setTextColor(38, 61, 77); - // pdf.text(5, 185, 'Declaration'); - // pdf.setFontSize(9); - // pdf.setTextColor(102, 102, 102); - // pdf.setFontType('bold'); - // pdf.text(5, 190, this.$filter('translate')('PDF_FILE_DECLARATION_BOLD')); - // pdf.setFontType('normal'); - // pdf.text(5, 194, pdf.splitTextToSize(this.$filter('translate')('PDF_FILE_DECLARATION'), 65)); - // - // //entity icon - // let self = this; - // let addEntityIcon:Function = () => { - // let iconPath:string = self.sdcConfig.imagesPath + '/styles/images/'; - // if (scope.entity.isService()) { - // iconPath += 'service-icons/' + scope.entity.icon + '.png'; - // } else { - // iconPath += 'resource-icons/' + scope.entity.icon + '.png'; - // } - // self.urlToBase64Service.downloadUrl(iconPath, (base64string:string):void => { - // if (base64string) { - // pdf.addImage(base64string, 'JPEG', 5, 7, 15, 15); - // } - // pdf.save(scope.entity.name + '.pdf'); - // }); - // }; - // - // //actual snapshop of canvas - // - // let diagramDiv :any = document.getElementById('myDiagram'); - // let diagram :any = null;// Sdc.Graph.Diagram.fromDiv(diagramDiv), canvasImg = new Image(); - // diagram.startTransaction('print screen'); - // let canvasImgBase64:any = diagram.makeImageData({ - // //scale: 1, - // // size: new Sdc.Graph.Size(pdfHeight * 5, NaN), - // background: 'white', - // type: 'image/jpeg' - // }); - // diagramDiv.firstElementChild.toDataURL(); - // diagram.commitTransaction('print screen'); - // - // canvasImg.onload = () => { - // if (canvasImg.height > 0) { - // let canvasImgRatio:number = Math.min((pdfWidth - leftColumnWidth - 15) / canvasImg.width, pdfHeight / canvasImg.height); - // let canvasImgWidth:number = canvasImg.width * canvasImgRatio, - // canvasImgHeight:number = canvasImg.height * canvasImgRatio; - // let canvasImgOffset:number = (pdfHeight - canvasImgHeight) / 2; - // pdf.addImage(canvasImg, 'JPEG', leftColumnWidth, canvasImgOffset, canvasImgWidth, canvasImgHeight); - // - // addEntityIcon(); - // } - // }; - // - // if(canvasImg.src === 'data:,') { //empty canvas - // addEntityIcon(); - // } else { - // canvasImg.src = canvasImgBase64; - // } - }; - - let getPdfProperties = ():Array<any> => { - return [ - {title: this.$filter('translate')('GENERAL_LABEL_TYPE'), value: scope.entity.getComponentSubType(), offset: 10}, - {title: this.$filter('translate')('GENERAL_LABEL_VERSION'), value: scope.entity.version, offset: 15}, - {title: this.$filter('translate')('GENERAL_LABEL_CATEGORY'), value: scope.entity.categories.length ? scope.entity.categories[0].name : '', offset: 16}, - {title: this.$filter('translate')('GENERAL_LABEL_CREATION_DATE'), value: this.$filter('date')(scope.entity.creationDate, 'MM/dd/yyyy'), offset: 24}, - {title: this.$filter('translate')('GENERAL_LABEL_AUTHOR'), value: scope.entity.creatorFullName, offset: 13}, - {title: this.$filter('translate')('GENERAL_LABEL_CONTACT_ID'), value: scope.entity.contactId, offset: 41}, - {title: this.$filter('translate')('GENERAL_LABEL_STATUS'), value: (<any>this.sdcMenu).LifeCycleStatuses[scope.entity.lifecycleState].text, offset: 13}, - {title: this.$filter('translate')('GENERAL_LABEL_PROJECT_CODE'), value: scope.entity.projectCode, offset: 15}, - {title: this.$filter('translate')('GENERAL_LABEL_DESCRIPTION'), value: scope.entity.description, offset: 20}, - {title: this.$filter('translate')('GENERAL_LABEL_TAGS'), value: scope.entity.tags.join(', '), offset: 10} - ]; - }; - - }; - - public static factory = ($filter:ng.IFilterService, sdcMenu:Models.IAppMenu, sdcConfig:Models.IAppConfigurtaion, urlToBase64Service:Sdc.Services.UrlToBase64Service)=> { - return new PrintGraphScreenDirective($filter, sdcMenu, sdcConfig, urlToBase64Service); - }; - - } - - PrintGraphScreenDirective.factory.$inject = ['$filter', 'sdcMenu', 'sdcConfig', 'Sdc.Services.UrlToBase64Service']; -} diff --git a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts b/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts deleted file mode 100644 index 94567ca36b..0000000000 --- a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 1/27/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface IDataTypeFieldsStructureScope extends ng.IScope { - parentFormObj:ng.IFormController; - dataTypeProperties:Array<Models.DataTypePropertyModel>; - typeName:string; - valueObjRef:any; - propertyNameValidationPattern: RegExp; - fieldsPrefixName:string; - readOnly:boolean; - currentTypeDefaultValue:any; - types:Models.DataTypesMap; - expandByDefault:boolean; - expand:boolean; - expanded:boolean; - dataTypesService:Sdc.Services.DataTypesService; - - expandAndCollapse():void; - getValidationPattern(type:string):RegExp; - validateIntRange(value:string):boolean; - onValueChange(propertyName:string, type:string):void - } - - - export class DataTypeFieldsStructureDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private DataTypesService:Sdc.Services.DataTypesService, - private PropertyNameValidationPattern: RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils) { - } - - scope = { - valueObjRef: '=', - typeName: '=', - parentFormObj: '=', - fieldsPrefixName: '=', - readOnly: '=', - defaultValue: '@', - types: '=', - expandByDefault: '=' - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.html'); - }; - public types=Utils.Constants.PROPERTY_DATA.TYPES; - - //get data type properties array and return object with the properties and their default value - //(for example: get: [{name:"prop1",defaultValue:1 ...},{name:"prop2", defaultValue:"bla bla" ...}] - // return: {prop1: 1, prop2: "bla bla"} - private getDefaultValue = (dataTypeProperties:Array<Models.DataTypePropertyModel>):any => { - let defaultValue = {}; - for(let i=0; i < dataTypeProperties.length; i++){ - if(dataTypeProperties[i].type!='string'){ - if(dataTypeProperties[i].defaultValue){ - defaultValue[dataTypeProperties[i].name] = JSON.parse(dataTypeProperties[i].defaultValue); - } - }else{ - defaultValue[dataTypeProperties[i].name] = dataTypeProperties[i].defaultValue; - } - } - return defaultValue; - }; - - private initDataOnScope = (scope:any, $attr:any):void =>{ - scope.dataTypesService = this.DataTypesService; - scope.dataTypeProperties = this.DataTypesService.getFirsLevelOfDataTypeProperties(scope.typeName,scope.types); - if($attr.defaultValue){ - scope.currentTypeDefaultValue = JSON.parse($attr.defaultValue); - }else{ - scope.currentTypeDefaultValue = this.getDefaultValue(scope.dataTypeProperties); - } - - if(!scope.valueObjRef) { - scope.valueObjRef = {}; - } - - _.forEach(scope.currentTypeDefaultValue, (value, key)=> { - if(!scope.valueObjRef[key]){ - if(typeof scope.currentTypeDefaultValue[key] == 'object'){ - angular.copy(scope.currentTypeDefaultValue[key], scope.valueObjRef[key]); - }else{ - scope.valueObjRef[key] = scope.currentTypeDefaultValue[key]; - } - } - }); - }; - - private rerender = (scope:any):void =>{ - scope.expanded = false; - scope.expand = false; - if(scope.expandByDefault){ - scope.expandAndCollapse(); - } - }; - - link = (scope:IDataTypeFieldsStructureScope, element:any, $attr:any) => { - scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - - scope.$watchCollection('[typeName,fieldsPrefixName]', (newData:any):void => { - this.rerender(scope); - }); - - - scope.expandAndCollapse = ():void => { - if(!scope.expanded){ - this.initDataOnScope(scope,$attr); - scope.expanded=true; - } - scope.expand=!scope.expand; - }; - - scope.getValidationPattern = (type:string):RegExp => { - return this.ValidationUtils.getValidationPattern(type); - }; - - scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - scope.onValueChange = (propertyName:string, type:string):void => { - scope.valueObjRef[propertyName] = !angular.isUndefined(scope.valueObjRef[propertyName]) ? scope.valueObjRef[propertyName] : scope.currentTypeDefaultValue[propertyName]; - if(scope.valueObjRef[propertyName] && type != 'string'){ - scope.valueObjRef[propertyName] = JSON.parse(scope.valueObjRef[propertyName]); - } - }; - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, - DataTypesService:Sdc.Services.DataTypesService, - PropertyNameValidationPattern:RegExp, - ValidationUtils:Sdc.Utils.ValidationUtils)=> { - return new DataTypeFieldsStructureDirective($templateCache,DataTypesService,PropertyNameValidationPattern,ValidationUtils); - }; - } - - DataTypeFieldsStructureDirective.factory.$inject = ['$templateCache','Sdc.Services.DataTypesService','PropertyNameValidationPattern','ValidationUtils']; -} diff --git a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.ts b/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.ts deleted file mode 100644 index ce5ee1ffa6..0000000000 --- a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.ts +++ /dev/null @@ -1,130 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/15/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - /// import Model = go.Model; - - export interface ITypeListScope extends ng.IScope { - parentFormObj:ng.IFormController; - schemaProperty:Models.SchemaProperty; - isSchemaTypeDataType:boolean; - valueObjRef:any; - propertyNameValidationPattern: RegExp; - fieldsPrefixName:string; - readOnly:boolean; - listDefaultValue:any; - types:Models.DataTypesMap; - listNewItem:any; - maxLength:number; - - getValidationPattern(type:string):RegExp; - validateIntRange(value:string):boolean; - addListItem():void; - deleteListItem(listItemIndex:number):void - } - - - export class TypeListDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private DataTypesService:Sdc.Services.DataTypesService, - private PropertyNameValidationPattern: RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils) { - } - - scope = { - valueObjRef: '=',//ref to list object in the parent value object - schemaProperty: '=',//get the schema.property object - parentFormObj: '=',//ref to parent form (get angular form object) - fieldsPrefixName: '=',//prefix for form fields names - readOnly: '=',//is form read only - defaultValue: '@',//this list default value - types: '=',//data types list - maxLength: '=' - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/property-types/type-list/type-list-directive.html'); - }; - - link = (scope:ITypeListScope, element:any, $attr:any) => { - scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - - //reset valueObjRef when schema type is changed - scope.$watchCollection('schemaProperty.type', (newData:any):void => { - scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty,scope.types); - //insert 1 empty item dt by default - if(scope.isSchemaTypeDataType && (!scope.valueObjRef||!scope.valueObjRef.length)){ - scope.valueObjRef = scope.valueObjRef ||[]; - scope.valueObjRef.push({}); - } - }); - - //when user brows between properties in "edit property form" - scope.$watchCollection('fieldsPrefixName', (newData:any):void => { - scope.listNewItem={value:''}; - - if($attr.defaultValue){ - scope.listDefaultValue = JSON.parse($attr.defaultValue); - } - }); - - scope.getValidationPattern = (type:string):RegExp => { - return this.ValidationUtils.getValidationPattern(type); - }; - - scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - scope.addListItem = ():void => { - scope.valueObjRef = scope.valueObjRef ||[]; - let newVal = ((scope.schemaProperty.simpleType||scope.schemaProperty.type)==Utils.Constants.PROPERTY_TYPES.STRING?scope.listNewItem.value:JSON.parse(scope.listNewItem.value)); - scope.valueObjRef.push(newVal); - scope.listNewItem.value = ""; - }; - - scope.deleteListItem = (listItemIndex:number):void => { - scope.valueObjRef.splice(listItemIndex,1); - if (!scope.valueObjRef.length) { - if (scope.listDefaultValue ) { - angular.copy(scope.listDefaultValue, scope.valueObjRef); - } - } - }; - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, - DataTypesService:Sdc.Services.DataTypesService, - PropertyNameValidationPattern:RegExp, - ValidationUtils:Sdc.Utils.ValidationUtils)=> { - return new TypeListDirective($templateCache,DataTypesService,PropertyNameValidationPattern,ValidationUtils); - }; - } - - TypeListDirective.factory.$inject = ['$templateCache','Sdc.Services.DataTypesService','PropertyNameValidationPattern','ValidationUtils']; -} - diff --git a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.ts b/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.ts deleted file mode 100644 index d94ccf3886..0000000000 --- a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.ts +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/15/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ITypeMapScope extends ng.IScope { - parentFormObj:ng.IFormController; - schemaProperty:Models.SchemaProperty; - isSchemaTypeDataType:boolean; - valueObjRef:any; - mapKeys:Array<string>;//array of map keys - propertyNameValidationPattern: RegExp; - fieldsPrefixName:string; - readOnly:boolean; - mapDefaultValue:any; - types:Models.DataTypesMap; - maxLength:number; - - getValidationPattern(type:string):RegExp; - validateIntRange(value:string):boolean; - changeKeyOfMap(newKey:string, index:number, fieldName:string):void; - deleteMapItem(index:number):void; - addMapItemFields():void; - parseToCorrectType(objectOfValues:any, locationInObj:string, type:string):void; - getNumber(num:number):Array<any>; - } - - - export class TypeMapDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private DataTypesService:Sdc.Services.DataTypesService, - private PropertyNameValidationPattern: RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils, - private $timeout: ng.ITimeoutService) { - } - - scope = { - valueObjRef: '=',//ref to map object in the parent value object - schemaProperty: '=',//get the schema.property object - parentFormObj: '=',//ref to parent form (get angular form object) - fieldsPrefixName: '=',//prefix for form fields names - readOnly: '=',//is form read only - defaultValue: '@',//this map default value - types: '=',//data types list - maxLength: '=' - }; - - restrict = 'E'; - replace = true; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/property-types/type-map/type-map-directive.html'); - }; - - link = (scope:ITypeMapScope, element:any, $attr:any) => { - scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - - //reset valueObjRef and mapKeys when schema type is changed - scope.$watchCollection('schemaProperty.type', (newData:any):void => { - scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty,scope.types); - if(scope.valueObjRef){ - scope.mapKeys = Object.keys(scope.valueObjRef); - } - }); - - //when user brows between properties in "edit property form" - scope.$watchCollection('fieldsPrefixName', (newData:any):void => { - if(!scope.valueObjRef) { - scope.valueObjRef={}; - } - scope.mapKeys = Object.keys(scope.valueObjRef); - - if($attr.defaultValue){ - scope.mapDefaultValue = JSON.parse($attr.defaultValue); - } - }); - - //return dummy array in order to prevent rendering map-keys ng-repeat again when a map key is changed - scope.getNumber = (num:number):Array<any> => { - return new Array(num); - }; - - scope.getValidationPattern = (type:string):RegExp => { - return this.ValidationUtils.getValidationPattern(type); - }; - - scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - scope.changeKeyOfMap = (newKey:string, index:number, fieldName:string) : void => { - let oldKey = Object.keys(scope.valueObjRef)[index]; - if(Object.keys(scope.valueObjRef).indexOf(newKey)>-1){ - scope.parentFormObj[fieldName].$setValidity('keyExist', false); - }else{ - scope.parentFormObj[fieldName].$setValidity('keyExist', true); - if(!scope.parentFormObj[fieldName].$invalid){ - angular.copy(JSON.parse(JSON.stringify(scope.valueObjRef).replace('"'+oldKey+'":', '"'+newKey+'":')),scope.valueObjRef);//update key - } - } - }; - - scope.deleteMapItem=(index:number):void=>{ - delete scope.valueObjRef[scope.mapKeys[index]]; - scope.mapKeys.splice(index,1); - if (!scope.mapKeys.length) {//only when user removes all pairs of key-value fields - put the default - if ( scope.mapDefaultValue ) { - angular.copy(scope.mapDefaultValue, scope.valueObjRef); - scope.mapKeys = Object.keys(scope.valueObjRef); - } - } - }; - - scope.addMapItemFields = ():void => { - scope.valueObjRef['']= null; - scope.mapKeys = Object.keys(scope.valueObjRef); - }; - - scope.parseToCorrectType = (objectOfValues:any, locationInObj:string, type:string):void => { - if(objectOfValues[locationInObj] && type != Utils.Constants.PROPERTY_TYPES.STRING){ - objectOfValues[locationInObj] = JSON.parse(objectOfValues[locationInObj]); - } - } - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, - DataTypesService:Sdc.Services.DataTypesService, - PropertyNameValidationPattern:RegExp, - ValidationUtils:Sdc.Utils.ValidationUtils, - $timeout: ng.ITimeoutService)=> { - return new TypeMapDirective($templateCache,DataTypesService,PropertyNameValidationPattern,ValidationUtils,$timeout); - }; - } - - TypeMapDirective.factory.$inject = ['$templateCache','Sdc.Services.DataTypesService','PropertyNameValidationPattern','ValidationUtils','$timeout']; -} diff --git a/catalog-ui/app/scripts/directives/punch-out/punch-out.ts b/catalog-ui/app/scripts/directives/punch-out/punch-out.ts deleted file mode 100644 index f00b7971a9..0000000000 --- a/catalog-ui/app/scripts/directives/punch-out/punch-out.ts +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - export interface IPunchOutScope extends ng.IScope { - name: string; - data: any; - user: Models.IUserProperties; - onEvent: Function; - } - - export class PunchOutDirective implements ng.IDirective { - - constructor( - private sdcConfig: Sdc.Models.IAppConfigurtaion) {} - - scope = { - name: '=', - data: '=', - user: '=', - onEvent: '&' - }; - - replace = false; - restrict = 'E'; - - link = (scope: IPunchOutScope, element: ng.IAugmentedJQuery):void => { - // global registry object - let PunchOutRegistry = window['PunchOutRegistry']; - - let render = ():void => { - let cookieConfig = this.sdcConfig.cookie; - let props = { - name: scope.name, - options: { - data: scope.data, - apiRoot: this.sdcConfig.api.root, - apiHeaders: { - userId: { - name: cookieConfig.userIdSuffix, - value: scope.user.userId - }, - userFirstName: { - name: cookieConfig.userFirstName, - value: scope.user.firstName - }, - userLastName: { - name: cookieConfig.userLastName, - value: scope.user.lastName - }, - userEmail: { - name: cookieConfig.userEmail, - value: scope.user.email - } - } - }, - onEvent: (...args) => { - scope.$apply(() => { - scope.onEvent().apply(null, args); - }); - } - }; - PunchOutRegistry.render(props, element[0]); - }; - - let unmount = ():void => { - PunchOutRegistry.unmount(element[0]); - }; - - scope.$watch('data', render); - element.on('$destroy', unmount); - }; - - public static factory = (sdcConfig: Sdc.Models.IAppConfigurtaion) => { - return new PunchOutDirective(sdcConfig); - }; - - } - - PunchOutDirective.factory.$inject = ['sdcConfig']; -} diff --git a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts b/catalog-ui/app/scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts deleted file mode 100644 index 26390a7501..0000000000 --- a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export class SdcSingleTabDirective implements ng.IDirective { - - constructor(private $compile:ng.ICompileService, private $parse:ng.IParseService) { - } - restrict = 'E'; - - link = (scope, elem:any, attrs:any, ctrl:any) => { - if(!elem.attr('inner-sdc-single-tab')) { - let name = this.$parse(elem.attr('ctrl'))(scope); - elem = elem.removeAttr('ctrl'); - elem.attr('inner-sdc-single-tab', name); - this.$compile(elem)(scope); - } - }; - - public static factory = ($compile:ng.ICompileService, $parse:ng.IParseService)=> { - return new SdcSingleTabDirective($compile, $parse); - }; - } - - export class InnerSdcSingleTabDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - singleTab: "=", - isViewOnly: "=" - }; - - replace = true; - restrict = 'A'; - controller = '@'; - template = '<div ng-include src="singleTab.templateUrl"></div>'; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new InnerSdcSingleTabDirective($templateCache); - }; - } - - SdcSingleTabDirective.factory.$inject = ['$compile', '$parse']; - InnerSdcSingleTabDirective.factory.$inject = ['$templateCache']; - -} diff --git a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs-directive.ts b/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs-directive.ts deleted file mode 100644 index 91d1744ae5..0000000000 --- a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs-directive.ts +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/28/2016. - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISdcTabsDirectiveScope extends ng.IScope { - tabs:Array<Models.Tab>; - selectedTab: Models.Tab; - isActive: boolean; - onTabSelected(selectedTab: Models.Tab); - } - - export class SdcTabsDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - tabs: "=", - selectedTab: "=?", - isViewOnly: "=" - }; - - replace = true; - restrict = 'E'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/sdc-tabs/sdc-tabs-directive-view.html'); - }; - - link = (scope:ISdcTabsDirectiveScope) => { - scope.isActive = true; - - if(!scope.selectedTab){ - scope.selectedTab = scope.tabs[0]; - } - - scope.onTabSelected = (selectedTab: Models.Tab) => { - scope.selectedTab = selectedTab; - } - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcTabsDirective($templateCache); - }; - } - - SdcTabsDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.ts b/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.ts deleted file mode 100644 index 1edce6f36e..0000000000 --- a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.ts +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - - export interface IStructureTreeScope extends ng.IScope { - - component: Models.Components.Component; - structureTree: StructureTree; - } - - class StructureTree { - - serviceRoot:ResourceInstanceNode; - - constructor(private uniqueId:string, private resourceInstanceName:string, private resourceInstanceIcon:string, private certified:boolean) { - this.serviceRoot = new ResourceInstanceNode(uniqueId, resourceInstanceName, resourceInstanceIcon, certified); - } - - } - - class ResourceInstanceNode { - id:string; - icon:string; - name:string; - resourceInstancesList:Array<ResourceInstanceNode>; - isAlreadyInTree:boolean; - certified:boolean; - - - constructor(private uniqueId:string, private resourceInstanceName:string, private resourceInstanceIcon:string, certified:boolean) { - this.id = uniqueId; - this.name = resourceInstanceName; - this.icon = resourceInstanceIcon; - this.resourceInstancesList = []; - this.isAlreadyInTree = false; - this.certified = certified; - } - } - - export class StructureTreeDirective implements ng.IDirective { - - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - component: '=', - }; - restrict = 'E'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/structure-tree/structure-tree-directive.html'); - }; - - link = (scope:IStructureTreeScope, $elem:any) => { - - let RESOURCE_INSTANCE_LIST:string = "resourceInstancesChildesList"; - let resourceInstanceMap:Utils.Dictionary<string, ResourceInstanceNode>; - let relations:Array<Models.RelationshipModel>; - //************* Start Building Tree Functions *******************// - - //remove unnecessary instances - let initResourceInstanceMap = ():void => { - - resourceInstanceMap = new Utils.Dictionary<string, ResourceInstanceNode>(); - - _.forEach(scope.component.componentInstances, (resourceInstance:Models.ComponentsInstances.ComponentInstance)=> { - if (_.some(Object.keys(resourceInstance.capabilities), (key:string)=> { - return 'tosca.capabilities.container' == key.toLowerCase(); - }) || _.some(Object.keys(resourceInstance.requirements),(key:string)=> { - return 'tosca.capabilities.container' == key.toLowerCase(); - })) { - - let isCertified = 0 === (parseFloat(resourceInstance.componentVersion) % 1); - let node:ResourceInstanceNode = new ResourceInstanceNode(resourceInstance.uniqueId, - resourceInstance.name, - resourceInstance.icon, - isCertified); - resourceInstanceMap.setValue(resourceInstance.uniqueId, node); - } - }); - }; - - //remove unnecessary relations - let initRelations = ():void => { - relations = _.filter(scope.component.componentInstancesRelations, (relation:Models.RelationshipModel)=> { - return resourceInstanceMap.containsKey(relation.fromNode) && resourceInstanceMap.containsKey(relation.toNode); - }); - }; - - let buildTree = ():void => { - if (scope.component) { - scope.structureTree = new StructureTree(scope.component.uniqueId, scope.component.name, scope.component.icon, 'CERTIFIED' === scope.component.lifecycleState); - initResourceInstanceMap(); - initRelations(); - - let parentNodesList = _.groupBy(relations, (node:any)=> { - return node.fromNode; - }); - - for (let parent in parentNodesList) { - _.forEach(parentNodesList[parent], (childNode)=> { - parentNodesList[parent][RESOURCE_INSTANCE_LIST] = []; - parentNodesList[parent][RESOURCE_INSTANCE_LIST].push(mergeAllSubtrees(childNode, parentNodesList)); - }); - } - - //add the resourceInstanceList for the service root node - for (let parent in parentNodesList) { - let resourceInstanceNode:ResourceInstanceNode = resourceInstanceMap.getValue(parent); - resourceInstanceNode.resourceInstancesList = parentNodesList[parent]; - resourceInstanceNode.resourceInstancesList = parentNodesList[parent][RESOURCE_INSTANCE_LIST]; - resourceInstanceNode.isAlreadyInTree = true; - scope.structureTree.serviceRoot.resourceInstancesList.push(resourceInstanceNode); - } - - // Add all node that have no connection to the rootNode - resourceInstanceMap.forEach((key:string, value:ResourceInstanceNode) => { - if (!value.isAlreadyInTree) { - scope.structureTree.serviceRoot.resourceInstancesList.push(value); - } - }); - } - }; - - //this recursion is merging all the subtrees - let mergeAllSubtrees = (connectionData:any, parentNodesList:any):ResourceInstanceNode => { - let resourceInstanceNode:ResourceInstanceNode = resourceInstanceMap.getValue(connectionData.toNode); - resourceInstanceNode.isAlreadyInTree = true; - if (parentNodesList[resourceInstanceNode.id]) { - if (parentNodesList[resourceInstanceNode.id][RESOURCE_INSTANCE_LIST]) { - resourceInstanceNode.resourceInstancesList = parentNodesList[resourceInstanceNode.id][RESOURCE_INSTANCE_LIST]; - } - else { - _.forEach(parentNodesList[resourceInstanceNode.id], (children)=> { - resourceInstanceNode.resourceInstancesList.push(mergeAllSubtrees(children, parentNodesList)); - }); - } - delete parentNodesList[resourceInstanceNode.id]; - } - return resourceInstanceNode; - }; - //************* End Building Tree Functions *******************// - - //************* Start Watchers *******************// - scope.$watch('component.name', ():void => { - if (scope.structureTree) - scope.structureTree.serviceRoot.name = scope.component.name; - }); - - scope.$watch('component.icon', ():void => { - if (scope.structureTree) - scope.structureTree.serviceRoot.icon = scope.component.icon; - }); - - scope.$watchCollection('component.componentInstancesRelations', ():void => { - buildTree(); - }); - - scope.$watchCollection('component.componentInstances', ():void => { - buildTree(); - }); - - //************* End Watchers *******************// - - buildTree(); - - }; - - - public static factory = ($templateCache:ng.ITemplateCacheService) => { - return new StructureTreeDirective($templateCache); - }; - } - - StructureTreeDirective.factory.$inject = ['$templateCache']; - -} diff --git a/catalog-ui/app/scripts/directives/tag/tag-directive.ts b/catalog-ui/app/scripts/directives/tag/tag-directive.ts deleted file mode 100644 index 64d245e242..0000000000 --- a/catalog-ui/app/scripts/directives/tag/tag-directive.ts +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - - export class TagData { - tag:string; - tooltip:string; - id: string; - } - - export interface ITagScope extends ng.IScope { - tagData: TagData; - onDelete: Function; - delete:Function; - hideTooltip:boolean; - hideDelete:boolean; - sdcDisable: boolean; - } - - export class TagDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - tagData: '=', - onDelete: '&', - hideTooltip: '=', - hideDelete: '=', - sdcDisable: '=' - }; - - replace = true; - restrict = 'EA'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/tag/tag-directive.html'); - }; - - link = (scope:ITagScope) => { - scope.delete = ()=>{ - scope.onDelete({'uniqueId':scope.tagData.id}); - } - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new TagDirective($templateCache); - }; - - } - - TagDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/tutorial/image-template.html b/catalog-ui/app/scripts/directives/tutorial/image-template.html deleted file mode 100644 index 7e7f7af356..0000000000 --- a/catalog-ui/app/scripts/directives/tutorial/image-template.html +++ /dev/null @@ -1,7 +0,0 @@ -<perfect-scrollbar include-padding="true" class="sdc-tutorial-container-content sdc-tutorial-image-template"> - <div class="{{pageObject.data.imageClass}}"></div> - <div class="sdc-tutorial-image-template-text"> - <h1 translate="{{pageObject.data.title}}"></h1> - <p class="sdc-welcome-page-description2" translate="{{pageObject.data.description}}"></p> - </div> -</perfect-scrollbar> diff --git a/catalog-ui/app/scripts/directives/tutorial/text-template.html b/catalog-ui/app/scripts/directives/tutorial/text-template.html deleted file mode 100644 index dc1173be64..0000000000 --- a/catalog-ui/app/scripts/directives/tutorial/text-template.html +++ /dev/null @@ -1,4 +0,0 @@ -<perfect-scrollbar include-padding="true" class="sdc-tutorial-container-content sdc-tutorial-text-template"> - <h1 translate="{{pageObject.data.title}}"></h1> - <p class="sdc-welcome-page-description2" translate="{{pageObject.data.description}}"></p> -</perfect-scrollbar> diff --git a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.html b/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.html deleted file mode 100644 index 191752fc1f..0000000000 --- a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.html +++ /dev/null @@ -1,22 +0,0 @@ -<div class="sdc-tutorial-page" data-ng-if="showTutorial"> - <div class="sdc-tutorial-container-wrapper"> - <div class="sdc-tutorial-skip" translate="{{isFirstTime?'TUTRIAL_GENERAL_SKIP_BUTTON':'TUTRIAL_GENERAL_CLOSE_BUTTON'}}" data-ng-click="closeTutorial()"></div> - <div class="sdc-tutorial-container"> - <div class="sdc-tutorial-container-tabs"> - <div class="sdc-tutorial-container-tab" data-ng-repeat="tab in tabs" data-ng-class="{'selected': tab.id===pageObject.tab}"> - <span translate="{{tab.name}}" data-ng-click="initPage(tab.defaultPage)"></span> - </div> - </div> - <ng-include src="templateUrl"></ng-include> - </div> - - <div class="sdc-tutorial-footer"> - <div class="sdc-tutorial-footer-prev-button"><span data-ng-show="hasPrevious()" translate="TUTRIAL_GENERAL_PREVIOUS_BUTTON" data-ng-click="previous()"></span></div> - <div class="sdc-tutorial-footer-page-counter"><span class="selected" data-ng-bind="currentPageIndex+1"></span>/<span class="total" data-ng-bind="totalPages"></span></div> - <div class="sdc-tutorial-footer-next-button"> - <span data-ng-if="hasNext()" translate="TUTRIAL_GENERAL_NEXT_BUTTON" data-ng-click="next()"></span> - <span data-ng-if="(currentPageIndex+1) === totalPages" translate="TUTRIAL_GENERAL_NEXT_BUTTON_END" data-ng-click="closeAndShowLastPage()"></span> - </div> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.less b/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.less deleted file mode 100644 index 410a54e9c1..0000000000 --- a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.less +++ /dev/null @@ -1,213 +0,0 @@ -.sdc-tutorial-page { - - width: 100%; - height: 100%; - background-color: rgba(0,0,0,0.8); - - display: flex; - align-items: center; - justify-content: center; - position: absolute; - top: 0; - left: 0; - z-index: 3000; - - .sdc-tutorial-container-wrapper { - display: flex; - flex-direction: column; - } - - .sdc-tutorial-container { - .bg_c; - width: 830px; - height: 466px; - box-shadow: 1px 2px 2px 0px rgba(0, 0, 0, 0.35); - } - - .sdc-tutorial-container-tabs { - height: 56px; - display: flex; - flex-direction: row; - } - - .sdc-tutorial-container-tab { - .a_6; - flex-grow: 1; - align-items: center; - justify-content: center; - display: flex; - height: 56px; - position: relative; - opacity: 0.8; - - span { - .hand; - } - - &::after { - content: ''; - display: block; - border-right: solid 1px ; - border-color: rgba(59, 123, 155, 0.31); - height: 28px; - right: 0; - position: absolute; - top: 14px; //(56-28)/2 - width: 1px; - } - - &:last-child:after { - display: none; - } - - &.selected { - opacity: 1; - .bold; - } - - } - - .sdc-tutorial-container-content { - .bg_a; - .perfect-scrollbar; - display: flex; - align-items: center; - height: 410px; - } - - .sdc-tutorial-skip { - .c_1; - .hand; - text-align: right; - margin-bottom: 9px; - } - - .sdc-tutorial-footer { - .c_4; - margin-top: 9px; - - .sdc-tutorial-footer-prev-button { - float: left; - position: relative; - padding-left: 14px; - .noselect; - - span { - .hand; - &::before { - content: '<'; - display: block; - position: absolute; - left: 0; - top: 0; - } - } - } - - .sdc-tutorial-footer-page-counter { - .e_3; - position: absolute; - left: 50%; - margin-top: 2px; - cursor: default; - .noselect; - - .selected { - .c_3; - .bold; - margin-right: 2px; - } - - .total { - margin-left: 2px; - } - } - - .sdc-tutorial-footer-next-button { - float: right; - position: relative; - padding-right: 14px; - .noselect; - - span { - .hand; - - &::after { - content: '>'; - display: block; - position: absolute; - right: 0; - top: 0; - } - } - } - - } - -} - -///////////////// TEXT TEMPLATE -.sdc-tutorial-text-template { - - padding: 20px 65px; - - h1 { - .c_15; - margin-top: 0; - } - - p { - .c_10; - } -} - -///////////////// IMAGE TEMPLATE -.sdc-tutorial-image-template { - - .sdc-tutorial-image-template-text { - padding: 16px 38px; - height: 118px; - h1 { - .c_11; - margin: 0 0 4px 0; - } - - p { - .c_4; - font-weight: 300; - line-height: 21px; - } - - } - - .sdc-tutorial-page-2-image { background: transparent url('../../../styles/images/tutorial/2.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-3-image { background: transparent url('../../../styles/images/tutorial/3.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-4-image { background: transparent url('../../../styles/images/tutorial/4.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-5-image { background: transparent url('../../../styles/images/tutorial/5.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-6-image { background: transparent url('../../../styles/images/tutorial/6.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-7-image { background: transparent url('../../../styles/images/tutorial/7.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-8-image { background: transparent url('../../../styles/images/tutorial/8.png') no-repeat 0 0; width: 830px; height: 292px;} - - .sdc-tutorial-page-10-image { background: transparent url('../../../styles/images/tutorial/10.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-11-image { background: transparent url('../../../styles/images/tutorial/11.png') no-repeat 0 0; width: 830px; height: 292px;} - - .sdc-tutorial-page-13-image { background: transparent url('../../../styles/images/tutorial/13.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-14-image { background: transparent url('../../../styles/images/tutorial/14.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-15-image { background: transparent url('../../../styles/images/tutorial/15.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-16-image { background: transparent url('../../../styles/images/tutorial/16.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-17-image { background: transparent url('../../../styles/images/tutorial/17.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-18-image { background: transparent url('../../../styles/images/tutorial/18.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-19-image { background: transparent url('../../../styles/images/tutorial/19.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-20-image { background: transparent url('../../../styles/images/tutorial/20.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-21-image { background: transparent url('../../../styles/images/tutorial/21.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-22-image { background: transparent url('../../../styles/images/tutorial/22.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-23-image { background: transparent url('../../../styles/images/tutorial/23.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-24-image { background: transparent url('../../../styles/images/tutorial/24.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-25-image { background: transparent url('../../../styles/images/tutorial/25.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-26-image { background: transparent url('../../../styles/images/tutorial/26.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-27-image { background: transparent url('../../../styles/images/tutorial/27.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-28-image { background: transparent url('../../../styles/images/tutorial/28.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-29-image { background: transparent url('../../../styles/images/tutorial/29.png') no-repeat 0 0; width: 830px; height: 292px;} - .sdc-tutorial-page-30-image { background: transparent url('../../../styles/images/tutorial/30.png') no-repeat 0 0; width: 830px; height: 292px;} - -} diff --git a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.ts b/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.ts deleted file mode 100644 index 7df35cade9..0000000000 --- a/catalog-ui/app/scripts/directives/tutorial/tutorial-directive.ts +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - export interface ITutorialScope extends ng.IScope { - showTutorial:boolean; - isFirstTime:boolean; - templateUrl:string; - totalPages: number; - currentPageIndex: number; - page:number; - tabs:Array<string>; - tutorialData:any; - pageObject:any; - - initPage:Function; - next:Function; - previous:Function; - hasNext():boolean; - hasPrevious():boolean; - closeTutorial:Function; - closeAndShowLastPage:Function; - } - - export class TutorialDirective implements ng.IDirective { - - constructor( - private $templateCache:ng.ITemplateCacheService, - private sdcConfig:Models.IAppConfigurtaion, - private $state:ng.ui.IStateService - ) { - } - - scope = { - page: '=', - showTutorial: '=', - isFirstTime: '=' - }; - - replace = false; - restrict = 'EA'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/tutorial/tutorial-directive.html'); - }; - - link = (scope:ITutorialScope, $elem:any) => { - - let findPageIndex:Function = (pageId:number):number=> { - for (let i:number=0;i<scope.totalPages;i++){ - if (scope.tutorialData.pages[i].id===pageId){ - return i; - } - } - return -1; - } - - let showCurrentPage:Function = ():void=> { - scope.pageObject = scope.tutorialData.pages[scope.currentPageIndex]; - scope.templateUrl = '/app/scripts/directives/tutorial/' + scope.pageObject.template + '.html'; - } - - scope.tutorialData = this.sdcConfig.tutorial; - - scope.closeTutorial = ()=> { - scope.showTutorial = false; - if(scope.isFirstTime){ - scope.isFirstTime=false; - } - } - - scope.closeAndShowLastPage = ()=> { - if(scope.isFirstTime){ - this.$state.go('dashboard.tutorial-end'); - } - scope.closeTutorial(); - } - - let init:Function = ():void => { - scope.tabs = scope.tutorialData.tabs; - scope.totalPages = scope.tutorialData.pages.length; - scope.initPage(scope.page); - - } - - scope.initPage = (pageId) => { - scope.currentPageIndex = findPageIndex(pageId); - showCurrentPage(); - } - - scope.next = ():void => { - if (scope.hasNext()){ - scope.currentPageIndex++; - showCurrentPage(); - } - } - - scope.previous = ():void => { - if (scope.hasPrevious()){ - scope.currentPageIndex--; - showCurrentPage(); - } - } - - scope.hasNext = ():boolean => { - return (scope.currentPageIndex+1) < scope.totalPages; - } - - scope.hasPrevious = ():boolean => { - return scope.currentPageIndex>0; - } - - angular.element(document).ready(function () { - init(); - }); - - scope.$watch('showTutorial', (showTutorial:any):void => { - scope.initPage(scope.page); - }); - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, sdcConfig:Models.IAppConfigurtaion, $state:ng.ui.IStateService)=> { - return new TutorialDirective($templateCache, sdcConfig, $state); - }; - - } - - TutorialDirective.factory.$inject = ['$templateCache', 'sdcConfig', '$state']; -} diff --git a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.ts b/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.ts deleted file mode 100644 index 46c43a266b..0000000000 --- a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.ts +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Directives { - 'use strict'; - export interface IUserHeaderDetailsScope extends ng.IScope { - name: string; - role: string; - iconUrl: string; - UserResourceClass:Services.IUserResourceClass; - user: Models.IUser; - sdcConfig:Models.IAppConfigurtaion; - initUser:Function; - } - - export class UserHeaderDetailsDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, private $http:ng.IHttpService, private sdcConfig:Models.IAppConfigurtaion, private UserResourceClass:Services.IUserResourceClass) { - } - - scope = { - iconUrl: '=?' - }; - - replace = true; - restrict = 'E'; - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/user-header-details/user-header-details-directive.html'); - }; - - link = (scope:IUserHeaderDetailsScope) => { - - scope.initUser = ():void => { - let defaultUserId:string; - let user:Services.IUserResource = this.UserResourceClass.getLoggedinUser(); - if (!user) { - defaultUserId = this.$http.defaults.headers.common[this.sdcConfig.cookie.userIdSuffix]; - user = this.UserResourceClass.get({id: defaultUserId}, ():void => { - scope.user = new Models.User(user); - }); - } else { - scope.user = new Models.User(user); - } - }; - scope.initUser(); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $http:ng.IHttpService, sdcConfig:Models.IAppConfigurtaion, UserResourceClass:Services.IUserResourceClass)=> { - return new UserHeaderDetailsDirective($templateCache, $http, sdcConfig, UserResourceClass); - }; - - } - - UserHeaderDetailsDirective.factory.$inject = ['$templateCache', '$http', 'sdcConfig', 'Sdc.Services.UserResourceService']; -} diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts b/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts deleted file mode 100644 index 9756ff9e49..0000000000 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - export interface IExpandCollapseMenuBoxDirectiveScope extends ng.IScope { - menuItemsGroup: Utils.MenuItemGroup; - menuTitle: string; - parentScope: ng.IScope; - onMenuItemClick(menuItem: Utils.MenuItem):void; - } - - export class ExpandCollapseMenuBoxDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - menuTitle: '@', - menuItemsGroup: '=', - parentScope: '=' - }; - - public replace = false; - public restrict = 'AE'; - public transclude = true; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.html'); - }; - - link = (scope:IExpandCollapseMenuBoxDirectiveScope, $elem:any) => { - scope.onMenuItemClick = (menuItem: Utils.MenuItem):void => { - let onSuccess = ():void => { - scope.menuItemsGroup.selectedIndex = scope.menuItemsGroup.menuItems.indexOf(menuItem); - }; - let onFailed = ():void => {}; - scope.parentScope[menuItem.action](menuItem.state).then(onSuccess, onFailed); - } - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new ExpandCollapseMenuBoxDirective($templateCache); - }; - - } - - ExpandCollapseMenuBoxDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.ts b/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.ts deleted file mode 100644 index b294da6c13..0000000000 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.ts +++ /dev/null @@ -1,136 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - export interface IExpandCollapseScope extends ng.IScope { - toggle(): void; - collapsed: boolean; - expandedSelector: string; - content:string; - isCloseOnInit:boolean; - loadDataFunction: Function; - isLoadingData: boolean; - } - - export class ExpandCollapseDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - expandedSelector: '@', - loadDataFunction: '&?', - isCloseOnInit: '=?' - }; - - public replace = false; - public restrict = 'AE'; - public transclude = true; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/expand-collapse/expand-collapse.html'); - }; - - link = (scope:IExpandCollapseScope, $elem:any) => { - scope.collapsed = false; - scope.isLoadingData = false; - $elem.addClass('expanded'); - - - if(scope.isCloseOnInit) { - window.setTimeout(function () { - toggle(); - },0); - } - - $elem.click(function(){ - toggle(); - }); - - let expand = ():void => { - $elem.addClass('expanded'); - scope.collapsed = false; - - let element = $(scope.expandedSelector)[0]; - let prevWidth = element.style.height; - element.style.height = 'auto'; - let endWidth = getComputedStyle(element).height; - element.style.height = prevWidth; - element.offsetHeight; // force repaint - element.style.transition = 'height .3s ease-in-out'; - element.style.height = endWidth; - element.hidden = false; - element.addEventListener('transitionend', function transitionEnd(event) { - if (event['propertyName'] == 'height') { - element.style.transition = ''; - element.style.height = 'auto'; - element.removeEventListener('transitionend', transitionEnd, false); - } - }, false) - }; - - let collapse = ():void => { - $elem.removeClass('expanded'); - scope.collapsed = true; - - let element = $(scope.expandedSelector)[0]; - element.style.height = getComputedStyle(element).height; - element.style.transition = 'height .5s ease-in-out'; - element.offsetHeight; // force repaint - element.style.height = '0px'; - element.hidden = true; - }; - - let toggle = ():void => { - if (scope.collapsed === true){ - if(scope.loadDataFunction) { - scope.isLoadingData = true; - let onSuccess = () => { - window.setTimeout(function () { - expand(); - scope.isLoadingData = false; - },0); - }; - scope.loadDataFunction().then(onSuccess); - } - else { - if(scope.isLoadingData === false) { - expand(); - } - } - - } else { - if(scope.isLoadingData === false) { - collapse(); - } - } - } - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new ExpandCollapseDirective($templateCache); - }; - - } - - ExpandCollapseDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.html b/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.html deleted file mode 100644 index 4fbea447e2..0000000000 --- a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.html +++ /dev/null @@ -1,9 +0,0 @@ -<div class="i-sdc-left-sidebar-page-nav"> - <ul data-ng-class="{'expanded': expanded===true}"> - <li data-ng-repeat="item in list | filter:exceptSelectedComparator" - data-ng-click="expanded=false" - class="sidebar-page-nav-item" - ui-sref="{{item.url}}">{{item.name}}</li> - </ul> - <div class="sidebar-page-nav-item-selected" data-ng-click="openCollapse()">{{selected}}<span data-ng-class="{'expanded': expanded===true}"></span></div> -</div> diff --git a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.less b/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.less deleted file mode 100644 index da70218263..0000000000 --- a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.less +++ /dev/null @@ -1,51 +0,0 @@ -.i-sdc-left-sidebar-page-nav { - - height: 64px; - - .sidebar-page-nav-item-selected, - .sidebar-page-nav-item { - .i_11; - background-color: #e0e5e9; - width: 100%; - height: 64px; - border-bottom: solid 1px #cccccc; - line-height: 64px; - text-align: center; - cursor: pointer; - vertical-align: middle; - list-style: none; - padding: 0; - margin: 0; - } - - .sidebar-page-nav-item-selected { - z-index: 1010; - position: absolute; - top: 0px; - } - - .sidebar-page-nav-item-selected span { - .sprite; - .sprite.table-arrow; - position: absolute; - top: 28px; - margin-left: 10px; - - &.expanded { - .sprite; - .sprite.table-arrow.opened; - top: 30px; - } - } - - ul { - position: absolute; - top: 0px; - padding: 0; - width: 100%; - z-index: 99; - visibility: hidden; //Need this and not display none, so I can use the function: getComputedStyle - .box-shadow(0px 4px 2px -2px rgba(0, 0, 0, 0.36)); - } - -} diff --git a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.ts b/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.ts deleted file mode 100644 index c185fe1c15..0000000000 --- a/catalog-ui/app/scripts/directives/utils/page-selector/page-selector.ts +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - class ListItem { - name; - url; - } - - export interface IPageSelectorScope extends ng.IScope { - selected:string; - expanded: boolean; - list:Array<ListItem>; - exceptSelectedComparator(actual, expected):boolean; - openCollapse(); - } - - export class PageSelectorDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - list: '=', - selected: '@', - }; - - public replace = true; - public restrict = 'E'; - public transclude = false; - - private ulElement:HTMLElement; - private itemHeight:number = 64; - - private getUlHeight = ():number => { - let tmp:string = getComputedStyle(this.ulElement).height; - //console.log("tmp: " + tmp); - let ulHeight:number = parseInt(tmp.substr(0,tmp.length-2)); - //console.log("ulHeight: " + ulHeight); - return ulHeight; - }; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/page-selector/page-selector.html'); - }; - - link = (scope:IPageSelectorScope, $elem:any) => { - scope.expanded=false; - - window.setTimeout(() => { - this.ulElement = angular.element(".i-sdc-left-sidebar-page-nav ul")[0]; - console.log("this.ulElement: " + this.ulElement); - console.log("this.itemHeight: " + this.itemHeight); - this.ulElement.style.top = (this.itemHeight - this.getUlHeight() - 5) + 'px'; - this.ulElement.style.visibility = 'visible'; - },10); - - this.ulElement = angular.element(".i-sdc-left-sidebar-page-nav ul")[0]; - - scope.exceptSelectedComparator = (actual) => { - if (actual.name===scope.selected) { - return false; - } - return true; - }; - - scope.openCollapse = ():void => { - scope.expanded=!scope.expanded; - if (scope.expanded===true) { - this.ulElement.style.transition = 'top 0.4s ease-out'; - this.ulElement.style.top = this.itemHeight + 'px'; - } else { - this.ulElement.style.transition = 'top 0.4s ease-in'; - this.ulElement.style.top = (this.itemHeight - this.getUlHeight() - 5) + 'px'; - } - }; - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new PageSelectorDirective($templateCache); - }; - - } - - PageSelectorDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts b/catalog-ui/app/scripts/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts deleted file mode 100644 index 9e61caa812..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISdcKeyboardEventsScope extends ng.IScope { - keyEnter:Function; - keyShift:Function; - keyCtrl:Function; - keyEscape:Function; - keySpace:Function; - } - - export class SdcKeyboardEventsDirective implements ng.IDirective { - - constructor() { - } - - scope = { - keyEnter: '=', - keyShift: '=', - keyCtrl: '=', - keyEscape: '=', - keySpace: '=' - }; - - public replace = false; - public restrict = 'A'; - public transclude = false; - - link = (scope:ISdcKeyboardEventsScope, element:ng.IAugmentedJQuery, attrs:angular.IAttributes) => { - - element.bind("keydown keypress", function (event) { - //console.log(event.which); - switch (event.which) { - case 13: // enter key - scope.$apply(function (){ - if (scope.keyEnter) { - scope.keyEnter(); - event.preventDefault(); - } - }); - break; - case 16: // shift key - scope.$apply(function (){ - if (scope.keyShift) { - scope.keyShift(); - event.preventDefault(); - } - }); - break; - case 17: // ctrl key - scope.$apply(function (){ - if (scope.keyCtrl) { - scope.keyCtrl(); - event.preventDefault(); - } - }); - break; - case 27: // escape key - scope.$apply(function (){ - if (scope.keyEscape) { - scope.keyEscape(); - event.preventDefault(); - } - }); - break; - case 32: // space key - scope.$apply(function (){ - if (scope.keySpace) { - scope.keySpace(); - event.preventDefault(); - } - }); - break; - } - }); - - }; - - public static factory = ()=> { - return new SdcKeyboardEventsDirective(); - }; - - } - - SdcKeyboardEventsDirective.factory.$inject = []; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.ts b/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.ts deleted file mode 100644 index 3f4147c920..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.ts +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISdcTagsScope extends ng.IScope { - tags:Array<string>; - specialTag:string; - newTag:string; - formElement:ng.IFormController; - elementName:string; - pattern:any; - sdcDisabled:boolean; - maxTags:number; - deleteTag(tag:string):void; - addTag(tag:string):void; - validateName():void; - } - - export class SdcTagsDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - tags: '=', - specialTag: '=', - pattern: '=', - sdcDisabled: '=', - formElement: '=', - elementName: '@', - maxTags: '@' - }; - - public replace = false; - public restrict = 'E'; - public transclude = false; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/sdc-tags/sdc-tags.html'); - }; - - link = (scope:ISdcTagsScope, element:ng.INgModelController) => { - - scope.deleteTag = (tag:string):void => { - scope.tags.splice(scope.tags.indexOf(tag),1); - }; - - scope.addTag = ():void => { - let valid = scope.formElement[scope.elementName].$valid; - if (valid && - scope.tags.length<scope.maxTags && - scope.newTag && - scope.newTag!=='' && - scope.tags.indexOf(scope.newTag)===-1 && - scope.newTag!==scope.specialTag) { - scope.tags.push(scope.newTag); - scope.newTag=''; - } - }; - - scope.validateName = ():void => { - if (scope.tags.indexOf(scope.newTag)>-1) { - scope.formElement[scope.elementName].$setValidity('nameExist', false); - }else{ - scope.formElement[scope.elementName].$setValidity('nameExist', true); - } - } - - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcTagsDirective($templateCache); - }; - - } - - SdcTagsDirective.factory.$inject = ['$templateCache']; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.html b/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.html deleted file mode 100644 index 376381b8af..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.html +++ /dev/null @@ -1,6 +0,0 @@ -<div class="i-sdc-form-item-error-message" style="display: none;"> - <span class="i-sdc-form-item-error-icon-open"></span> - <ng-transclude> - - </ng-transclude> -</div> diff --git a/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.ts b/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.ts deleted file mode 100644 index dc30ea7f41..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.ts +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISdcErrorTooltipScope extends ng.IScope { - alignToSelector: string; - topMargin: string; - } - - export class SdcErrorTooltipDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - alignToSelector: '@', // Jquery selector to align to - topMargin: '@' // The margin from the top, in case there is label or not the top margin is different. - }; - - public replace = false; - public restrict = 'E'; - public transclude = true; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/sdc_error_tooltip/sdc_error_tooltip.html'); - }; - - link = (scope:ISdcErrorTooltipScope, $elem:any) => { - let _self = this; - - $elem.addClass("i-sdc-form-item-error-icon"); - - // Calculate the position of the elements after they loaded to the dom. - window.setTimeout(function(){ - _self.calculatePosition(scope, $elem); - },100); - - $elem.bind('mouseover', function(){ - $(".i-sdc-form-item-error-message",$elem).css("display", "block"); - }); - - $elem.bind('mouseleave', function(){ - $(".i-sdc-form-item-error-message",$elem).css("display", "none"); - }); - - } - - private calculatePosition(scope:ISdcErrorTooltipScope, $elem:any):void { - let leftMargin = 13; - let topMargin = scope.topMargin? parseInt(scope.topMargin) : 10; - - if (scope.alignToSelector) { - // Set the position of the error, in case user add align-to-selector attribute - let jObj = $(scope.alignToSelector); - if (jObj.length > 0) { - let height1 = jObj.outerHeight(); - $elem.css('left', jObj.position().left + jObj.outerWidth() + leftMargin); - //$elem.css('top', jObj.position().top + topMargin + (height1 / 2)); - $elem.css('top', jObj.position().top + (height1 / 2) - 5); // Label margin is: 2 - } - } else { - // Set the position of the error, according to the input element. - let inputElm = $elem.siblings('input'); - let textareaElm = $elem.siblings('textarea'); - let selectElm = $elem.siblings('select'); - if (inputElm.length > 0) { - $elem.css('left', inputElm.outerWidth() + leftMargin); - $elem.css('top', inputElm.position().top + topMargin); - } else if (textareaElm.length > 0) { - $elem.css('left', textareaElm.outerWidth() + leftMargin); - let height2 = textareaElm.outerHeight(); - let elmHeight2 = $elem.outerHeight(); - //let top = textareaElm.position().top; - $elem.css('bottom', (height2 - (elmHeight2 / 2)) / 2); - } else if (selectElm.length > 0) { - $elem.css('left', selectElm.outerWidth() + leftMargin); - $elem.css('top', selectElm.position().top + topMargin); - } - } - } - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcErrorTooltipDirective($templateCache); - }; - - } - - SdcErrorTooltipDirective.factory.$inject = ['$templateCache']; - -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-message.ts b/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-message.ts deleted file mode 100644 index d41ef1ce04..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-message.ts +++ /dev/null @@ -1,179 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - export interface ISdcMessageScope extends ng.IScope { - sdcTranslate: string; - sdcTranslateValues:string; - sdcAlign:string; - } - - export class SdcMessageDirective implements ng.IDirective { - - constructor(private $animate:any, private $filter:any, private $parse:any) { - } - - scope = { - field: '=', - required: '@', - pattern: '@', - sdcTranslate: '@', - sdcTranslateValues: '@', - sdcAlign: '@' - }; - - public terminal = true; - public restrict = 'A'; - public transclude = 'element'; - public require = '^^sdcMessages'; - - link = (scope:ISdcMessageScope, $element:any, $attrs:any,sdcMessagesCtrl:any, $transclude:any) => { - let self = this; - - let commentNode = $element[0]; - - let records; - let staticExp = $attrs.sdcMessage || $attrs.when; - let dynamicExp = $attrs.sdcMessageExp || $attrs.whenExp; - let assignRecords = function(items) { - records = items - ? (angular.isArray(items) - ? items - : items.split(/[\s,]+/)) - : null; - sdcMessagesCtrl.reRender(); - }; - - if (dynamicExp) { - assignRecords(scope.$eval(dynamicExp)); - scope.$watchCollection(dynamicExp, assignRecords); - } else { - assignRecords(staticExp); - } - - let currentElement, messageCtrl; - sdcMessagesCtrl.register(commentNode, messageCtrl = { - test: function (name) { - return self.contains(records, name); - }, - attach: function () { - if (!currentElement) { - $transclude(scope, function (elm) { - - self.$animate.enter(elm, null, $element); - currentElement = elm; - - elm.addClass("i-sdc-form-item-error-message"); - - //$compile - let text; - if (scope.sdcTranslate) { - text = self.$filter('translate')(scope.sdcTranslate, scope.sdcTranslateValues); - } else { - //TODO: Need to handle this - //let t = elm.html(); - //let t = angular.element("<span>" + elm.html() + "</span>"); - //text = self.$parse(t); - } - - //scope.sdcTranslateValues - elm.html(text); - - elm.prepend("<span class='error'></span>"); - - // Adding OK to close the message - //let okElm = $('<span />').attr('class', 'ok').html('OK'); - //okElm.click(function(e){ - // messageCtrl.detach(); - //}); - //elm.append(okElm); - - // Handle the position - if (scope.sdcAlign){ - let choosenElm = $(scope.sdcAlign); - if (choosenElm.length > 0) { - let height1 = choosenElm.outerHeight(); - let elmHeight1 = elm.outerHeight(); - elm.css('left', choosenElm.outerWidth()); - elm.css('bottom', (height1 - (elmHeight1 / 2)) / 2); - } - } else { - // Set the position of the error, according to the input element. - let inputElm = elm.parent().siblings('input'); - let textareaElm = elm.parent().siblings('textarea'); - let selectElm = elm.parent().siblings('select'); - if (inputElm.length > 0) { - elm.css('left', inputElm.outerWidth()); - elm.css('top', inputElm.position().top); - } else if (textareaElm.length > 0) { - elm.css('left', textareaElm.outerWidth()); - let height = textareaElm.outerHeight(); - let elmHeight = elm.outerHeight(); - //let top = textareaElm.position().top; - elm.css('bottom', (height - (elmHeight / 2)) / 2); - } else if (selectElm.length > 0) { - elm.css('left', selectElm.outerWidth()); - elm.css('top', selectElm.position().top); - } - } - - // Each time we attach this node to a message we get a new id that we can match - // when we are destroying the node later. - let $$attachId = currentElement.$$attachId = sdcMessagesCtrl.getAttachId(); - - // in the event that the parent element is destroyed - // by any other structural directive then it's time - // to deregister the message from the controller - currentElement.on('$destroy', function () { - if (currentElement && currentElement.$$attachId === $$attachId) { - sdcMessagesCtrl.deregister(commentNode); - messageCtrl.detach(); - } - }); - }); - } - }, - detach: function () { - if (currentElement) { - let elm = currentElement; - currentElement = null; - self.$animate.leave(elm); - } - } - }); - } - - contains = (collection, key):any => { - if (collection) { - return angular.isArray(collection) - ? collection.indexOf(key) >= 0 - : collection.hasOwnProperty(key); - } - } - - public static factory = ($animate:any, $filter:any, $parse:any)=> { - return new SdcMessageDirective($animate, $filter, $parse); - }; - - } - - SdcMessageDirective.factory.$inject = ['$animate', '$filter', '$parse']; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.less b/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.less deleted file mode 100644 index d8dfdbb73b..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.less +++ /dev/null @@ -1,10 +0,0 @@ -.ellipsis-directive-more-less { - .a_9; - .bold; - .hand; - float: right; - margin-right: 17px; - line-height: 23px; - text-decoration: underline; - text-align: left; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.ts b/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.ts deleted file mode 100644 index f8b435b1fa..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc-messages.ts +++ /dev/null @@ -1,245 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - export interface ISdcMessagesScope extends ng.IScope { - sdcMessages: any; - editForm:ng.IFormController; - } - - export class SdcMessagesDirective implements ng.IDirective { - - constructor() {} - - scope = { - sdcMessages: '=' - }; - - public restrict = 'AE'; - public require = 'sdcMessages'; - public controller = SdcMessagesController; - - /*template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/sdc-messages/sdc-messages.html'); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcMessagesDirective($templateCache); - };*/ - - public static factory = ()=> { - return new SdcMessagesDirective(); - } - - } - - export class SdcMessagesController { - - messages:any; - getAttachId:Function; - render:any; - reRender:Function; - register:Function; - deregister:Function; - head:any; - - static '$inject' = [ - '$element', - '$scope', - '$attrs', - '$animate' - ]; - - constructor(private $element:JQuery, - private $scope:ISdcMessagesScope, - private $attrs:ng.IAttributes, - private $animate:any - ) { - - this.init(); - - } - - init=():void => { - let self = this; - - let ACTIVE_CLASS:string = 'ng-active'; - let INACTIVE_CLASS:string = 'ng-inactive'; - - let ctrl = this; - let latestKey = 0; - let nextAttachId = 0; - - this.getAttachId = function getAttachId() { return nextAttachId++; }; - - let messages = this.messages = {}; - let renderLater, cachedCollection; - - this.render = function(collection) { - collection = collection || {}; - - renderLater = false; - cachedCollection = collection; - - // this is true if the attribute is empty or if the attribute value is truthy - let multiple = self.isAttrTruthy(self.$scope, self.$attrs['sdcMessagesMultiple']) || self.isAttrTruthy(self.$scope, self.$attrs['multiple']); - - let unmatchedMessages = []; - let matchedKeys = {}; - let messageItem = ctrl.head; - let messageFound = false; - let totalMessages = 0; - - // we use != instead of !== to allow for both undefined and null values - while (messageItem != null) { - totalMessages++; - let messageCtrl = messageItem.message; - - let messageUsed = false; - if (!messageFound) { - _.each(collection, function(value, key) { - if (!messageUsed && self.truthy(value) && messageCtrl.test(key)) { - // this is to prevent the same error name from showing up twice - if (matchedKeys[key]) return; - matchedKeys[key] = true; - - messageUsed = true; - messageCtrl.attach(); - } - }); - } - - if (messageUsed) { - // unless we want to display multiple messages then we should - // set a flag here to avoid displaying the next message in the list - messageFound = !multiple; - } else { - unmatchedMessages.push(messageCtrl); - } - - messageItem = messageItem.next; - } - - _.each(unmatchedMessages, function(messageCtrl) { - messageCtrl.detach(); - }); - - unmatchedMessages.length !== totalMessages - ? ctrl.$animate.setClass(self.$element, ACTIVE_CLASS, INACTIVE_CLASS) - : ctrl.$animate.setClass(self.$element, INACTIVE_CLASS, ACTIVE_CLASS); - }; - - self.$scope.$watchCollection('sdcMessages' || self.$attrs['for'], function(newVal:any, oldVal:any){ - ctrl.render(newVal); - }); - - this.reRender = function() { - if (!renderLater) { - renderLater = true; - self.$scope.$evalAsync(function() { - if (renderLater) { - cachedCollection && ctrl.render(cachedCollection); - } - }); - } - }; - - this.register = function(comment, messageCtrl) { - let nextKey = latestKey.toString(); - messages[nextKey] = { - message: messageCtrl - }; - insertMessageNode(self.$element[0], comment, nextKey); - comment.$$sdcMessageNode = nextKey; - latestKey++; - - ctrl.reRender(); - }; - - this.deregister = function(comment) { - let key = comment.$$sdcMessageNode; - delete comment.$$sdcMessageNode; - removeMessageNode(self.$element[0], comment, key); - delete messages[key]; - ctrl.reRender(); - }; - - function findPreviousMessage(parent, comment) { - let prevNode = comment; - let parentLookup = []; - while (prevNode && prevNode !== parent) { - let prevKey = prevNode.$$sdcMessageNode; - if (prevKey && prevKey.length) { - return messages[prevKey]; - } - - // dive deeper into the DOM and examine its children for any sdcMessage - // comments that may be in an element that appears deeper in the list - if (prevNode.childNodes.length && parentLookup.indexOf(prevNode) == -1) { - parentLookup.push(prevNode); - prevNode = prevNode.childNodes[prevNode.childNodes.length - 1]; - } else { - prevNode = prevNode.previousSibling || prevNode.parentNode; - } - } - } - - function insertMessageNode(parent, comment, key) { - let messageNode = messages[key]; - if (!ctrl.head) { - ctrl.head = messageNode; - } else { - let match = findPreviousMessage(parent, comment); - if (match) { - messageNode.next = match.next; - match.next = messageNode; - } else { - messageNode.next = ctrl.head; - ctrl.head = messageNode; - } - } - } - - function removeMessageNode(parent, comment, key) { - let messageNode = messages[key]; - - let match = findPreviousMessage(parent, comment); - if (match) { - match.next = messageNode.next; - } else { - ctrl.head = messageNode.next; - } - } - } - - isAttrTruthy = (scope, attr):any => { - return (angular.isString(attr) && attr.length === 0) || //empty attribute - this.truthy(scope.$eval(attr)); - } - - truthy = (val):any => { - return angular.isString(val) ? val.length : !!val; - } - - } - - SdcMessagesDirective.factory.$inject = ['$templateCache','$animate']; -} diff --git a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc_messages.html b/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc_messages.html deleted file mode 100644 index 09b1cad4d2..0000000000 --- a/catalog-ui/app/scripts/directives/utils/sdc_messages/sdc_messages.html +++ /dev/null @@ -1 +0,0 @@ -<span>aaa</span> diff --git a/catalog-ui/app/scripts/directives/utils/smart-tooltip/smart-tooltip.ts b/catalog-ui/app/scripts/directives/utils/smart-tooltip/smart-tooltip.ts deleted file mode 100644 index 49a57245e7..0000000000 --- a/catalog-ui/app/scripts/directives/utils/smart-tooltip/smart-tooltip.ts +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - 'use strict'; - - export interface ISmartTooltipScope extends ng.IScope { - sdcSmartToolip; - } - - export class SmartTooltipDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService, - private $compile:ng.ICompileService) { - } - - public replace = false; - public restrict = 'A'; - public transclude = false; - - public link = (scope:ISmartTooltipScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { - - if ($elem[0].hasAttribute('style')===false){ - $elem[0].setAttribute("style", "overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"); - } else { - let styles = $elem.attr('style'); - $elem[0].setAttribute("style", styles + ";overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"); - } - - $elem.bind('mouseenter', () => { - if($elem[0].offsetWidth < $elem[0].scrollWidth && !$elem.attr('tooltips')){ - $attrs.$set('tooltips', 'tooltips'); - if ($attrs['sdcSmartTooltip'] && $attrs['sdcSmartTooltip'].length>0){ - $elem.attr('tooltip-content', $attrs['sdcSmartTooltip']); - } else { - $attrs.$set('tooltip-content', $elem.text()); - } - - //One possible problem arises when the ngIf is placed on the root element of the template. - //ngIf removes the node and places a comment in it's place. Then it watches over the expression and adds/removes the actual HTML element as necessary. - //The problem seems to be that if it is placed on the root element of the template, then a single comment is what is left from the - //whole template (even if only temporarily), which gets ignored (I am not sure if this is browser-specific behaviour), resulting in an empty template. - - // Remove ng-if attribute and its value (if we reach here, we pass ng-if (ng-if===true), so we can remove it). - $elem.removeAttr('ng-if'); - $elem.removeAttr('data-ng-if'); - - // Remove me (the directive from the element) - let template = $elem[0].outerHTML; - template = template.replace('sdc-smart-tooltip=""',''); - template = template.replace('sdc-smart-tooltip="' + $elem.text() + '"',''); - //console.log(template); - - let el = this.$compile(template)(scope); - console.log(el); - $elem.replaceWith(el); - } - }); - }; - - public static factory = ($templateCache:ng.ITemplateCacheService, $compile:ng.ICompileService)=> { - return new SmartTooltipDirective($templateCache, $compile); - }; - - } - - SmartTooltipDirective.factory.$inject = ['$templateCache', '$compile']; -} diff --git a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.html b/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.html deleted file mode 100644 index 0c9b97a58c..0000000000 --- a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.html +++ /dev/null @@ -1,16 +0,0 @@ -<ul class="sdc-wizard-step"> - <li class="step" data-ng-repeat="step in steps track by $index"> - <div class="step-wrapper"> - <button class="step-index" - data-ng-click="controllerStepClicked(step.name)" - data-ng-class="{'selected': step.selected===true, 'valid': step.valid===true, 'disabled': !step.enabled || step.enabled===false}"> - {{$index+1}} - </button> - <span class="step-name" - data-ng-class="{'selected': step.selected===true, 'valid': step.valid===true, 'disabled': !step.enabled || step.enabled===false}">{{step.name}} - </span> - </div> - <div class="step-seperator"></div> - </li> -</ul> - diff --git a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.less b/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.less deleted file mode 100644 index 8b777923a0..0000000000 --- a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.less +++ /dev/null @@ -1,69 +0,0 @@ -@circle-radius: 18px; -@gap: 70px; -@gap-width: 2px; -@valid-width: 2px; - -ul.sdc-wizard-step { - padding: 0; - margin: 0; - - li.step { - position: relative; - list-style: none; - - .step-wrapper { - line-height: @circle-radius*2; - height: @circle-radius*2; - margin-bottom: @gap; - - button.step-index { - ._w-sdc-wizard-step-btn(@circle-radius); - z-index: 99; - display: inline-block; - - &.valid { - display: inline-block; - } - - } - - span.step-name { - .b_7; - line-height: @circle-radius; - display: inline-block; - word-wrap: break-word; - width: calc(~"100%" - @circle-radius*2 + 4); - vertical-align: middle; - padding-left: 10px; - white-space: normal; - - &.selected { - .a_7; - font-weight: bold; - } - - &.disabled { - border: none; - background-color: transparent; - } - - } - } - - .step-seperator { - border-right: @gap-width solid @color_n; - height: @gap + @circle-radius*2; - position: absolute; - top: @circle-radius*2-@circle-radius; - left: @circle-radius - @gap-width/2; - } - - } - - li.step:last-child { - .step-seperator { - display: none; - } - } - -} diff --git a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.ts b/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.ts deleted file mode 100644 index 9cad36ab78..0000000000 --- a/catalog-ui/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.ts +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Directives { - - 'use strict'; - - export interface IWizardStep { - name: string; - selected?: boolean; - valid?:boolean; - enabled?:boolean; - callback: Function; - } - - export interface ISdcWizardStepScope extends ng.IScope { - steps:Array<IWizardStep>; - control:any; - internalControl:any; - - stepClicked(stepName:string):void; - controllerStepClicked(stepName:string):void; - - setStepValidity(stepName:string, valid:boolean):void; - controllerSetStepValidity(step:IWizardStep, valid:boolean):void; - } - - export interface SdcWizardStepMethods { - unSelectAllSteps():void; - selectStep(step:IWizardStep):void; - } - - export class SdcWizardStepDirective implements ng.IDirective { - - constructor(private $templateCache:ng.ITemplateCacheService) { - } - - scope = { - steps: '=', - control: '=' - }; - - public replace = false; - public restrict = 'E'; - public transclude = true; - public controller = SdcWizardStepDirectiveController; - - template = ():string => { - return this.$templateCache.get('/app/scripts/directives/utils/wizard_steps/sdc-wizard-steps.html'); - }; - - link = (scope:ISdcWizardStepScope, $elem:JQuery, attr:any, controller:SdcWizardStepDirectiveController) => { - scope.internalControl = scope.control || {}; - scope.internalControl.stepClicked = (step:string):void => { - scope.controllerStepClicked(step); - }; - - scope.internalControl.setStepValidity = (step:IWizardStep, valid:boolean):void => { - scope.controllerSetStepValidity(step, valid); - }; - } - - public static factory = ($templateCache:ng.ITemplateCacheService)=> { - return new SdcWizardStepDirective($templateCache); - }; - - } - - SdcWizardStepDirective.factory.$inject = ['$templateCache']; - - export class SdcWizardStepDirectiveController { - static $inject = ['$element', '$scope']; - - methods:SdcWizardStepMethods = <SdcWizardStepMethods>{}; - - constructor(public $element: JQuery, - public $scope: ISdcWizardStepScope) { - - this.initMethods(); - this.initScope(); - } - - private initScope = ():void => { - - this.$scope.controllerStepClicked = (stepName:string):void => { - let selectedStep:IWizardStep = <IWizardStep>_.find(this.$scope.steps, function (item) { - return item.name === stepName; - }); - - if (selectedStep && selectedStep.enabled===true){ - let result:boolean = selectedStep.callback(); - if (result===true){ - this.methods.unSelectAllSteps(); - this.methods.selectStep(selectedStep); - } - } - }; - - this.$scope.controllerSetStepValidity = (step:IWizardStep, valid:boolean):void => { - step.valid=valid; - }; - - }; - - private initMethods = ():void => { - - this.methods.unSelectAllSteps = ():void => { - this.$scope.steps.forEach(function (step) { - step.selected = false; - }); - } - - this.methods.selectStep = (step:IWizardStep):void => { - if (step.enabled===true){ - step.selected=true; - } - } - }; - - } - -} diff --git a/catalog-ui/app/scripts/filters/_category-name-filter.ts b/catalog-ui/app/scripts/filters/_category-name-filter.ts deleted file mode 100644 index 77bbf47684..0000000000 --- a/catalog-ui/app/scripts/filters/_category-name-filter.ts +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class CategoryNameFilter{ - - constructor() { - let filter = <CategoryNameFilter>( (name:string) => { - if(name){ - let newName:string = _.last(name.split('/')); - if (newName){ - return newName; - } - return name; - } - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/capitalize-filter.ts b/catalog-ui/app/scripts/filters/capitalize-filter.ts deleted file mode 100644 index ef0469aaa1..0000000000 --- a/catalog-ui/app/scripts/filters/capitalize-filter.ts +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.Filters { - - export class CapitalizeFilter{ - - constructor() { - let filter = <CapitalizeFilter>( (sentence:string) => { - if (sentence != null) { - let newSentence:string = ""; - let words = sentence.split(' '); - for (let i=0; i < words.length; ++i){ - let word:string = words[i].toLowerCase(); - newSentence += word.substring(0,1).toUpperCase()+word.substring(1) + ' '; - } - return newSentence.trim(); - }else{ - return sentence; - } - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/catalog-status-filter.ts b/catalog-ui/app/scripts/filters/catalog-status-filter.ts deleted file mode 100644 index 5b382f6513..0000000000 --- a/catalog-ui/app/scripts/filters/catalog-status-filter.ts +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -/** - * Created by obarda on 19/08/2015. - */ -module Sdc.Filters { - - export class CatalogStatusFilter{ - - constructor() { - let filter = <CatalogStatusFilter>( (statuses:any) => { - let filtered = []; - angular.forEach(statuses, function(status) { - filtered.push(status); - }); - return filtered; - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/category-icon-filter.ts b/catalog-ui/app/scripts/filters/category-icon-filter.ts deleted file mode 100644 index 6916a13399..0000000000 --- a/catalog-ui/app/scripts/filters/category-icon-filter.ts +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class CategoryIconFilter{ - - constructor() { - let filter = <CategoryIconFilter>( (category:string) => { - let map = { - 'Application Layer 4+/Application Servers': ['applicationServer', 'server'], - 'Application Layer 4+/Media Servers': ['applicationServer', 'server'], - 'Application Layer 4+/Web Server': ['applicationServer', 'server'], - 'Network Layer 4+/Common Network Resources': ['network', 'loadBalancer'], - 'Generic/Infrastructure': ['objectStorage', 'compute'], - 'Generic/Network Elements': ['port', 'network', 'router'], - 'Application Layer 4+/Database': ['database'], - 'Generic/Database': ['database'], - 'Network Layer 2-3/Router': ['router'], - 'Network Layer 2-3/Gateway': ['gateway'], - 'Network Layer 2-3/LAN Connectors': ['connector'], - 'Network Layer 2-3/WAN Connectors': ['connector'], - 'Application Layer 4+/Border Elements': ['borderElement'], - 'Application Layer 4+/Load Balancer': ['loadBalancer'], - 'Application Layer 4+/Call Control': ['call_controll'], - 'VoIP Call Control': ['call_controll'], - 'Mobility': ['mobility'], - 'Network L1-3': ['network_l_1-3'], - 'Network L4': ['network_l_4'] - } - return map[category]; - - }); - return filter; - } - } -} diff --git a/catalog-ui/app/scripts/filters/category-type-filter.ts b/catalog-ui/app/scripts/filters/category-type-filter.ts deleted file mode 100644 index 482e566e5a..0000000000 --- a/catalog-ui/app/scripts/filters/category-type-filter.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class CategoryTypeFilter { - - static $inject = ['Sdc.Services.CacheService']; - - constructor(cacheService:Services.CacheService) { - let filter = <CategoryTypeFilter> (categories:any, selectedType:Array<string>) => { - - if (!selectedType.length) - return categories; - - let filteredCategories:any = []; - selectedType.forEach((type:string) => { - filteredCategories = filteredCategories.concat(cacheService.get(type.toLowerCase() + 'Categories')); - }); - - return _.filter(categories, function (category:any) { - return filteredCategories.indexOf(category) != -1; - }); - }; - return filter; - } - } -} diff --git a/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts b/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts deleted file mode 100644 index 63f0d780be..0000000000 --- a/catalog-ui/app/scripts/filters/graph-resource-name-filter.ts +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class GraphResourceNameFilter { - - - constructor() { - let filter = <GraphResourceNameFilter>( (name:string) => { - let context = document.createElement("canvas").getContext("2d"); - context.font = "13px Arial"; - - if(67 < context.measureText(name).width) { - let newLen = name.length - 3; - let newName = name.substring(0, newLen); - - while (59 < (context.measureText(newName).width)) { - newName = newName.substring(0, (--newLen)); - } - return newName + '...'; - } - - return name; - }); - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts b/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts deleted file mode 100644 index 66d7a76c28..0000000000 --- a/catalog-ui/app/scripts/filters/product-subcategory-name-filter.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.Filters { - - export class ProductSubCategoryNameFilter{ - - constructor() { - let filter = <CategoryNameFilter>( (name:string) => { - if(name){ - let newName:string = _.last(name.split('/')); - if (newName){ - return newName; - } - return name; - } - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/relation-name-fllter.ts b/catalog-ui/app/scripts/filters/relation-name-fllter.ts deleted file mode 100644 index 7d97eea372..0000000000 --- a/catalog-ui/app/scripts/filters/relation-name-fllter.ts +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class RelationNameFilter{ - - constructor() { - let filter = <RelationNameFilter>( (relationshipType:string) => { - let icons: Array<string> = [ - 'AttachesTo', - 'BindsTo', - 'DependsOn', - 'HostedOn', - 'LinksTo', - 'RoutesTo' - ]; - - let result:string = 'ConnectedTo'; - - if (relationshipType) { - let arr = relationshipType.split('.'); // looks like tosca.relationships.AttachesTo - relationshipType = arr[arr.length - 1]; - if (icons.indexOf(relationshipType) > -1) { - result = relationshipType; - } - } - - return result; - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/filters/resource-type-filter.ts b/catalog-ui/app/scripts/filters/resource-type-filter.ts deleted file mode 100644 index 6aa79dae76..0000000000 --- a/catalog-ui/app/scripts/filters/resource-type-filter.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class ResourceTypeFilter{ - static '$inject' = ['Sdc.Services.CacheService']; - constructor(cacheService:Services.CacheService) - { - let filter = <ResourceTypeFilter> (resourceType:string) => { - let uiConfiguration:any = cacheService.get('UIConfiguration'); - - if(uiConfiguration.resourceTypes && uiConfiguration.resourceTypes[resourceType]){ - return uiConfiguration.resourceTypes[resourceType]; - } - return resourceType; - } - return filter; - } - } -} diff --git a/catalog-ui/app/scripts/filters/string-to-date-filter.ts b/catalog-ui/app/scripts/filters/string-to-date-filter.ts deleted file mode 100644 index 1c4919d419..0000000000 --- a/catalog-ui/app/scripts/filters/string-to-date-filter.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class StringToDateFilter{ - - constructor() { - let filter = <StringToDateFilter>( (date:string) => { - if(date){ - return new Date(date.replace(" UTC", '').replace(" ", 'T') + '+00:00'); - } - }); - return filter; - } - } -} diff --git a/catalog-ui/app/scripts/filters/truncate-filter.ts b/catalog-ui/app/scripts/filters/truncate-filter.ts deleted file mode 100644 index 1470e5937d..0000000000 --- a/catalog-ui/app/scripts/filters/truncate-filter.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.Filters { - - export class TruncateFilter { - constructor() { - let filter = <TruncateFilter> (str:string, length:number) => { - if (str.length <= length) { - return str; - } - - //if(str[length - 1] === ' '){ - // return str.substring(0, length - 1) + '...'; - //} - - let char; - let index = length; - while (char !== ' ' && index !== 0) { - index--; - char = str[index]; - } - if (index === 0) { - return (index === 0) ? str : str.substring(0, length - 3) + '...'; - } - return (index === 0) ? str : str.substring(0, index) + '...'; - }; - return filter; - } - - } -} diff --git a/catalog-ui/app/scripts/filters/underscoreless-filter.ts b/catalog-ui/app/scripts/filters/underscoreless-filter.ts deleted file mode 100644 index 6849a36f04..0000000000 --- a/catalog-ui/app/scripts/filters/underscoreless-filter.ts +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.Filters { - - export class UnderscoreLessFilter{ - - constructor() { - let filter = <UnderscoreLessFilter>( (sentence:string) => { - return sentence.replace(/_/g, ' '); - }); - - return filter; - } - } - -} diff --git a/catalog-ui/app/scripts/models/activity.ts b/catalog-ui/app/scripts/models/activity.ts deleted file mode 100644 index 4f8648d6b7..0000000000 --- a/catalog-ui/app/scripts/models/activity.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 19/11/2015. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - /*this is in uppercase because of the server response*/ - export class Activity{ - TIMESTAMP: string; - ACTION:string; - MODIFIER:string; - STATUS:string; - DESC:string; - COMMENT:string; - //custom data - public dateFormat:string; - - constructor() { - } - public toJSON = ():any => { - this.dateFormat = undefined; - return this; - }; - - } -} - - diff --git a/catalog-ui/app/scripts/models/app-config.ts b/catalog-ui/app/scripts/models/app-config.ts deleted file mode 100644 index f0a316fc92..0000000000 --- a/catalog-ui/app/scripts/models/app-config.ts +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - - 'use strict'; - export interface IApi { - baseUrl:string; - - //***** NEW API *******// - GET_component: string; - PUT_component: string; - GET_component_validate_name: string; - POST_changeLifecycleState: string; - component_api_root:string; - welcome_page_video_url:string; - //*********// - - GET_user: string; - GET_user_authorize: string; - GET_all_users: string; - POST_create_user; - DELETE_delete_user; - POST_edit_user_role; - GET_resource: string; - GET_resources_latestversion_notabstract:string; - GET_resources_certified_not_abstract: string; - GET_resources_certified_abstract: string; - PUT_resource: string; - GET_resource_property: string; - GET_resource_artifact:string; - GET_download_instance_artifact:string; - POST_instance_artifact:string; - GET_resource_additional_information:string; - GET_service_artifact:string; - GET_resource_interface_artifact:string; - GET_resource_api_artifact:string; - GET_resource_validate_name: string; - GET_resource_artifact_types: string; - GET_activity_log: string; - GET_configuration_ui: string; - GET_service: string; - PUT_product: string; - GET_product: string; - GET_ecomp_menu_items: string; - GET_product_validate_name: string; - GET_service_validate_name: string; - GET_service_distributions: string; - GET_service_distributions_components: string; - POST_service_distribution_deploy: string; - GET_element: string; - GET_catalog: string; - GET_resource_category: string; - GET_service_category: string; - resource_instance: string; - GET_resource_instance_property: string; - GET_relationship:string; - GET_lifecycle_state_resource:string; - GET_lifecycle_state_CHECKIN:string; - GET_lifecycle_state_CERTIFICATIONREQUEST:string; - GET_lifecycle_state_UNDOCHECKOUT:string; - root: string; - PUT_service: string; - GET_download_artifact: string; - GET_SDC_Version: string; - GET_categories: string; - POST_category: string; - POST_subcategory: string; - POST_change_instance_version: string; - GET_requirements_capabilities: string; - GET_onboarding: string; - GET_component_from_csar_uuid: string; - kibana:string; - - //Added by Ikram -- starts - GET_product_category: string; - GET_product_category_temp: string; - GET_product_sub_category: string; - //Added by Ikram -- ends - - } - - export interface ILogConfig { - minLogLevel: string; - prefix: string; - } - - export interface ICookie { - junctionName: string; - prefix: string; - userIdSuffix: string; - userFirstName: string; - userLastName: string; - userEmail: string; - } - export interface IUserTypes { - admin: any; - designer: any; - tester: any; - } - - export interface IConfigStatuses { - inDesign: IConfigStatus; - readyForCertification: IConfigStatus; - inCertification: IConfigStatus; - certified: IConfigStatus; - distributed: IConfigStatus; - - } - - export interface IConfigStatus { - name: string; - values: Array<string>; - } - - export interface IConfigRoles { - ADMIN: IConfigRole; - DESIGNER: IConfigRole; - TESTER: IConfigRole; - OPS: IConfigRole; - GOVERNOR: IConfigRole; - PRODUCT_MANAGER: IConfigRole; - PRODUCT_STRATEGIST: IConfigRole; - } - - export interface IConfigRole { - pages: Array<string>; - states: IConfigState; - } - - export interface IConfigState { - NOT_CERTIFIED_CHECKOUT: Array<IConfigDistribution>; - NOT_CERTIFIED_CHECKIN: Array<IConfigDistribution>; - READY_FOR_CERTIFICATION: Array<IConfigDistribution>; - CERTIFICATION_IN_PROGRESS: Array<IConfigDistribution>; - CERTIFIED: Array<IConfigDistribution>; - } - - export interface IConfigDistribution { - DISTRIBUTION_NOT_APPROVED: Array<ConfigMenuItem>; - DISTRIBUTION_APPROVED: Array<ConfigMenuItem>; - DISTRIBUTED: Array<ConfigMenuItem>; - DISTRIBUTION_REJECTED: Array<ConfigMenuItem>; - } - - export interface IConfirmationMessage { - showComment: boolean; - title: string; - message: string; - } - - export interface IConfirmationMessages { - checkin: IConfirmationMessage; - checkout: IConfirmationMessage; - certify: IConfirmationMessage; - failCertification: IConfirmationMessage; - certificationRequest: IConfirmationMessage; - approve: IConfirmationMessage; - reject: IConfirmationMessage; - } - - export interface IAlertMessage { - title: string; - message: string; - } - - export interface IAlertMessages { - deleteInstance: IAlertMessage; - exitWithoutSaving: IConfirmationMessage; - } - - class ConfigMenuItem { - text:string; - action:string; - url:string; - disable:boolean = false; - } - - export interface IAppConfigurtaion { - environment:string; - api: IApi; - resourceTypesFilter:IResourceTypesFilter; - logConfig: ILogConfig; - cookie: ICookie; - imagesPath: string; - toscaFileExtension:string; - csarFileExtension:string; - testers: Array<ITester> - tutorial:any; - roles: Array<string>; - cpEndPointInstances: Array<string>; - openSource:boolean; - } - export interface IResourceTypesFilter { - resource: Array<string>; - } - - export interface ITester { - email: string; - } - - export interface IAppMenu { - roles: IConfigRoles; - confirmationMessages: IConfirmationMessages; - alertMessages: IAlertMessages; - statuses: IConfigStatuses; - catalogMenuItem: any; - categoriesDictionary:any; - canvas_buttons:Object; - component_workspace_menu_option: any; - LifeCycleStatuses: any; - DistributionStatuses: any; - ChangeLifecycleStateButton:any; - } -} diff --git a/catalog-ui/app/scripts/models/artifacts.ts b/catalog-ui/app/scripts/models/artifacts.ts deleted file mode 100644 index 8ee98d90d1..0000000000 --- a/catalog-ui/app/scripts/models/artifacts.ts +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - //this object contains keys, each key contain ArtifactModel - export class ArtifactGroupModel{ - constructor(artifacts?:Models.ArtifactGroupModel) { - _.forEach(artifacts, (artifact:Models.ArtifactModel, key) => { - this[key] = new Models.ArtifactModel(artifact); - }); - } - - public filteredByType (type:string): Models.ArtifactGroupModel { - return JSON.parse(JSON.stringify(_.pick(this, (artifact)=>{ return artifact.artifactType == type}))); - }; - } - - export class ArtifactModel { - - artifactDisplayName:string; - artifactGroupType:string; - uniqueId:string; - artifactName:string; - artifactLabel:string; - artifactType:string; - artifactUUID:string; - artifactVersion:string; - creatorFullName:string; - creationDate:number; - lastUpdateDate:number; - description:string; - mandatory:boolean; - serviceApi:boolean; - payloadData:string; - timeout:number; - esId:string; - "Content-MD5":string; - artifactChecksum:string; - apiUrl:string; - heatParameters:Array<any>; - generatedFromId:string; - - //custom properties - selected:boolean; - originalDescription:string; - - constructor(artifact?:ArtifactModel) { - if(artifact) { - this.artifactDisplayName = artifact.artifactDisplayName; - this.artifactGroupType = artifact.artifactGroupType; - this.uniqueId = artifact.uniqueId; - this.artifactName = artifact.artifactName; - this.artifactLabel = artifact.artifactLabel; - this.artifactType = artifact.artifactType; - this.artifactUUID = artifact.artifactUUID; - this.artifactVersion = artifact.artifactVersion; - this.creatorFullName = artifact.creatorFullName; - this.creationDate = artifact.creationDate; - this.lastUpdateDate = artifact.lastUpdateDate; - this.description = artifact.description; - this.mandatory = artifact.mandatory; - this.serviceApi = artifact.serviceApi; - this.payloadData = artifact.payloadData; - this.timeout = artifact.timeout; - this.esId = artifact.esId; - this["Content-MD5"] = artifact["Content-MD5"]; - this.artifactChecksum = artifact.artifactChecksum; - this.apiUrl = artifact.apiUrl; - this.heatParameters = _.sortBy(artifact.heatParameters, 'name'); - this.generatedFromId = artifact.generatedFromId; - this.selected = artifact.selected ? artifact.selected : false; - this.originalDescription = artifact.description; - } - } - - public isHEAT = ():boolean => { - return Utils.Constants.ArtifactType.HEAT === this.artifactType.substring(0,4); - }; - - // public isEditableInInstanceLevel = ():boolean => { - // return true; - // }; - - public isThirdParty = ():boolean => { - return _.has(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType); - }; - - public toJSON = ():any => { - this.selected = undefined; - this.originalDescription = undefined; - return this; - }; - } -} - - diff --git a/catalog-ui/app/scripts/models/aschema-property.ts b/catalog-ui/app/scripts/models/aschema-property.ts deleted file mode 100644 index 7ecc85c302..0000000000 --- a/catalog-ui/app/scripts/models/aschema-property.ts +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by osonsino on 16/05/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class SchemaPropertyGroupModel{ - property: SchemaProperty; - - constructor(schemaProperty?:Models.SchemaProperty) { - this.property = schemaProperty; - } - } - - export class SchemaProperty { - - type: string; - required: boolean; - definition: boolean; - description: string; - password: boolean; - //custom properties - simpleType: string; - - constructor(schemaProperty?:SchemaProperty) { - if(schemaProperty) { - this.type = schemaProperty.type; - this.required = schemaProperty.required; - this.definition = schemaProperty.definition; - this.description = schemaProperty.description; - this.password = schemaProperty.password; - this.simpleType = schemaProperty.simpleType; - } - } - - public toJSON = ():any => { - this.simpleType = undefined; - return this; - }; - } -} - - diff --git a/catalog-ui/app/scripts/models/attributes.ts b/catalog-ui/app/scripts/models/attributes.ts deleted file mode 100644 index ea4c7a5a23..0000000000 --- a/catalog-ui/app/scripts/models/attributes.ts +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class AttributesGroup { - constructor(attributesObj?:Models.AttributesGroup) { - _.forEach(attributesObj, (attributes:Array<Models.AttributeModel>, instance) => { - this[instance] = []; - _.forEach(attributes, (attribute:Models.AttributeModel):void => { - attribute.resourceInstanceUniqueId = instance; - attribute.readonly = true; - this[instance].push(new Models.AttributeModel(attribute)); - }); - }); - } - } - - export interface IAttributeModel { - - //server data - uniqueId:string; - name:string; - defaultValue:string; - description:string; - type:string; - schema:Models.SchemaAttributeGroupModel; - status:string; - value:string; - hidden:boolean; - parentUniqueId:string; - //custom data - resourceInstanceUniqueId:string; - readonly:boolean; - valueUniqueUid:string; - } - - export class AttributeModel implements IAttributeModel { - - //server data - uniqueId:string; - name:string; - defaultValue:string; - description:string; - type:string; - schema:Models.SchemaAttributeGroupModel; - status:string; - value:string; - hidden:boolean; - parentUniqueId:string; - //custom data - resourceInstanceUniqueId:string; - readonly:boolean; - valueUniqueUid:string; - - constructor(attribute?:Models.AttributeModel) { - if (attribute) { - this.uniqueId = attribute.uniqueId; - this.name = attribute.name; - this.defaultValue = attribute.defaultValue; - this.description = attribute.description; - this.type = attribute.type; - this.status = attribute.status; - this.schema = attribute.schema; - this.value = attribute.value; - this.hidden = attribute.hidden; - this.parentUniqueId = attribute.parentUniqueId; - this.resourceInstanceUniqueId = attribute.resourceInstanceUniqueId; - this.readonly = attribute.readonly; - this.valueUniqueUid = attribute.valueUniqueUid; - } - - if (!this.schema || !this.schema.property) { - this.schema = new Models.SchemaPropertyGroupModel(new Models.SchemaProperty()); - } else { - //forcing creating new object, so editing different one than the object in the table - this.schema = new Models.SchemaAttributeGroupModel(new Models.SchemaAttribute(this.schema.property)); - } - - this.convertValueToView(); - } - - public convertToServerObject:Function = ():string => { - if (this.defaultValue && this.type === 'map') { - this.defaultValue = '{' + this.defaultValue + '}'; - } - if (this.defaultValue && this.type === 'list') { - this.defaultValue = '[' + this.defaultValue + ']'; - } - this.defaultValue = this.defaultValue != "" && this.defaultValue != "[]" && this.defaultValue != "{}" ? this.defaultValue : null; - - return JSON.stringify(this); - }; - - - public convertValueToView() { - //unwrapping value {} or [] if type is complex - if (this.defaultValue && (this.type === 'map' || this.type === 'list') && - ['[', '{'].indexOf(this.defaultValue.charAt(0)) > -1 && - [']', '}'].indexOf(this.defaultValue.slice(-1)) > -1) { - this.defaultValue = this.defaultValue.slice(1, -1); - } - - //also for value - for the modal in canvas - if (this.value && (this.type === 'map' || this.type === 'list') && - ['[', '{'].indexOf(this.value.charAt(0)) > -1 && - [']', '}'].indexOf(this.value.slice(-1)) > -1) { - this.value = this.value.slice(1, -1); - } - } - - public toJSON = ():any => { - if (!this.resourceInstanceUniqueId) { - this.value = undefined; - } - this.readonly = undefined; - this.resourceInstanceUniqueId = undefined; - return this; - }; - } -} diff --git a/catalog-ui/app/scripts/models/capability.ts b/catalog-ui/app/scripts/models/capability.ts deleted file mode 100644 index 815be5a389..0000000000 --- a/catalog-ui/app/scripts/models/capability.ts +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 4/20/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - //this is an object contains keys, when each key has matching array. - // for example: key = tosca.capabilities.network.Linkable and the match array is array of capabilities objects - export class CapabilitiesGroup { - constructor(capabilityGroupObj?:Models.CapabilitiesGroup) { - _.forEach(capabilityGroupObj, (capabilitiesArrayObj:Array<Models.Capability>, instance) => { - this[instance] = []; - _.forEach(capabilitiesArrayObj, (capability:Models.Capability):void => { - this[instance].push(new Models.Capability(capability)); - }); - }); - } - - public findValueByKey(keySubstring:string):Array<Models.Capability> { - let key:string = _.find(Object.keys(this), (key)=> { - return _.includes(key.toLowerCase(), keySubstring); - }); - return this[key]; - } - } - - export class Capability { - - //server data - name:string; - ownerId:string; - ownerName:string; - type:string; - uniqueId:string; - capabilitySources:Array<String>; - minOccurrences:string; - maxOccurrences:string; - properties:Array<Models.PropertyModel>; - description:string; - validSourceTypes:Array<string>; - //custom - selected:boolean; - filterTerm:string; - - constructor(capability?:Capability) { - - if (capability) { - //server data - this.name = capability.name; - this.ownerId = capability.ownerId; - this.ownerName = capability.ownerName; - this.type = capability.type; - this.uniqueId = capability.uniqueId; - this.capabilitySources = capability.capabilitySources; - this.minOccurrences = capability.minOccurrences; - this.maxOccurrences = capability.maxOccurrences; - this.properties = capability.properties; - this.description = capability.description; - this.validSourceTypes = capability.validSourceTypes; - this.selected = capability.selected; - this.initFilterTerm(); - - } - } - - public getFullTitle():string { - let maxOccurrences:string = this.maxOccurrences === 'UNBOUNDED' ? '∞' : this.maxOccurrences; - return this.ownerName + ': ' + this.name + ': [' + this.minOccurrences + ', ' + maxOccurrences + ']'; - } - - public toJSON = ():any => { - this.selected = undefined; - this.filterTerm = undefined; - return this; - }; - - private initFilterTerm = ():void =>{ - this.filterTerm = this.name + " " + - (this.type ? (this.type.substring("tosca.capabilities.".length) + " " ) : "") + - (this.description||"") + " " + - (this.ownerName||"") + " " + - (this.validSourceTypes ? (this.validSourceTypes.join(',') + " ") : "") + - this.minOccurrences+","+this.maxOccurrences; - if(this.properties && this.properties.length){ - _.forEach(this.properties,(prop:Models.PropertyModel)=>{ - this.filterTerm += " "+ prop.name + - " " + (prop.description||"") + - " " + prop.type + - (prop.schema && prop.schema.property?(" " + prop.schema.property.type):""); - }); - } - } - } -} - - diff --git a/catalog-ui/app/scripts/models/category.ts b/catalog-ui/app/scripts/models/category.ts deleted file mode 100644 index 730460cbc0..0000000000 --- a/catalog-ui/app/scripts/models/category.ts +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class ICategoryBase { - - //server properties - name: string; - normalizedName: string; - uniqueId:string; - icons: Array<string>; - - //custom properties - filterTerms: string; - isDisabled: boolean; - filteredGroup: Array<Models.IGroup>; - - constructor(category?: ICategoryBase){ - if (category) { - this.name = category.name; - this.normalizedName = category.normalizedName; - this.icons = category.icons; - this.filterTerms = category.filterTerms; - this.isDisabled = category.isDisabled; - this.filteredGroup = category.filteredGroup; - } - } - } - - export class IMainCategory extends ICategoryBase { - subcategories:Array<ISubCategory>; - constructor(); - constructor(category?: IMainCategory){ - super(category); - if (category) { - this.subcategories = category.subcategories; - } - } - } - - export class ISubCategory extends ICategoryBase { - groupings:Array<ICategoryBase>; - } - - export interface IGroup extends ICategoryBase { - } - -} diff --git a/catalog-ui/app/scripts/models/components/component.ts b/catalog-ui/app/scripts/models/components/component.ts deleted file mode 100644 index c0fb3a9fbb..0000000000 --- a/catalog-ui/app/scripts/models/components/component.ts +++ /dev/null @@ -1,828 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.Components { - 'use strict'; - import Util = jasmine.Util; - - export interface IComponent { - - //---------------------------------------------- API CALLS ----------------------------------------------------// - - //Component API - getComponent():ng.IPromise<Models.Components.Component>; - updateComponent():ng.IPromise<Models.Components.Component>; - createComponentOnServer():ng.IPromise<Models.Components.Component>; - changeLifecycleState(state:string, commentObj:Models.AsdcComment):ng.IPromise<Models.Components.Component>; - validateName(newName:string):ng.IPromise<Models.IValidate>; - updateRequirementsCapabilities():ng.IPromise<any>; - - //Artifacts API - addOrUpdateArtifact(artifact:ArtifactModel):ng.IPromise<Models.ArtifactModel>; - updateMultipleArtifacts(artifacts:Array<Models.ArtifactModel>):ng.IPromise<any>; - deleteArtifact(artifactId:string, artifactLabel:string):ng.IPromise<Models.ArtifactModel>; - downloadInstanceArtifact(artifactId:string):ng.IPromise<Models.IFileDownload>; - downloadArtifact(artifactId:string):ng.IPromise<Models.IFileDownload>; - - //Property API - addOrUpdateProperty(property:Models.PropertyModel):ng.IPromise<Models.PropertyModel>; - deleteProperty(propertyId:string):ng.IPromise<Models.PropertyModel>; - updateInstanceProperty(property:Models.PropertyModel):ng.IPromise<Models.PropertyModel>; - - //Attribute API - deleteAttribute(attributeId:string):ng.IPromise<Models.AttributeModel>; - addOrUpdateAttribute(attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel>; - updateInstanceAttribute(attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel>; - - - - - //Component Instance API - createComponentInstance(componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - deleteComponentInstance(componentInstanceId:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - addOrUpdateInstanceArtifact(artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel>; - deleteInstanceArtifact(artifactId:string, artifactLabel:string):ng.IPromise<Models.ArtifactModel>; - uploadInstanceEnvFile(artifact:Models.ArtifactModel): ng.IPromise<Models.ArtifactModel>; - changeComponentInstanceVersion(componentUid:string):ng.IPromise<Models.Components.Component>; - updateComponentInstance(componentInstance:Models.ComponentsInstances.ComponentInstance): ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - updateMultipleComponentInstances(instances: Array<Models.ComponentsInstances.ComponentInstance>):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>>; - - //Inputs API - getComponentInstanceInputProperties(componentInstanceId: string, inputId: string):ng.IPromise<Array<Models.PropertyModel>> - getComponentInputs(componentId: string):ng.IPromise<Array<Models.InputModel>>; - - createRelation(link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel>; - deleteRelation(link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel>; - - - //Modules - getModuleForDisplay(moduleId:string):ng.IPromise<Models.DisplayModule>; - updateGroupMetadata(group:Models.Module):ng.IPromise<Models.Module>; - //---------------------------------------------- HELP FUNCTIONS ----------------------------------------------------// - - getComponentSubType():string; - isAlreadyCertified():boolean; - isProduct():boolean; - isService():boolean; - isResource():boolean; - isComplex():boolean; - getAdditionalInformation():Array<Models.AdditionalInformationModel>; - getAllVersionsAsSortedArray():Array<any>; - getStatus(sdcMenu:Models.IAppMenu):string; - } - - - export class Component implements IComponent { - - //server data - public abstract:string; - public uniqueId:string; - public uuid:string; - public invariantUUID:string; - public name:string; - public version:string; - public creationDate:number; - public lastUpdateDate:number; - public description:string; - public lifecycleState:string; - public tags:Array<string>; - public icon:string; - public contactId:string; - public allVersions:any; - public creatorUserId:string; - public creatorFullName:string; - public lastUpdaterUserId:string; - public lastUpdaterFullName:string; - public componentType:string; - public deploymentArtifacts:Models.ArtifactGroupModel; - public artifacts:Models.ArtifactGroupModel; - public toscaArtifacts:Models.ArtifactGroupModel; - public distributionStatus:string; - public categories:Array<Models.IMainCategory>; - public componentInstancesProperties:Models.PropertiesGroup; - public componentInstancesAttributes:Models.AttributesGroup; - public componentInstancesRelations:Array<Models.RelationshipModel>; - public componentInstances:Array<Models.ComponentsInstances.ComponentInstance>; - public inputs:Array<Models.InputModel>; - public capabilities:Models.CapabilitiesGroup; - public requirements:Models.RequirementsGroup; - public additionalInformation:any; - public properties:Array<Models.PropertyModel>; - public attributes:Array<Models.AttributeModel>; - public highestVersion:boolean; - public vendorName:string; - public vendorRelease:string; - public derivedList:Array<any>; - public interfaces:any; - public normalizedName:string; - public systemName:string; - public projectCode:string; - public groups:Array<Models.Module>; - //custom properties - public componentService:Sdc.Services.Components.IComponentService; - public filterTerm:string; - public iconSprite:string; - public selectedInstance:Models.ComponentsInstances.ComponentInstance; - public mainCategory:string; - public subCategory:string; - public selectedCategory:string; - public showMenu:boolean; - - - constructor(componentService:Sdc.Services.Components.IComponentService, - protected $q:ng.IQService, - component?:Component) { - if (component) { - this.abstract = component.abstract; - this.uniqueId = component.uniqueId; - this.uuid = component.uuid; - this.invariantUUID = component.invariantUUID; - this.additionalInformation = component.additionalInformation; - this.artifacts = new Sdc.Models.ArtifactGroupModel(component.artifacts); - this.toscaArtifacts = new Sdc.Models.ArtifactGroupModel(component.toscaArtifacts); - this.contactId = component.contactId; - this.categories = component.categories; - this.creatorUserId = component.creatorUserId; - this.creationDate = component.creationDate; - this.creatorFullName = component.creatorFullName; - this.description = component.description; - this.icon = component.icon; - this.lastUpdateDate = component.lastUpdateDate; - this.lastUpdaterUserId = component.lastUpdaterUserId; - this.lastUpdaterFullName = component.lastUpdaterFullName; - this.lifecycleState = component.lifecycleState; - this.initComponentInstanceRelations(component.componentInstancesRelations); - this.componentInstancesProperties = new Models.PropertiesGroup(component.componentInstancesProperties); - this.componentInstancesAttributes = new Models.AttributesGroup(component.componentInstancesAttributes); - this.name = component.name; - this.version = component.version; - this.tags = component.tags; - this.capabilities = new Models.CapabilitiesGroup(component.capabilities); - this.requirements = new Models.RequirementsGroup(component.requirements); - this.allVersions = component.allVersions; - this.deploymentArtifacts = new Sdc.Models.ArtifactGroupModel(component.deploymentArtifacts); - this.componentType = component.componentType; - this.distributionStatus = component.distributionStatus; - this.highestVersion = component.highestVersion; - this.vendorName = component.vendorName; - this.vendorRelease = component.vendorRelease; - this.derivedList = component.derivedList; - this.interfaces = component.interfaces; - this.normalizedName = component.normalizedName; - this.systemName = component.systemName; - this.projectCode = component.projectCode; - this.inputs = component.inputs; - this.componentInstances = Utils.CommonUtils.initComponentInstances(component.componentInstances); - this.properties = Utils.CommonUtils.initProperties(component.properties, this.uniqueId); - this.attributes = Utils.CommonUtils.initAttributes(component.attributes, this.uniqueId); - this.selectedInstance = component.selectedInstance; - this.iconSprite = component.iconSprite; - this.showMenu = true; - this.groups = Utils.CommonUtils.initModules(component.groups); - } - - //custom properties - this.componentService = componentService; - } - - public setUniqueId = (uniqueId:string):void => { - this.uniqueId = uniqueId; - }; - - public setSelectedInstance = (componentInstance:Models.ComponentsInstances.ComponentInstance):void => { - this.selectedInstance = componentInstance; - }; - - //------------------------------------------ Init Functions ----------------------------------------------------------------// - - private initComponentInstanceRelations = (componentInstanceRelationsObj:Array<Models.RelationshipModel>):void => { - if (componentInstanceRelationsObj) { - this.componentInstancesRelations = []; - _.forEach(componentInstanceRelationsObj, (instanceRelation:Models.RelationshipModel):void => { - this.componentInstancesRelations.push(new Models.RelationshipModel(instanceRelation)); - }); - } - }; - //----------------------------------------------------------------------------------------------------------------------// - - //------------------------------------------ API Calls ----------------------------------------------------------------// - public changeLifecycleState = (state:string, commentObj:Models.AsdcComment):ng.IPromise<Models.Components.Component> => { - return this.componentService.changeLifecycleState(this, state, JSON.stringify(commentObj)); - }; - - public getComponent = ():ng.IPromise<Models.Components.Component> => { - return this.componentService.getComponent(this.uniqueId); - }; - - public createComponentOnServer = ():ng.IPromise<Models.Components.Component> => { - this.handleTags(); - return this.componentService.createComponent(this); - }; - - public updateComponent = ():ng.IPromise<Models.Components.Component> => { - this.handleTags(); - return this.componentService.updateComponent(this); - }; - - public validateName = (newName:string, subtype?:string):ng.IPromise<Models.IValidate> => { - return this.componentService.validateName(newName, subtype); - }; - - public downloadArtifact = (artifactId:string):ng.IPromise<Models.IFileDownload> => { - return this.componentService.downloadArtifact(this.uniqueId, artifactId); - }; - - public addOrUpdateArtifact = (artifact:ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let onSuccess = (artifactObj:Models.ArtifactModel):void => { - let newArtifact = new Models.ArtifactModel(artifactObj); - let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType); - artifacts[artifactObj.artifactLabel] = newArtifact; - deferred.resolve(newArtifact); - }; - let onError = (error:any):void => { - deferred.reject(error); - }; - this.componentService.addOrUpdateArtifact(this.uniqueId, artifact).then(onSuccess, onError); - return deferred.promise; - }; - - public updateMultipleArtifacts = (artifacts:Array<Models.ArtifactModel>):ng.IPromise<any>=> { - let deferred = this.$q.defer(); - let onSuccess = (response:any):void => { - deferred.resolve(response); - }; - let onError = (error:any):void => { - deferred.reject(error); - }; - let q = new Utils.Functions.QueueUtils(this.$q); - - _.forEach(artifacts, (artifact)=> { - q.addBlockingUIAction(()=> this.addOrUpdateArtifact(artifact).then(onSuccess, onError)); - }); - return deferred.promise; - }; - - - public deleteArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let onSuccess = (artifactObj:Models.ArtifactModel):void => { - let newArtifact = new Models.ArtifactModel(artifactObj); - let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType); - if (newArtifact.mandatory || newArtifact.serviceApi) { - artifacts[newArtifact.artifactLabel] = newArtifact; - } - else { - delete artifacts[artifactLabel]; - } - deferred.resolve(newArtifact); - }; - this.componentService.deleteArtifact(this.uniqueId, artifactId, artifactLabel).then(onSuccess); - return deferred.promise; - }; - - - public addOrUpdateProperty = (property:Models.PropertyModel):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - - let onError = (error:any):void => { - deferred.reject(error); - }; - - if (!property.uniqueId) { - let onSuccess = (property:Models.PropertyModel):void => { - let newProperty = new Models.PropertyModel(property); - this.properties.push(newProperty); - deferred.resolve(newProperty); - }; - this.componentService.addProperty(this.uniqueId, property).then(onSuccess, onError); - } - else { - let onSuccess = (newProperty:Models.PropertyModel):void => { - // find exist instance property in parent component for update the new value ( find bu uniqueId ) - let existProperty:Models.PropertyModel = <Models.PropertyModel>_.find(this.properties, {uniqueId: newProperty.uniqueId}); - let propertyIndex = this.properties.indexOf(existProperty); - newProperty.readonly = this.uniqueId != newProperty.parentUniqueId; - this.properties[propertyIndex] = newProperty; - deferred.resolve(newProperty); - }; - this.componentService.updateProperty(this.uniqueId, property).then(onSuccess, onError); - } - return deferred.promise; - }; - - public addOrUpdateAttribute = (attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - - let onError = (error:any):void => { - deferred.reject(error); - }; - - if (!attribute.uniqueId) { - let onSuccess = (attribute:Models.AttributeModel):void => { - let newAttribute = new Models.AttributeModel(attribute); - this.attributes.push(newAttribute); - deferred.resolve(newAttribute); - }; - this.componentService.addAttribute(this.uniqueId, attribute).then(onSuccess, onError); - } - else { - let onSuccess = (newAttribute:Models.AttributeModel):void => { - let existAttribute:Models.AttributeModel = <Models.AttributeModel>_.find(this.attributes, {uniqueId: newAttribute.uniqueId}); - let attributeIndex = this.attributes.indexOf(existAttribute); - newAttribute.readonly = this.uniqueId != newAttribute.parentUniqueId; - this.attributes[attributeIndex] = newAttribute; - deferred.resolve(newAttribute); - }; - this.componentService.updateAttribute(this.uniqueId, attribute).then(onSuccess, onError); - } - return deferred.promise; - }; - - public deleteProperty = (propertyId:string):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - let onSuccess = ():void => { - console.log("Property deleted"); - delete _.remove(this.properties, {uniqueId: propertyId})[0]; - deferred.resolve(); - }; - let onFailed = ():void => { - console.log("Failed to delete property"); - deferred.reject(); - }; - this.componentService.deleteProperty(this.uniqueId, propertyId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public deleteAttribute = (attributeId:string):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - let onSuccess = ():void => { - console.log("Attribute deleted"); - delete _.remove(this.attributes, {uniqueId: attributeId})[0]; - }; - let onFailed = ():void => { - console.log("Failed to delete attribute"); - }; - this.componentService.deleteAttribute(this.uniqueId, attributeId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateInstanceProperty = (property:Models.PropertyModel):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - let onSuccess = (newProperty:Models.PropertyModel):void => { - // find exist instance property in parent component for update the new value ( find bu uniqueId & path) - let existProperty:Models.PropertyModel = <Models.PropertyModel>_.find(this.componentInstancesProperties[newProperty.resourceInstanceUniqueId], {uniqueId: newProperty.uniqueId,path: newProperty.path}); - let index = this.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty); - this.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty; - deferred.resolve(newProperty); - }; - let onFailed = (error:any):void => { - console.log('Failed to update property value'); - deferred.reject(error); - }; - this.componentService.updateInstanceProperty(this.uniqueId, property).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateInstanceAttribute = (attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - let onSuccess = (newAttribute:Models.AttributeModel):void => { - let existAttribute:Models.AttributeModel = <Models.AttributeModel>_.find(this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId], {uniqueId: newAttribute.uniqueId}); - let index = this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId].indexOf(existAttribute); - this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId][index] = newAttribute; - deferred.resolve(newAttribute); - }; - let onFailed = (error:any):void => { - console.log('Failed to update attribute value'); - deferred.reject(error); - }; - this.componentService.updateInstanceAttribute(this.uniqueId, attribute).then(onSuccess, onFailed); - return deferred.promise; - }; - - public downloadInstanceArtifact = (artifactId:string):ng.IPromise<Models.IFileDownload> => { - return this.componentService.downloadInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId); - }; - - public deleteInstanceArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let onSuccess = (artifactObj:Models.ArtifactModel):void => { - let newArtifact = new Models.ArtifactModel(artifactObj); - let artifacts = this.selectedInstance.deploymentArtifacts; - if (newArtifact.mandatory || newArtifact.serviceApi) {//????????? - artifacts[newArtifact.artifactLabel] = newArtifact; - } - else { - delete artifacts[artifactLabel]; - } - deferred.resolve(newArtifact); - }; - this.componentService.deleteInstanceArtifact(this.uniqueId,this.selectedInstance.uniqueId, artifactId, artifactLabel).then(onSuccess); - return deferred.promise; - }; - - public addOrUpdateInstanceArtifact = (artifact:ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let onSuccess = (artifactObj:Models.ArtifactModel):void => { - this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj; - deferred.resolve(artifactObj); - }; - let onError = (error:any):void => { - deferred.reject(error); - }; - if(artifact.uniqueId){ - this.componentService.updateInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); - }else{ - this.componentService.addInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); - } - return deferred.promise; - }; - - public uploadInstanceEnvFile = (artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let onSuccess = (artifactObj:Models.ArtifactModel):void => { - this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj; - deferred.resolve(artifactObj); - }; - let onError = (error:any):void => { - deferred.reject(error); - }; - this.componentService.uploadInstanceEnvFile(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); - return deferred.promise; - }; - - //this function will update the instance version than the function call getComponent to update the current component and return the new instance version - public changeComponentInstanceVersion = (componentUid:string):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - let onFailed = (error:any):void => { - deferred.reject(error); - }; - let onSuccess = (componentInstance:Models.ComponentsInstances.ComponentInstance):void => { - let onSuccess = (component:Models.Components.Component):void => { - component.setSelectedInstance(componentInstance); - deferred.resolve(component); - }; - this.getComponent().then(onSuccess, onFailed); - }; - this.componentService.changeResourceInstanceVersion(this.uniqueId, this.selectedInstance.uniqueId, componentUid).then(onSuccess, onFailed); - return deferred.promise; - }; - - public createComponentInstance = (componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - let onSuccess = (instance:Models.ComponentsInstances.ComponentInstance):void => { - let onSuccess = (component:Models.Components.Component):void => { - this.componentInstances = Utils.CommonUtils.initComponentInstances(component.componentInstances); - this.componentInstancesProperties = new Models.PropertiesGroup(component.componentInstancesProperties); - this.componentInstancesAttributes = new Models.AttributesGroup(component.componentInstancesAttributes); - deferred.resolve(instance); - }; - this.getComponent().then(onSuccess); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.createComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateComponentInstance = (componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - let onSuccess = (updatedInstance:Models.ComponentsInstances.ComponentInstance):void => { - let componentInstance:Models.ComponentsInstances.ComponentInstance = _.find(this.componentInstances, (instance:Models.ComponentsInstances.ComponentInstance) => { - return instance.uniqueId === updatedInstance.uniqueId; - }); - - let index = this.componentInstances.indexOf(componentInstance); - this.componentInstances[index] = componentInstance; - deferred.resolve(updatedInstance); - - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.updateComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateMultipleComponentInstances = (instances: Array<Models.ComponentsInstances.ComponentInstance>):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>> => { - let deferred = this.$q.defer(); - let onSuccess = (updatedInstances:Array<Models.ComponentsInstances.ComponentInstance>):void => { - deferred.resolve(updatedInstances); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.updateMultipleComponentInstances(this.uniqueId, instances).then(onSuccess, onFailed); - return deferred.promise; - }; - - public deleteComponentInstance = (componentInstanceId:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - let onSuccess = ():void => { - let onSuccess = (component:Models.Components.Component):void => { - this.componentInstances = Utils.CommonUtils.initComponentInstances(component.componentInstances); - this.componentInstancesProperties = new Models.PropertiesGroup(component.componentInstancesProperties); - this.componentInstancesAttributes = new Models.AttributesGroup(component.componentInstancesAttributes); - this.initComponentInstanceRelations(component.componentInstancesRelations); - deferred.resolve(); - }; - this.getComponent().then(onSuccess); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.deleteComponentInstance(this.uniqueId, componentInstanceId).then(onSuccess, onFailed); - return deferred.promise; - }; - - - public createRelation = (relation:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel> => { - let deferred = this.$q.defer(); - let onSuccess = (relation:Models.RelationshipModel):void => { - console.info('Link created successfully', relation); - if (!this.componentInstancesRelations) { - this.componentInstancesRelations = []; - } - this.componentInstancesRelations.push(new Models.RelationshipModel(relation)); - deferred.resolve(relation); - }; - let onFailed = (error:any):void => { - console.info('Failed to create relation', error); - deferred.reject(error); - }; - this.componentService.createRelation(this.uniqueId, relation).then(onSuccess, onFailed); - return deferred.promise; - }; - - public deleteRelation = (relation:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel> => { - let deferred = this.$q.defer(); - let onSuccess = (responseRelation:Models.RelationshipModel):void => { - console.log("Link Deleted In Server"); - let relationToDelete = _.find(this.componentInstancesRelations, (item) => { - return item.fromNode === relation.fromNode && item.toNode === relation.toNode && _.some(item.relationships, (relationship)=> { - return angular.equals(relation.relationships[0], relationship); - }); - }); - let index = this.componentInstancesRelations.indexOf(relationToDelete); - if (relationToDelete != undefined && index > -1) { - if (relationToDelete.relationships.length == 1) { - this.componentInstancesRelations.splice(index, 1); - } else { - this.componentInstancesRelations[index].relationships = - _.reject(this.componentInstancesRelations[index].relationships, relation.relationships[0]); - } - } else { - console.error("Error while deleting relation - the return delete relation from server was not found in UI") - } - deferred.resolve(relation); - }; - let onFailed = (error:any):void => { - console.error("Failed To Delete Link"); - deferred.reject(error); - }; - this.componentService.deleteRelation(this.uniqueId, relation).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateRequirementsCapabilities = ():ng.IPromise<any> => { - let deferred = this.$q.defer(); - let onSuccess = (response:any):void => { - this.capabilities = response.capabilities; - this.requirements = response.requirements; - deferred.resolve(response); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.getRequirementsCapabilities(this.uniqueId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public getModuleForDisplay = (moduleId:string):ng.IPromise<Models.DisplayModule> => { - - let deferred = this.$q.defer(); - let onSuccess = (response:Models.DisplayModule):void => { - deferred.resolve(response); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - this.componentService.getModuleForDisplay(this.uniqueId, moduleId).then(onSuccess, onFailed); - return deferred.promise; - }; - - // this function get all instances filtered by inputs and properties (optional) - if no search string insert - this function will - // get all the instances of the component (in service only VF instances) - public getComponentInstancesFilteredByInputsAndProperties = (searchText?:string):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>> => { - - let deferred = this.$q.defer(); - let onSuccess = (response: Array<Models.ComponentsInstances.ComponentInstance>):void => { - deferred.resolve(response); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInstancesFilteredByInputsAndProperties(this.uniqueId, searchText).then(onSuccess, onFailed); - return deferred.promise; - }; - - - // get inputs for instance - Pagination function - public getComponentInputs = ():ng.IPromise<Array<Models.InputModel>> => { - - let deferred = this.$q.defer(); - let onSuccess = (inputsRes: Array<Models.InputModel>):void => { - this.inputs = inputsRes; - deferred.resolve(inputsRes); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInputs(this.uniqueId).then(onSuccess, onFailed); - return deferred.promise; - }; - - - // get inputs instance - Pagination function - public getComponentInstanceInputs = (componentInstanceId: string, originComponentUid: string):ng.IPromise<Array<Models.InputModel>> => { - - let deferred = this.$q.defer(); - let onSuccess = (response: Array<Models.InputModel>):void => { - deferred.resolve(response); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInstanceInputs(this.uniqueId, componentInstanceId, originComponentUid).then(onSuccess, onFailed); - return deferred.promise; - }; - - // get inputs inatnce - Pagination function - public getComponentInstanceInputProperties = (componentInstanceId: string, inputId: string):ng.IPromise<Array<Models.PropertyModel>> => { - - let deferred = this.$q.defer(); - let onSuccess = (response: Array<Models.PropertyModel>):void => { - deferred.resolve(response); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInstanceInputProperties(this.uniqueId, componentInstanceId, inputId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public updateGroupMetadata = (module: Models.Module):ng.IPromise<Models.Module> => { - - let deferred = this.$q.defer(); - - let onSuccess = (updatedModule:Models.Module):void => { - let groupIndex: number = _.indexOf(this.groups, _.find(this.groups, (module: Models.Module) => { - return module.uniqueId === updatedModule.uniqueId; - })); - - if(groupIndex !== -1) { - this.groups[groupIndex] = updatedModule; - } - deferred.resolve(updatedModule); - }; - let onFailed = (error:any):void => { - deferred.reject(error); - }; - - this.componentService.updateGroupMetadata(this.uniqueId, module).then(onSuccess, onFailed); - - return deferred.promise; - }; - - //------------------------------------------ Help Functions ----------------------------------------------------------------// - - public isProduct = ():boolean => { - return this instanceof Product; - }; - - public isService = ():boolean => { - return this instanceof Service; - }; - - public isResource = ():boolean => { - return this instanceof Resource; - }; - - public getComponentSubType = ():string => { - return this.componentType; - }; - - public isAlreadyCertified = ():boolean => { - return parseInt(this.version) >= 1; - }; - - public isComplex = ():boolean => { - return true; - }; - - //sort string version value from hash to sorted version (i.e 1.9 before 1.11) - private sortVersions = (v1:string, v2:string):number => { - let ver1 = v1.split('.'); - let ver2 = v2.split('.'); - let diff = parseInt(_.first(ver1)) - parseInt(_.first(ver2)); - if (!diff){ - return parseInt(_.last(ver1)) - parseInt(_.last(ver2)); - } - return diff; - }; - - public getAllVersionsAsSortedArray = ():Array<any> => { - let res = []; - if(this.allVersions){ - let keys = Object.keys(this.allVersions).sort(this.sortVersions); - _.forEach(keys, (key)=> { - res.push({ - versionNumber: key, - versionId: this.allVersions[key] - }) - }); - } - return res; - }; - - public isLatestVersion = ():boolean => { - if (this.allVersions){ - return this.version === _.last(Object.keys(this.allVersions).sort(this.sortVersions)); - }else{ - return true; - } - - }; - - public getAdditionalInformation = ():Array<Models.AdditionalInformationModel> => { - let additionalInformationObject:any = _.find(this.additionalInformation, (obj:any):boolean => { - return obj.parentUniqueId == this.uniqueId; - }); - if (additionalInformationObject) { - return additionalInformationObject.parameters; - } - return []; - }; - - public handleTags = ():void => { - let isContainTag = _.find(this.tags, (tag)=> { - return tag === this.name; - }); - if (!isContainTag) { - this.tags.push(this.name); - } - }; - - public getArtifactsByType = (artifactGroupType:string):Models.ArtifactGroupModel => { - switch (artifactGroupType) { - case Utils.Constants.ArtifactGroupType.DEPLOYMENT: - return this.deploymentArtifacts; - case Utils.Constants.ArtifactGroupType.INFORMATION: - return this.artifacts; - } - }; - - public getStatus =(sdcMenu:Models.IAppMenu):string =>{ - let status:string = sdcMenu.LifeCycleStatuses[this.lifecycleState].text; - if(this.lifecycleState == "CERTIFIED" && sdcMenu.DistributionStatuses[this.distributionStatus]) { - status = sdcMenu.DistributionStatuses[this.distributionStatus].text; - } - return status; - }; - - public toJSON = ():any => { - this.componentService = undefined; - this.filterTerm = undefined; - this.iconSprite = undefined; - this.mainCategory = undefined; - this.subCategory = undefined; - this.selectedInstance = undefined; - this.showMenu = undefined; - this.$q = undefined; - this.selectedCategory = undefined; - return this; - }; - } -} - diff --git a/catalog-ui/app/scripts/models/components/displayComponent.ts b/catalog-ui/app/scripts/models/components/displayComponent.ts deleted file mode 100644 index 578f392470..0000000000 --- a/catalog-ui/app/scripts/models/components/displayComponent.ts +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/5/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class DisplayComponent { - - uniqueId:string; - displayName:string; - version:string; - mainCategory:string; - subCategory:string; - iconClass:string; - componentSubType:string; - searchFilterTerms:string; - certifiedIconClass:string; - icon:string; - isRequirmentAndCapabilitiesLoaded:boolean; - - constructor(public component:Models.Components.Component) { - this.icon = component.icon; - this.version = component.version; - this.uniqueId = component.uniqueId; - this.isRequirmentAndCapabilitiesLoaded = false; - - if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) { - this.mainCategory = component.categories[0].name; - this.subCategory = component.categories[0].subcategories[0].name; - } else { - this.mainCategory = 'Generic'; - this.subCategory = 'Generic'; - } - if (component instanceof Models.Components.Resource) { - this.componentSubType = (<Models.Components.Resource>component).resourceType; - } else { - this.componentSubType = component.componentType; - } - - this.initDisplayName(component.name); - this.searchFilterTerms = (this.displayName + ' ' + component.description + ' ' + component.tags.join(' ')).toLowerCase() + ' ' + component.version; - this.initIconSprite(component.icon); - this.certifiedIconClass = component.lifecycleState != 'CERTIFIED' ? 'non-certified' : ''; - if(component.icon === 'vl' || component.icon === 'cp') { - this.certifiedIconClass = this.certifiedIconClass + " " + 'smaller-icon'; - } - } - - public initDisplayName = (name:string):void => { - let newName = - _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.')) - .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.')) - .split('nodes.module.')).split('cp.')).split('vl.')); - if (newName){ - this.displayName = newName; - } else { - this.displayName = name; - } - }; - - public initIconSprite = (icon:string ):void => { - switch (this.componentSubType) { - case Utils.Constants.ComponentType.SERVICE: - this.iconClass = "sprite-services-icons " + icon; - break; - case Utils.Constants.ComponentType.PRODUCT: - this.iconClass = "sprite-product-icons " + icon; - break; - default: - this.iconClass = "sprite-resource-icons " + icon; - } - } - - public getComponentSubType = ():string => { - return this.componentSubType; - }; - } -} diff --git a/catalog-ui/app/scripts/models/components/product.ts b/catalog-ui/app/scripts/models/components/product.ts deleted file mode 100644 index 6ba3404afb..0000000000 --- a/catalog-ui/app/scripts/models/components/product.ts +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.Components { - 'use strict'; - - export class Product extends Component{ - - public contacts:Array<string>; - public componentService: Services.Components.IProductService; - public fullName: string; - - constructor(componentService: Services.Components.IProductService, $q:ng.IQService, component?:Product) { - super(componentService, $q, component); - - if(component) { - this.fullName = component.fullName; - this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; - this.contacts = component.contacts; - } - this.componentService = componentService; - this.iconSprite = "sprite-product-icons"; - } - - public deleteGroup = (uniqueId: string): void => { - _.forEach(this.categories, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - subcategory.groupings = _.reject (subcategory.groupings, (group:Models.IGroup) => { - return group.uniqueId === uniqueId; - }); - if(subcategory.groupings.length == 0){ // if there is no groups, delete the subcategory - category.subcategories = _.reject (category.subcategories, (subcategoryObj:Models.ISubCategory) => { - return subcategoryObj.uniqueId === subcategory.uniqueId; - }); - if(category.subcategories.length == 0){ // if there is no subcategory, delete the category - this.categories = _.reject (this.categories , (categoryObj:Models.IMainCategory) => { - return categoryObj.uniqueId === category.uniqueId; - }); - } - } - }); - }); - }; - - private getCategoryObjectById = (categoriesArray:Array<Models.ICategoryBase>, categoryUniqueId:string):Models.ICategoryBase => { - let categorySelected = _.find(categoriesArray, (category) => { - return category.uniqueId === categoryUniqueId; - }); - return categorySelected; - }; - - public addGroup = (category: Models.IMainCategory, subcategory: Models.ISubCategory, group: Models.IGroup): void => { - if(!this.categories){ - this.categories = new Array<Models.IMainCategory>(); - } - let existingCategory:Models.IMainCategory = <Models.IMainCategory>this.getCategoryObjectById(this.categories, category.uniqueId); - let newGroup = angular.copy(group); - newGroup.filterTerms = undefined; - newGroup.isDisabled = undefined; - if(!existingCategory){ - let newCategory: Models.IMainCategory = angular.copy(category); - newCategory.filteredGroup = undefined; - newCategory.subcategories = []; - let newSubcategory:Models.ISubCategory = angular.copy(subcategory); - newSubcategory.groupings = []; - newSubcategory.groupings.push(newGroup); - newCategory.subcategories.push(newSubcategory); - this.categories.push(newCategory); - } - else{ - let existingSubcategory:Models.ISubCategory = <Models.ISubCategory> this.getCategoryObjectById(existingCategory.subcategories, subcategory.uniqueId); - if(!existingSubcategory){ - let newSubcategory:Models.ISubCategory = angular.copy(subcategory); - newSubcategory.groupings = []; - newSubcategory.groupings.push(newGroup); - existingCategory.subcategories.push(newSubcategory); - - } else { - let existingGroup:Models.IGroup = <Models.IGroup> this.getCategoryObjectById(existingSubcategory.groupings, group.uniqueId); - if(!existingGroup){ - existingSubcategory.groupings.push(newGroup); - } - } - } - }; - - } -} - diff --git a/catalog-ui/app/scripts/models/components/resource.ts b/catalog-ui/app/scripts/models/components/resource.ts deleted file mode 100644 index 243ef3463c..0000000000 --- a/catalog-ui/app/scripts/models/components/resource.ts +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/3/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.Components { - 'use strict'; - - export class Resource extends Component { - - public interfaces: any; - public derivedFrom:Array<string>; - public componentService: Services.Components.IResourceService; - public resourceType:string; - public payloadData:string; - public payloadName:string; - public importedFile: Sdc.Directives.FileUploadModel; - - // Onboarding parameters - public csarUUID:string; - public csarVersion:string; - public csarPackageType:string; - public packageId:string; - - constructor(componentService: Services.Components.IResourceService, $q: ng.IQService, component?:Resource) { - super(componentService, $q, component); - if(component) { - - this.interfaces = component.interfaces; - this.derivedFrom = component.derivedFrom; - this.payloadData = component.payloadData ? component.payloadData : undefined; - this.payloadName = component.payloadName ? component.payloadName : undefined; - this.resourceType = component.resourceType; - this.csarUUID = component.csarUUID; - this.csarVersion = component.csarVersion; - this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType; - - if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) { - component.mainCategory = component.categories[0].name; - component.subCategory = component.categories[0].subcategories[0].name; - this.selectedCategory = component.mainCategory + "_#_" + component.subCategory; - this.importedFile = component.importedFile; - } - } else { - this.resourceType = Utils.Constants.ResourceType.VF; - } - - this.componentService = componentService; - this.iconSprite = "sprite-resource-icons"; - } - - public getComponentSubType = ():string => { - return this.resourceType; - }; - - public isComplex = ():boolean => { - return this.resourceType === Utils.Constants.ResourceType.VF; - }; - - public isVl = ():boolean => { - return Utils.Constants.ResourceType.VL == this.resourceType; - }; - - public isCsarComponent = ():boolean => { - return !!this.csarUUID; - }; - - public createComponentOnServer = ():ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - let onSuccess = (component:Models.Components.Resource):void => { - this.payloadData = undefined; - this.payloadName = undefined; - deferred.resolve(component); - }; - let onError = (error:any):void => { - deferred.reject(error); - }; - - this.handleTags(); - if(this.importedFile){ - this.payloadData = this.importedFile.base64; - this.payloadName = this.importedFile.filename; - } - this.componentService.createComponent(this).then(onSuccess, onError); - return deferred.promise; - }; - - /* we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service - * we also need to remove already selected inputs (the inputs that already create on server, and disabled in the view - but they are selected so they are still in the view model - */ - public createInputsFormInstances = (instanceInputsPropertiesMap:Models.InstanceInputsPropertiesMapData):ng.IPromise<Array<Models.InputModel>> => { - let deferred = this.$q.defer(); - /* - let instanceInputsPropertiesMapToCreate: Models.InstanceInputsPropertiesMapData = new Models.InstanceInputsPropertiesMapData(); - _.forEach(instanceInputsPropertiesMap, (properties:Array<Models.PropertyModel>, instanceId:string) => { - - if(properties && properties.length > 0) { - let componentInstance:Models.ComponentsInstances.ComponentInstance = _.find(this.componentInstances, (instace:Models.ComponentsInstances.ComponentInstance) => { - return instace.uniqueId === instanceId; - }); - - instanceInputsPropertiesMapToCreate[instanceId] = new Array<Models.PropertyModel>(); - _.forEach(properties, (property:Models.PropertyModel) => { - - if(!property.isAlreadySelected) { - let newInput = new Models.PropertyModel(property); - newInput.name = componentInstance.normalizedName + '_' + property.name; - instanceInputsPropertiesMapToCreate[instanceId].push(newInput); - } - }); - if( instanceInputsPropertiesMapToCreate[instanceId].length === 0) { - delete instanceInputsPropertiesMapToCreate[instanceId]; - } - } else { - delete instanceInputsPropertiesMapToCreate[instanceId]; - } - }); - - if(Object.keys(instanceInputsPropertiesMapToCreate).length > 0) { - let deferred = this.$q.defer(); - let onSuccess = (propertiesCreated: Array<Models.PropertyModel>):void => { - this.inputs = propertiesCreated.concat(this.inputs); - deferred.resolve(propertiesCreated); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.createInputsFromInstancesInputsProperties(this.uniqueId, new Models.InstanceInputsPropertiesMap(instanceInputsPropertiesMapToCreate)).then(onSuccess, onFailed); - } - */ - return deferred.promise; - }; - - // we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service - public getResourceInputInputs = (inputId:string):ng.IPromise<Array<Models.InputModel>> => { - let deferred = this.$q.defer(); - let onSuccess = (inputInputs: Array<Models.InputModel>):void => { - let input: Models.InputModel = _.find(this.inputs, (input:Models.InputModel) => { - return input.uniqueId === inputId; - }); - input.inputs = inputInputs; - deferred.resolve(inputInputs); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInputInputs(this.uniqueId, inputId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public toJSON = ():any => { - this.componentService = undefined; - this.filterTerm = undefined; - this.iconSprite = undefined; - this.mainCategory = undefined; - this.subCategory = undefined; - this.selectedInstance = undefined; - this.showMenu = undefined; - this.$q = undefined; - this.selectedCategory = undefined; - this.importedFile = undefined; - return this; - }; - } -} - - diff --git a/catalog-ui/app/scripts/models/components/service.ts b/catalog-ui/app/scripts/models/components/service.ts deleted file mode 100644 index b1730aae94..0000000000 --- a/catalog-ui/app/scripts/models/components/service.ts +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.Components { - 'use strict'; - - - export class Service extends Component { - - public serviceApiArtifacts:Models.ArtifactGroupModel; - public componentService:Services.Components.IServiceService; - - constructor(componentService:Services.Components.IServiceService, $q:ng.IQService, component?:Service) { - super(componentService, $q, component); - if (component) { - this.serviceApiArtifacts = new Models.ArtifactGroupModel(component.serviceApiArtifacts); - this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; - if (component.categories && component.categories[0]) { - this.mainCategory = component.categories[0].name; - this.selectedCategory = this.mainCategory; - } - } - this.componentService = componentService; - this.iconSprite = "sprite-services-icons"; - } - - public getDistributionsList = ():ng.IPromise<Array<Models.Distribution>> => { - return this.componentService.getDistributionsList(this.uuid); - }; - - public getDistributionsComponent = (distributionId:string):ng.IPromise<Array<Models.DistributionComponent>> => { - return this.componentService.getDistributionComponents(distributionId); - }; - - public markAsDeployed = (distributionId:string):ng.IPromise<any> => { - return this.componentService.markAsDeployed(this.uniqueId, distributionId); - }; - - /* we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service - * we also need to remove already selected inputs (the inputs that already create on server, and disabled in the view - but they are selected so they are still in the view model - */ - public createInputsFormInstances = (instancesInputsMap:Models.InstancesInputsMapData):ng.IPromise<Array<Models.InputModel>> => { - let deferred = this.$q.defer(); - - let instancesInputsMapToCreate: Models.InstancesInputsMapData = new Models.InstancesInputsMapData(); - _.forEach(instancesInputsMap, (inputs:Array<Models.InputModel>, instanceId:string) => { - - if(inputs && inputs.length > 0) { - let componentInstance:Models.ComponentsInstances.ComponentInstance = _.find(this.componentInstances, (instace:Models.ComponentsInstances.ComponentInstance) => { - return instace.uniqueId === instanceId; - }); - instancesInputsMapToCreate[instanceId] = new Array<Models.InputModel>(); - _.forEach(inputs, (input:Models.InputModel) => { - - if(!input.isAlreadySelected) { - let newInput = new Models.InputModel(input); - newInput.name = componentInstance.normalizedName + '_' + input.name; - instancesInputsMapToCreate[instanceId].push(newInput); - } - }); - if( instancesInputsMapToCreate[instanceId].length === 0) { - delete instancesInputsMapToCreate[instanceId]; - } - } else { - delete instancesInputsMapToCreate[instanceId]; - } - }); - - if(Object.keys(instancesInputsMapToCreate).length > 0) { - let deferred = this.$q.defer(); - let onSuccess = (inputsCreated: Array<Models.InputModel>):void => { - this.inputs = inputsCreated.concat(this.inputs); - deferred.resolve(inputsCreated); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.createInputsFromInstancesInputs(this.uniqueId, new Models.InstancesInputsMap(instancesInputsMapToCreate)).then(onSuccess, onFailed); - } - return deferred.promise; - }; - - // we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service - public getServiceInputInputs = (inputId:string):ng.IPromise<Array<Models.InputModel>> => { - let deferred = this.$q.defer(); - let onSuccess = (inputInputs: Array<Models.InputModel>):void => { - let input: Models.InputModel = _.find(this.inputs, (input:Models.InputModel) => { - return input.uniqueId === inputId; - }); - input.inputs = inputInputs; - deferred.resolve(inputInputs); - }; - let onFailed = (error:any): void => { - deferred.reject(error); - }; - this.componentService.getComponentInputInputs(this.uniqueId, inputId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public deleteServiceInput = (inputId:string):ng.IPromise<Models.InputModel> => { - var deferred = this.$q.defer(); - - var onSuccess = (input: Models.InputModel):void => { - deferred.resolve(input) - }; - - var onFailed = (error:any) : void => { - deferred.reject(error); - }; - - this.componentService.deleteComponentInput(this.uniqueId, inputId).then(onSuccess, onFailed); - return deferred.promise; - }; - - public getArtifactsByType = (artifactGroupType:string):Models.ArtifactGroupModel => { - switch (artifactGroupType) { - case Utils.Constants.ArtifactGroupType.DEPLOYMENT: - return this.deploymentArtifacts; - case Utils.Constants.ArtifactGroupType.INFORMATION: - return this.artifacts; - case Utils.Constants.ArtifactGroupType.SERVICE_API: - return this.serviceApiArtifacts; - } - }; - } -} - diff --git a/catalog-ui/app/scripts/models/componentsInstances/componentInstance.ts b/catalog-ui/app/scripts/models/componentsInstances/componentInstance.ts deleted file mode 100644 index af2f338998..0000000000 --- a/catalog-ui/app/scripts/models/componentsInstances/componentInstance.ts +++ /dev/null @@ -1,126 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.ComponentsInstances { - 'use strict'; - - export class ComponentInstance{ - - public componentUid: string; - public componentName:string; - public posX: number; - public posY: number; - public componentVersion:string; - public description: string; - public icon: string; - public name: string; - public normalizedName:string; - public originType: string; - public deploymentArtifacts: Models.ArtifactGroupModel; - public propertyValueCounter: number; - public uniqueId: string; - public creationTime: number; - public modificationTime: number; - public capabilities: Models.CapabilitiesGroup; - public requirements: Models.RequirementsGroup; - - //custom properties - public certified: boolean; - public iconSprite:string; - public inputs: Array<Models.InputModel>; - public properties: Array<Models.PropertyModel>; - - constructor(componentInstance?: ComponentInstance) { - - if(componentInstance) { - this.componentUid = componentInstance.componentUid; - this.componentName = componentInstance.componentName; - - this.componentVersion = componentInstance.componentVersion; - this.description = componentInstance.description; - this.icon = componentInstance.icon; - this.name = componentInstance.name; - this.normalizedName = componentInstance.normalizedName; - this.originType = componentInstance.originType; - this.deploymentArtifacts = new Models.ArtifactGroupModel(componentInstance.deploymentArtifacts); - this.uniqueId = componentInstance.uniqueId; - this.creationTime = componentInstance.creationTime; - this.modificationTime = componentInstance.modificationTime; - this.propertyValueCounter = componentInstance.propertyValueCounter; - this.capabilities = new Models.CapabilitiesGroup(componentInstance.capabilities); - this.requirements = new Models.RequirementsGroup(componentInstance.requirements); - this.certified = componentInstance.certified; - this.updatePosition(componentInstance.posX, componentInstance.posY); - } - } - - public isUcpe = ():boolean =>{ - if(this.originType === 'VF' && this.capabilities && this.capabilities['tosca.capabilities.Container'] && this.name.toLowerCase().indexOf('ucpe') > -1){ - return true; - } - return false; - }; - - public isVl = ():boolean =>{ - return this.originType === 'VL'; - }; - - - public setInstanceRC = ():void=>{ - _.forEach(this.requirements, (requirementValue:Array<any>, requirementKey)=> { - _.forEach(requirementValue, (requirement)=> { - if (!requirement.ownerName){ - requirement['ownerId'] = this.uniqueId; - requirement['ownerName'] = this.name; - } - }); - }); - _.forEach(this.capabilities, (capabilityValue:Array<any>, capabilityKey)=> { - _.forEach(capabilityValue, (capability)=> { - if (!capability.ownerName){ - capability['ownerId'] = this.uniqueId; - capability['ownerName'] = this.name; - } - }); - }); - }; - - public updatePosition (posX:number, posY:number) { - this.posX = posX; - this.posY = posY; - } - - public toJSON = ():any => { - - var serverInstance = angular.copy(this); - serverInstance.certified = undefined; - serverInstance.iconSprite = undefined; - serverInstance.inputs = undefined; - serverInstance.properties = undefined; - serverInstance.requirements = undefined; - serverInstance.capabilities = undefined; - return serverInstance; - }; - } - -} diff --git a/catalog-ui/app/scripts/models/componentsInstances/productInstance.ts b/catalog-ui/app/scripts/models/componentsInstances/productInstance.ts deleted file mode 100644 index 71ef9bb7d3..0000000000 --- a/catalog-ui/app/scripts/models/componentsInstances/productInstance.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.ComponentsInstances { - 'use strict'; - - export class ProductInstance extends ComponentInstance{ - - constructor(componentInstance?: ProductInstance) { - super(componentInstance); - this.iconSprite = "sprite-product-icons"; - } - } -} diff --git a/catalog-ui/app/scripts/models/componentsInstances/resourceInstance.ts b/catalog-ui/app/scripts/models/componentsInstances/resourceInstance.ts deleted file mode 100644 index 67df05ded9..0000000000 --- a/catalog-ui/app/scripts/models/componentsInstances/resourceInstance.ts +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.ComponentsInstances { - 'use strict'; - - export class ResourceInstance extends ComponentInstance{ - - constructor(componentInstance?: ResourceInstance) { - super(componentInstance); - - this.iconSprite = "sprite-resource-icons"; - } - } -} - diff --git a/catalog-ui/app/scripts/models/componentsInstances/serviceInstance.ts b/catalog-ui/app/scripts/models/componentsInstances/serviceInstance.ts deleted file mode 100644 index 0d78feafd3..0000000000 --- a/catalog-ui/app/scripts/models/componentsInstances/serviceInstance.ts +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models.ComponentsInstances { - 'use strict'; - - export class ServiceInstance extends ComponentInstance{ - - constructor(componentInstance?: ServiceInstance) { - super(componentInstance); - this.iconSprite = "sprite-services-icons"; - } - } -} - diff --git a/catalog-ui/app/scripts/models/csar-component.ts b/catalog-ui/app/scripts/models/csar-component.ts deleted file mode 100644 index da649c1efd..0000000000 --- a/catalog-ui/app/scripts/models/csar-component.ts +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.Models { - 'use strict'; - - export interface ICsarComponent { - displayName:string; - description:string; - vspName:string; - version:string; - packageId:string; - category:string; - subCategory:string - vendorName:string; - packageType:string; - vendorRelease:string; - } - -} diff --git a/catalog-ui/app/scripts/models/data-type-properties.ts b/catalog-ui/app/scripts/models/data-type-properties.ts deleted file mode 100644 index 973978d9b2..0000000000 --- a/catalog-ui/app/scripts/models/data-type-properties.ts +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/25/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class DataTypePropertyModel { - - //server data - uniqueId:string; - type:string; - required:boolean; - definition:boolean; - description:string; - password:boolean; - name:string; - parentUniqueId:string; - defaultValue:string; - constraints:Array<any>; - //custom - simpleType:string; - - constructor(dataTypeProperty:DataTypePropertyModel) { - if (dataTypeProperty) { - this.uniqueId = dataTypeProperty.uniqueId; - this.type = dataTypeProperty.type; - this.required = dataTypeProperty.required; - this.definition = dataTypeProperty.definition; - this.description = dataTypeProperty.description; - this.password = dataTypeProperty.password; - this.name = dataTypeProperty.name; - this.parentUniqueId = dataTypeProperty.parentUniqueId; - this.defaultValue = dataTypeProperty.defaultValue; - this.constraints = dataTypeProperty.constraints; - this.simpleType = dataTypeProperty.simpleType; - } - } - - public toJSON = ():any => { - this.simpleType = undefined; - return this; - }; - } - -} diff --git a/catalog-ui/app/scripts/models/data-types.ts b/catalog-ui/app/scripts/models/data-types.ts deleted file mode 100644 index d7de238f3b..0000000000 --- a/catalog-ui/app/scripts/models/data-types.ts +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/25/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class DataTypeModel { - - //server data - name:string; - uniqueId:string; - derivedFromName:string; - creationTime:string; - modificationTime:string; - properties:Array<Models.DataTypePropertyModel>; - - constructor(dataType:DataTypeModel) { - if (dataType) { - this.uniqueId = dataType.uniqueId; - this.name = dataType.name; - this.derivedFromName = dataType.derivedFromName; - this.creationTime = dataType.creationTime; - this.modificationTime = dataType.modificationTime; - this.properties = dataType.properties; - } - } - - public toJSON = ():any => { - - return this; - }; - } - -} - diff --git a/catalog-ui/app/scripts/models/distribution.ts b/catalog-ui/app/scripts/models/distribution.ts deleted file mode 100644 index 1c3a9568dd..0000000000 --- a/catalog-ui/app/scripts/models/distribution.ts +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class DistributionStatuses{ - public omfComponentID: string; - public url: string; - public timestamp:string; - public status: string; - - constructor() { - } - } - - - export class DistributionComponent{ - public omfComponentID: string; - public url: string; - public timestamp:string; - public status: string; - - constructor() { - } - } - - export class Distribution { - public distributionID:string; - public timestamp:string; - public userId:string; - public deployementStatus:string; - public distributionComponents:Array<Models.DistributionComponent>; - public statusCount:any; - //custom data - public dateFormat:string; - - constructor() { - } - public toJSON = ():any => { - this.dateFormat = undefined; - return this; - }; - - } - -} - - diff --git a/catalog-ui/app/scripts/models/file-download.ts b/catalog-ui/app/scripts/models/file-download.ts deleted file mode 100644 index 8a74ed57c1..0000000000 --- a/catalog-ui/app/scripts/models/file-download.ts +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export interface IFileDownload{ - artifactName: string; - base64Contents:string; - } -} diff --git a/catalog-ui/app/scripts/models/graph/d2-node.ts b/catalog-ui/app/scripts/models/graph/d2-node.ts deleted file mode 100644 index 16daa5470d..0000000000 --- a/catalog-ui/app/scripts/models/graph/d2-node.ts +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> - -// module Sdc.Models { -// -// export interface D2Node extends go.Node { -// //TODO:should be typesafe! -// resource: any; -// key:string; -// data:any; -// canvasPosition: {x:number;y:number}; -// } -// } diff --git a/catalog-ui/app/scripts/models/graph/graph-links/common-base-link.ts b/catalog-ui/app/scripts/models/graph/graph-links/common-base-link.ts deleted file mode 100644 index 7d21c5d978..0000000000 --- a/catalog-ui/app/scripts/models/graph/graph-links/common-base-link.ts +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 6/29/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Models { - - export class CommonLinkBase { - - img:string; - color:string; - classes: string; - - //this is cytoscapejs fields - public source: string; - public target: string; - public type: string; - public isSdcElement: boolean; - - constructor() { - this.isSdcElement = true; - this.type = 'sdc-link'; - - } - - public setImage = (imgUrl: string) => { - this.img = imgUrl; - }; - - public setColor = (color: string) => { - this.color = color; - }; - - } -} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/common-ci-link-base.ts b/catalog-ui/app/scripts/models/graph/graph-links/common-ci-link-base.ts deleted file mode 100644 index 1e7416ac3e..0000000000 --- a/catalog-ui/app/scripts/models/graph/graph-links/common-ci-link-base.ts +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 6/29/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Models { - - export interface ICommonCiLinkBase { - - } - - export class CommonCiLinkBase extends CommonLinkBase implements ICommonCiLinkBase { - - relation:RelationshipModel; - - - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(); - if (relation) { - if(singleRelationship){ - this.relation = new Models.RelationshipModel(relation, singleRelationship); - }else{ - this.relation = new Models.RelationshipModel(relation); - } - this.source = relation.fromNode; - this.target = relation.toNode; - } else { - this.relation = new RelationshipModel(); - } - } - } -} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.ts b/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.ts deleted file mode 100644 index c2deddbfc3..0000000000 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.ts +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.Models { - - export class CompositionCiSimpleLink extends CompositionCiLinkBase { - - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.color = Utils.Constants.GraphColors.BASE_LINK; - this.classes = 'simple-link'; - } - } -} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts b/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts deleted file mode 100644 index 5d035ccc2c..0000000000 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.Models { - - export class CompositionCiUcpeLink extends CompositionCiLinkBase { - - isFromUcpe: boolean; - constructor(relation?:RelationshipModel, from?:boolean, singleRelation?:Relationship) { - super(relation, singleRelation); - this.isFromUcpe = from; - this.target = relation.toNode; - this.source = singleRelation.requirementOwnerId; - this.relation.relationships = [singleRelation]; - this.color = Utils.Constants.GraphColors.BASE_LINK; - } - - updateLinkDirection():void {} - } -} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/links-factory.ts b/catalog-ui/app/scripts/models/graph/graph-links/links-factory.ts deleted file mode 100644 index 8f6cd6d321..0000000000 --- a/catalog-ui/app/scripts/models/graph/graph-links/links-factory.ts +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 5/1/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Utils { - 'use strict'; - - export class LinksFactory { - - constructor() { - } - - public createGraphLink = (cy: Cy.Instance, relation:Models.RelationshipModel, singleRelation:Models.Relationship):Models.CompositionCiLinkBase => { - - let newRelation:Models.CompositionCiLinkBase; - - let fromNode:Models.Graph.CompositionCiNodeBase = cy.getElementById(relation.fromNode).data(); - let toNode:Models.Graph.CompositionCiNodeBase = cy.getElementById(relation.toNode).data() ; - - if ((relation.fromNode && fromNode.isUcpePart) || (relation.toNode && toNode.isUcpePart )) { //Link from or to node inside ucpe - - if (singleRelation && singleRelation.relationship.type && singleRelation.relationship.type == 'tosca.relationships.HostedOn') { - newRelation = new Models.LinkUcpeHost(relation, singleRelation); - } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { - newRelation = new Models.CompositionCiVlUcpeLink(relation, fromNode.isUcpePart, singleRelation); - } else { - newRelation = new Models.CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation); - } - } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { - newRelation = new Models.CompositionCiVLink(relation, singleRelation); - } else { - newRelation = new Models.CompositionCiSimpleLink(relation, singleRelation); - } - - return newRelation; - }; - - public createUcpeHostLink = (relation:Models.RelationshipModel):Models.LinkUcpeHost => { - return new Models.LinkUcpeHost(relation); - }; - - public createVLLink = (relation:Models.RelationshipModel):Models.CompositionCiVLink => { - return new Models.CompositionCiVLink(relation); - } - - - public createModuleGraphLinks= (relation:Models.RelationshipModel, singleRelation:Models.Relationship):Models.ModuleCiLinkBase => { - - let newRelation:Models.ModuleCiLinkBase; - - if (_.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { - newRelation = new Models.ModuleCiVlLink(relation, singleRelation); - } else { - newRelation = new Models.ModuleCiLinkBase(relation, singleRelation); - } - - return newRelation; - }; - - } -} diff --git a/catalog-ui/app/scripts/models/graph/graphTooltip.ts b/catalog-ui/app/scripts/models/graph/graphTooltip.ts deleted file mode 100644 index 08a85e1126..0000000000 --- a/catalog-ui/app/scripts/models/graph/graphTooltip.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class GraphTooltip{ - position: Cy.Position; - isShow:boolean; - text:string; - - constructor(); - constructor(position: Cy.Position, isShow:boolean, text: string); - constructor(position?: Cy.Position, isShow?:boolean, text?: string) { - this.position = position; - this.isShow = isShow; - this.text = text; - } - } -} - diff --git a/catalog-ui/app/scripts/models/graph/link-menu.ts b/catalog-ui/app/scripts/models/graph/link-menu.ts deleted file mode 100644 index 606c392982..0000000000 --- a/catalog-ui/app/scripts/models/graph/link-menu.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class LinkMenu { - position:Sdc.Models.Graph.Point; - isShow:boolean; - link:Cy.CollectionFirstEdge; - - constructor(); - constructor(point:Sdc.Models.Graph.Point, isShow:boolean, link:Cy.CollectionFirstEdge); - constructor(point?:Sdc.Models.Graph.Point, isShow?:boolean, link?:Cy.CollectionFirstEdge) { - this.position = point ? point: new Sdc.Models.Graph.Point(); - this.isShow = isShow ? isShow : false; - this.link = link ? link : null; - } - } -} - diff --git a/catalog-ui/app/scripts/models/graph/match-relation.ts b/catalog-ui/app/scripts/models/graph/match-relation.ts deleted file mode 100644 index 8d864c675b..0000000000 --- a/catalog-ui/app/scripts/models/graph/match-relation.ts +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class MatchBase { - requirement:Models.Requirement; - isFromTo:boolean; - fromNode:string; - toNode:string; - - constructor(requirement:Models.Requirement, isFromTo:boolean, fromNode:string, toNode:string) { - this.requirement = requirement; - this.isFromTo = isFromTo; - this.fromNode = fromNode; - this.toNode = toNode; - } - - public getDisplayText = (menuSide:string):string => {return '';}; - - public isOwner = (id:string):boolean => { return false; } - - } - - export class MatchReqToReq extends MatchBase { - - secondRequirement:Models.Requirement; - - constructor(requirement:Models.Requirement, secondRequirement:Models.Requirement, isFromTo:boolean, fromNode:string, toNode:string) { - super(requirement, isFromTo, fromNode, toNode); - this.secondRequirement = secondRequirement; - } - - public getDisplayText = (menuSide:string):string => { - if ('left' == menuSide) { - return this.requirement.getFullTitle(); - } - return this.secondRequirement.getFullTitle(); - }; - - public isOwner = (id:string):boolean => { - return this.secondRequirement.ownerId === id || this.requirement.ownerId === id; - } - } - - export class MatchReqToCapability extends MatchBase { - - capability:Models.Capability; - - constructor(requirement:Models.Requirement, capability:Models.Capability, isFromTo:boolean, fromNode:string, toNode:string) { - super(requirement, isFromTo, fromNode, toNode); - this.capability = capability; - } - - public matchToRelation = ():Models.Relationship => { - let relationship:Models.Relationship = new Models.Relationship(); - relationship.capability = this.capability.name; - relationship.capabilityOwnerId = this.capability.ownerId; - relationship.capabilityUid = this.capability.uniqueId; - relationship.relationship = new Models.RelationType(this.capability.type); - relationship.requirement = this.requirement.name; - relationship.requirementOwnerId = this.requirement.ownerId; - relationship.requirementUid = this.requirement.uniqueId; - return relationship; - }; - - - public getDisplayText = (menuSide:string):string => { - if (this.isFromTo && 'left' == menuSide || !this.isFromTo && 'right' == menuSide) { - return this.requirement.getFullTitle(); - } - return this.capability.getFullTitle(); - - }; - - public isOwner = (id:string):boolean => { - return this.capability.ownerId === id || this.requirement.ownerId === id; - }; - - - public matchToRelationModel = ():Models.RelationshipModel => { - let relationshipModel:Models.RelationshipModel = new Models.RelationshipModel(); - let relationship:Models.Relationship = this.matchToRelation(); - relationshipModel.setRelationshipModelParams(this.fromNode, this.toNode, [relationship]); - return relationshipModel; - }; - } - -} - - diff --git a/catalog-ui/app/scripts/models/graph/nodes/base-common-node.ts b/catalog-ui/app/scripts/models/graph/nodes/base-common-node.ts deleted file mode 100644 index e1957e61aa..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/base-common-node.ts +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 6/29/2016. - */ -/// <reference path="../../../references"/> - -module Sdc.Models.Graph { - 'use strict'; - - export abstract class CommonNodeBase { - - public displayName:string; - public name:string; - public img:string; - public certified:boolean; - public isGroup:boolean; - public imagesPath: string; - public isDraggable: boolean; //we need to to manage manually the dragging on the graph inside groups (ucpe-cp is not draggable) - - //cytoscape fields - public id:string; - public type:string; //type is for the edge edition extension, by type we put the green plus icon in position - public isSdcElement:boolean; //this fields is in order to filter sdc elements from all extensions elements - public classes: string; - public parent: string; - public allowConnection: boolean; //this is for egeEdition extension in order to decide if connection to a node is available - - constructor() { - - this.imagesPath = Services.AngularJSBridge.getAngularConfig().imagesPath; - this.type = "basic-node"; - this.isSdcElement = true; - this.isDraggable = true; - this.allowConnection = true; - } - - public updateNameForDisplay =() => { - let context = document.createElement("canvas").getContext("2d"); - context.font = "13px Arial"; - - if (63 < context.measureText(this.name).width) { - let newLen = this.name.length - 3; - let newName = this.name.substring(0, newLen); - - while (60 < (context.measureText(newName).width)) { - newName = newName.substring(0, (--newLen)); - } - this.displayName = newName + '...'; - return; - } - - this.displayName = this.name; - }; - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/common-ci-node-base.ts b/catalog-ui/app/scripts/models/graph/nodes/common-ci-node-base.ts deleted file mode 100644 index 1597650654..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/common-ci-node-base.ts +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Models.Graph { - - export abstract class CommonCINodeBase extends CommonNodeBase { - - public certified:boolean; - public template:string; - public componentInstance:Models.ComponentsInstances.ComponentInstance; - public group:string; - - constructor(instance:Models.ComponentsInstances.ComponentInstance) { - super(); - this.componentInstance = instance; - this.id = this.componentInstance.uniqueId; - this.name = this.componentInstance.name; - this.img = ''; - this.certified = this.isCertified(this.componentInstance.componentVersion); - this.displayName = instance.name; - } - - private isCertified(version:string):boolean { - return 0 === (parseFloat(version)) % 1; - } - - } -} - diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts deleted file mode 100644 index 5f4c0df3c2..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export interface ICompositionCiNodeBase { - - } - - - export abstract class CompositionCiNodeBase extends CommonCINodeBase implements ICompositionCiNodeBase { - - public textPosition: string; //need to move to cp UCPE - public isUcpe: boolean; - public isInsideGroup: boolean; - public isUcpePart: boolean; - - constructor(instance: Models.ComponentsInstances.ComponentInstance, - public imageCreator: Utils.ImageCreatorService) { - super(instance); - this.init(); - } - - private init() { - - this.displayName = this.getDisplayName(); - this.isUcpe = false; - this.isGroup = false; - this.isUcpePart = false; - this.isInsideGroup = false; - - } - - public initImage(node: Cy.Collection): string { - - this.imageCreator.getImageBase64(this.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png', - this.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS + 'uncertified.png') - .then(imageBase64 => { - this.img = imageBase64; - node.style({'background-image': this.img}); - }); - - return this.img; - } - - protected getDisplayName(): string { - - let graphResourceName = Services.AngularJSBridge.getFilter('graphResourceName'); - let resourceName = Services.AngularJSBridge.getFilter('resourceName'); - return graphResourceName(resourceName(this.componentInstance.name)); - } - - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts deleted file mode 100644 index 6286c8245d..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export class CompositionCiNodeCp extends CompositionCiNodeBase { - - constructor(instance:Models.ComponentsInstances.ComponentInstance, - imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initCp(); - } - - private initCp():void { - let sdcConfig = Services.AngularJSBridge.getAngularConfig(); - this.img = sdcConfig.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; - this.type = "basic-small-node"; - //if the cp from type cpEndPointInstances create with another template - if(sdcConfig.cpEndPointInstances.indexOf(this.componentInstance.icon) > -1){ - this.classes = 'cp-end-point-node'; - }else { - this.classes = 'cp-node'; - } - if(!this.certified) { - this.classes = this.classes + ' not-certified'; - } - - } - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts deleted file mode 100644 index 41bf0cef98..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export class CompositionCiNodeService extends CompositionCiNodeBase { - - constructor(instance:Models.ComponentsInstances.ComponentInstance, - imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initService(); - } - - private initService():void { - - this.img = this.imagesPath + Utils.Constants.ImagesUrl.SERVICE_ICONS + this.componentInstance.icon + '.png'; - this.classes = 'service-node' - if(!this.certified) { - this.classes = this.classes + ' not-certified'; - } - - } - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts deleted file mode 100644 index bc91e004f4..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export class NodeUcpe extends CompositionCiNodeBase { - constructor(instance:Models.ComponentsInstances.ComponentInstance, - imageCreator:Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initUcpe(); - } - - private initUcpe():void { - this.isUcpe = true; - this.isGroup = true; - this.isUcpePart = true; - this.classes = 'ucpe-node'; - this.type = 'ucpe-node'; - this.allowConnection = false; - - if (!this.certified) { - this.classes = this.classes + ' not-certified-ucpe'; - } - } - - } -} - - - - - diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts deleted file mode 100644 index d090960046..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export class CompositionCiNodeVf extends CompositionCiNodeBase { - - constructor(instance: Models.ComponentsInstances.ComponentInstance, - imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initVf(); - } - - private initVf(): void { - this.img = this.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; - this.classes = 'vf-node'; - if(!this.certified) { - this.classes = this.classes + ' not-certified'; - } - } - - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts b/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts deleted file mode 100644 index 04f45c87fb..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - export class CompositionCiNodeVfc extends CompositionCiNodeBase { - constructor(instance:Models.ComponentsInstances.ComponentInstance, imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initVfc(); - } - - private initVfc():void { - this.img = this.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS+ this.componentInstance.icon + '.png'; - } - } -} diff --git a/catalog-ui/app/scripts/models/graph/nodes/nodes-factory.ts b/catalog-ui/app/scripts/models/graph/nodes/nodes-factory.ts deleted file mode 100644 index b19b1a7261..0000000000 --- a/catalog-ui/app/scripts/models/graph/nodes/nodes-factory.ts +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.Utils { - 'use strict'; - - export class NodesFactory { - - constructor( - private imageCreator:ImageCreatorService) { - } - - public createNode = (instance:Models.ComponentsInstances.ComponentInstance):Models.Graph.CompositionCiNodeBase => { - - if (instance.isUcpe()) { - return new Models.Graph.NodeUcpe(instance, this.imageCreator); - } - if (instance.originType === Utils.Constants.ComponentType.SERVICE) { - return new Models.Graph.CompositionCiNodeService(instance, this.imageCreator); - } - if (instance.originType === Utils.Constants.ResourceType.CP) { - return new Models.Graph.CompositionCiNodeCp(instance, this.imageCreator); - } - if (instance.originType === Utils.Constants.ResourceType.VL) { - return new Models.Graph.CompositionCiNodeVl(instance, this.imageCreator); - } - - return new Models.Graph.CompositionCiNodeVf(instance, this.imageCreator); - }; - - public createModuleNode = (module:Models.Module):Models.Graph.ModuleNodeBase => { - - return new Models.Graph.ModuleNodeBase(module); - }; - - public createUcpeCpNode = (instance:Models.ComponentsInstances.ComponentInstance):Models.Graph.CompositionCiNodeCp => { - - - return new Models.Graph.CompositionCiNodeUcpeCp(instance, this.imageCreator); - } - } - - NodesFactory.$inject = [ - 'ImageCreatorService' - ]; -} diff --git a/catalog-ui/app/scripts/models/graph/point.ts b/catalog-ui/app/scripts/models/graph/point.ts deleted file mode 100644 index 0efd4c6040..0000000000 --- a/catalog-ui/app/scripts/models/graph/point.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Created by obarda on 11/7/2016. - */ -/// <reference path="../../references"/> - -module Sdc.Models.Graph { - - - export class Point { - /** - * The two-argument constructor produces the Point(x, y). - * @param {number} x - * @param {number} y - */ - constructor(x?:number, y?:number) { - this.x = x || 0; - this.y = y || 0; - } - - /**Gets or sets the x value of the Point.*/ - x:number; - - /**Gets or sets the y value of the Point.*/ - y:number; - } -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/models/graph/relationMenuObjects.ts b/catalog-ui/app/scripts/models/graph/relationMenuObjects.ts deleted file mode 100644 index 266ed76cfa..0000000000 --- a/catalog-ui/app/scripts/models/graph/relationMenuObjects.ts +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - - export class RelationMenuDirectiveObj { - - fromNode:Models.Graph.CompositionCiNodeBase; - toNode:Models.Graph.CompositionCiNodeBase; - // modelLinks:Array<Models.CompositionCiLinkBase>; - mp2mpVL:Models.Components.Component; - p2pVL:Models.Components.Component; - menuPosition: Cy.Position; - rightSideLink:GraphLinkMenuSide; - leftSideLink:GraphLinkMenuSide; - selectionText:string; - vlType:string; - - constructor(fromNode:Models.Graph.CompositionCiNodeBase, toNode:Models.Graph.CompositionCiNodeBase, mp2mpVL:Models.Components.Component, p2pVL:Models.Components.Component, menuPosition:Cy.Position, possibleRelations:Array<Models.MatchBase>) { - this.fromNode = fromNode; - this.toNode = toNode; - // this.modelLinks = modelLinks; - this.mp2mpVL = mp2mpVL; - this.p2pVL = p2pVL; - this.menuPosition = menuPosition; - this.leftSideLink = new GraphLinkMenuSide(this.fromNode.componentInstance); - this.rightSideLink = new GraphLinkMenuSide(this.toNode.componentInstance); - this.selectionText = ''; - this.vlType = null; - - possibleRelations.forEach((match:any) => { - - let reqObjKey: string = match.requirement.ownerName + match.requirement.uniqueId; - let capObjKey: string = match.secondRequirement ? match.secondRequirement.ownerName + match.secondRequirement.uniqueId - : match.capability.ownerName + match.capability.uniqueId; - - if (match.fromNode === this.leftSideLink.componentInstance.uniqueId) { - //init the left side requirements Array - if (!this.leftSideLink.requirements[reqObjKey]) { - this.leftSideLink.requirements[reqObjKey] = []; - } - //push the match to fromNode object (from node is always the requirement) - this.leftSideLink.requirements[reqObjKey].push(match); - - if (match instanceof Models.MatchReqToReq) { - //init the right side requirements Array - if (!this.rightSideLink.requirements[capObjKey]) { - this.rightSideLink.requirements[capObjKey] = []; - } - this.rightSideLink.requirements[capObjKey].push(match); - } else { - //init the right side capabilities Array - if (!this.rightSideLink.capabilities[capObjKey]) { - this.rightSideLink.capabilities[capObjKey] = []; - } - //add to array - this.rightSideLink.capabilities[capObjKey].push(match); - } - - } else { - if (!this.rightSideLink.requirements[reqObjKey]) { - this.rightSideLink.requirements[reqObjKey] = []; - } - this.rightSideLink.requirements[reqObjKey].push(match); - - if (!this.leftSideLink.capabilities[capObjKey]) { - this.leftSideLink.capabilities[capObjKey] = []; - } - this.leftSideLink.capabilities[capObjKey].push(match); - } - }); - - } - } - - - export class GraphLinkMenuSide { - public componentInstance:Models.ComponentsInstances.ComponentInstance; - public selectedMatch:Array<any>; //match array returned by function in utils - public requirements:any; //array of matches returned by function in utils - public capabilities:any; //array of matches returned by function in utils - - constructor(componentInstance:Models.ComponentsInstances.ComponentInstance) { - this.componentInstance = componentInstance; - this.capabilities = {}; - this.requirements = {}; - } - - public selectMatchArr(matchArr:Array<Models.MatchBase>):void { - if (this.selectedMatch === matchArr) { - this.selectedMatch = undefined; - } else { - this.selectedMatch = matchArr; - } - } - - - //TODO move to match object - public getPreviewText(showReq:boolean):string { - if (!this.selectedMatch) { - return ''; - } - - let match:any = this.selectedMatch[0]; - if (showReq) { - return match.requirement.ownerName + ': ' + match.requirement.name + - ': [' + match.requirement.minOccurrences + ', ' + match.requirement.maxOccurrences + ']'; - } else if (match.secondRequirement) { - return match.secondRequirement.ownerName + ': ' + match.secondRequirement.name + - ': [' + match.secondRequirement.minOccurrences + ', ' + match.secondRequirement.maxOccurrences + ']'; - } - else { - return match.capability.ownerName + ': ' + match.capability.name + - ': [' + match.capability.minOccurrences + ', ' + match.capability.maxOccurrences + ']'; - } - } - } - -} diff --git a/catalog-ui/app/scripts/models/graph/relationship.ts b/catalog-ui/app/scripts/models/graph/relationship.ts deleted file mode 100644 index e0dfbbd6d1..0000000000 --- a/catalog-ui/app/scripts/models/graph/relationship.ts +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class RelationshipModel { - fromNode:string; - toNode:string; - relationships:Array<Relationship>; - - constructor(relationshipModel?:RelationshipModel, singleRelationship?:Relationship) { - if(relationshipModel){ - this.fromNode = relationshipModel.fromNode; - this.toNode = relationshipModel.toNode; - this.relationships = []; - if (relationshipModel.relationships && !singleRelationship) { - _.forEach(relationshipModel.relationships, (relation:Models.Relationship):void => { - this.relationships.push(new Models.Relationship(relation)); - }); - }else if(singleRelationship){ - this.relationships.push(singleRelationship); - } - } - } - - public setRelationshipModelParams (fromNode: string, toNode:string, relationships:Array<Relationship>) { - this.fromNode = fromNode; - this.toNode = toNode; - this.relationships = relationships; - } - } - - export class RelationType { - type:string; - - constructor(type?:string) { - if(type){ - this.type = type; - } - } - } - - export class Relationship { - capability:string; - capabilityOwnerId:string; - capabilityUid:string; - relationship:RelationType; - requirement:string; - requirementOwnerId:string; - requirementUid:string; - - constructor(relationship?:Models.Relationship) { - if(relationship) { - this.capability = relationship.capability; - this.capabilityOwnerId = relationship.capabilityOwnerId; - this.capabilityUid = relationship.capabilityUid; - this.relationship = new RelationType(relationship.relationship.type); - this.requirement = relationship.requirement; - this.requirementOwnerId = relationship.requirementOwnerId; - this.requirementUid = relationship.requirementUid; - } else { - this.relationship = new RelationType(); - } - - } - - //public setRelationProperties = (capability:string, capabilityOwnerId:string, capabilityUid:string, relationship:RelationType, requirement:string, requirementOwnerId:string, requirementUid:string )=>{ - // this.capability = capability; - // this.capabilityOwnerId = capabilityOwnerId; - // this.capabilityUid = capabilityUid; - // this.relationship = relationship; - // this.requirement =requirement; - // this.requirementOwnerId = requirementOwnerId; - // this.requirementUid = requirementUid; - //} - - - public setRelationProperties = (capability:Models.Capability, requirement:Models.Requirement)=>{ - this.capability = capability.name; - this.capabilityOwnerId = capability.ownerId; - this.capabilityUid = capability.uniqueId; - this.relationship = new Models.RelationType(capability.type); - this.requirement = requirement.name; - this.requirementOwnerId = requirement.ownerId; - this.requirementUid = requirement.uniqueId; - }; - - } -} diff --git a/catalog-ui/app/scripts/models/inputs.ts b/catalog-ui/app/scripts/models/inputs.ts deleted file mode 100644 index 68e26e246e..0000000000 --- a/catalog-ui/app/scripts/models/inputs.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 8/24/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class InputModel { - - //server data - uniqueId:string; - name:string; - type:string; - password:boolean; - required:boolean; - definition:boolean; - parentUniqueId:string; - description:string; - componentInstanceName:string; - componentInstanceId:string; - - //costom properties - isNew: boolean; - properties:Array<Models.PropertyModel>; - inputs:Array<Models.InputModel>; - isAlreadySelected: boolean; - filterTerm: string; - - constructor(input:InputModel) { - if (input) { - this.uniqueId = input.uniqueId; - this.name = input.name; - this.type = input.type; - this.description = input.description; - this.password = input.password; - this.required = input.required; - this.definition = input.definition; - this.parentUniqueId = input.parentUniqueId; - this.description = input.description; - this.componentInstanceName = input.componentInstanceName; - this.componentInstanceId = input.componentInstanceId; - this.filterTerm = this.name + ' ' + this.description + ' ' + this.type + ' ' + this.componentInstanceName; - } - } - - public toJSON = ():any => { - this.isNew = undefined; - this.properties = undefined; - this.inputs = undefined; - this.isAlreadySelected = undefined; - this.filterTerm = undefined; - return this; - }; - } -} diff --git a/catalog-ui/app/scripts/models/instance-inputs-properties-map.ts b/catalog-ui/app/scripts/models/instance-inputs-properties-map.ts deleted file mode 100644 index 2c67dfd718..0000000000 --- a/catalog-ui/app/scripts/models/instance-inputs-properties-map.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 9/12/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class InstanceInputsPropertiesMapData { - [instanceId:string]: Array<PropertyModel>; - } - - export class InstanceInputsPropertiesMap { - componentInstanceInputsProperties:InstanceInputsPropertiesMapData; - - constructor(componentInstanceInputsPropertiesMapData:InstanceInputsPropertiesMapData) { - this.componentInstanceInputsProperties = componentInstanceInputsPropertiesMapData; - } - } - -} diff --git a/catalog-ui/app/scripts/models/instances-inputs-map.ts b/catalog-ui/app/scripts/models/instances-inputs-map.ts deleted file mode 100644 index 1643a125ae..0000000000 --- a/catalog-ui/app/scripts/models/instances-inputs-map.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 9/12/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class InstancesInputsMapData { - [instanceId:string]: Array<InputModel>; - } - - export class InstancesInputsMap { - componentInstanceInputsMap:InstancesInputsMapData; - - constructor(componentInstanceInputsMapData:InstancesInputsMapData) { - this.componentInstanceInputsMap = componentInstanceInputsMapData; - } - } - -} diff --git a/catalog-ui/app/scripts/models/left-panel.ts b/catalog-ui/app/scripts/models/left-panel.ts deleted file mode 100644 index a47170c7c2..0000000000 --- a/catalog-ui/app/scripts/models/left-panel.ts +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class LeftPanelModel { - numberOfElements:number; - sortedCategories:any; - - constructor() { - this.numberOfElements = 0; - this.sortedCategories = {}; - } - } -} diff --git a/catalog-ui/app/scripts/models/member.ts b/catalog-ui/app/scripts/models/member.ts deleted file mode 100644 index 21dc907333..0000000000 --- a/catalog-ui/app/scripts/models/member.ts +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 8/2/2016. - */ - -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class Members { - - [index: string]: string; - - constructor(members?:Members) { - _.forEach(members, (memberId:string, index) => { - this[index] = memberId; - }); - } - } -} - diff --git a/catalog-ui/app/scripts/models/modules/base-module.ts b/catalog-ui/app/scripts/models/modules/base-module.ts deleted file mode 100644 index 2df52cc907..0000000000 --- a/catalog-ui/app/scripts/models/modules/base-module.ts +++ /dev/null @@ -1,108 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Models { - 'use strict'; - - export class Module { - - public name:string; - public groupUUID:string; - public invariantUUID:string; - public propertyValueCounter:number; - public type:string; - public typeUid:string; - public uniqueId:string; - public version: string; - public artifacts: Array<string> | Array<Models.ArtifactModel>; - public artifactsUuid: Array<string>; - public properties: Array<Models.PropertyModel>; - public members: Array<string>; - - - constructor(module?: Module) { - if(module) { - this.name = module.name; - this.groupUUID = module.groupUUID; - this.invariantUUID = module.invariantUUID; - this.propertyValueCounter = module.propertyValueCounter; - this.type = module.type; - this.typeUid = module.typeUid; - this.uniqueId = module.uniqueId; - this.version = module.version; - this.artifacts = module.artifacts; - this.artifactsUuid = module.artifactsUuid; - this.properties = Utils.CommonUtils.initProperties(module.properties); - this.members = module.members; - - this.name = this.name.replace(/:/g, '..'); - - } - } - } - - export class DisplayModule extends Module { - - isBase: string; - artifacts:Array<Models.ArtifactModel>; - - //custom properties - public vfInstanceName: string; - public heatName: string; - public moduleName: string; - - constructor(displayModule?:Models.DisplayModule) { - super(displayModule); - - this.isBase = displayModule.isBase; - this.initArtifactsForDisplay(displayModule.artifacts); - - //splitting module name for display and edit - let splitName:Array<string> = this.name.split('..'); - this.vfInstanceName = splitName[0]; - this.heatName = splitName[1]; - this.moduleName = splitName[2]; - } - - private initArtifactsForDisplay = (artifacts:Array<Models.ArtifactModel>):void => { - this.artifacts = new Array<Models.ArtifactModel>(); - _.forEach(artifacts, (artifact:Models.ArtifactModel) => { - this.artifacts.push(new Models.ArtifactModel(artifact)); - }); - }; - - public updateName = ():void => { - this.name = this.vfInstanceName + '..' + this.heatName + '..' + this.moduleName; - }; - - public toJSON = ():any => { - this.vfInstanceName = undefined; - this.heatName = undefined; - this.moduleName = undefined; - this.isBase = undefined; - this.artifacts = undefined; - return this; - }; - } -} diff --git a/catalog-ui/app/scripts/models/properties.ts b/catalog-ui/app/scripts/models/properties.ts deleted file mode 100644 index 679ca03b44..0000000000 --- a/catalog-ui/app/scripts/models/properties.ts +++ /dev/null @@ -1,176 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class PropertiesGroup { - constructor(propertiesObj?:Models.PropertiesGroup){ - _.forEach(propertiesObj, (properties:Array<Models.PropertyModel>, instance) => { - this[instance] = []; - _.forEach(properties, (property:Models.PropertyModel):void => { - property.resourceInstanceUniqueId = instance; - property.readonly = true; - this[instance].push(new Models.PropertyModel(property)); - }); - }); - } - } - - export interface IPropertyModel { - - //server data - uniqueId: string; - name: string; - constraints: Array<Object>; - defaultValue: string; - description: string; - password: boolean; - required: boolean; - type: string; - source: string; - parentUniqueId: string; - schema: Models.SchemaPropertyGroupModel; - - //instance properties - value:string; - valueUniqueUid:string; - path:Array<string>; - rules:Array<Object>; - - //custom properties - resourceInstanceUniqueId: string; - readonly: boolean; - simpleType: string; - } - - export class PropertyModel implements IPropertyModel{ - - //server data - uniqueId:string; - name:string; - constraints:Array<Object>; - defaultValue:string; - description:string; - password:boolean; - required:boolean; - type:string; - source:string; - parentUniqueId:string; - schema: Models.SchemaPropertyGroupModel; - - //instance properties - value:string; - valueUniqueUid:string; - path:Array<string>; - rules:Array<Object>; - - //custom properties - resourceInstanceUniqueId:string; - readonly:boolean; - simpleType: string; - filterTerm: string; - isAlreadySelected: boolean; - - constructor(property?:Models.PropertyModel) { - if (property) { - this.uniqueId = property.uniqueId; - this.name = property.name; - this.constraints = property.constraints; - this.defaultValue = property.defaultValue; - this.description = property.description; - this.password = property.password; - this.required = property.required; - this.type = property.type; - this.source = property.source; - this.parentUniqueId = property.parentUniqueId; - this.schema = property.schema; - this.value = property.value?property.value:property.defaultValue; - this.valueUniqueUid = property.valueUniqueUid; - this.path = property.path; - this.rules = property.rules; - this.resourceInstanceUniqueId = property.resourceInstanceUniqueId; - this.readonly = property.readonly; - this.simpleType = property.simpleType; - - - } - - if(!this.schema || !this.schema.property) { - this.schema = new Models.SchemaPropertyGroupModel(new Models.SchemaProperty()); - } else { - //forcing creating new object, so editing different one than the object in the table - this.schema = new Models.SchemaPropertyGroupModel(new Models.SchemaProperty(this.schema.property)); - } - if(property) { - this.filterTerm = this.name + " " + (this.description||"") +" " + this.type; - if(this.schema.property && this.schema.property.type) { - this.filterTerm += " " +this.schema.property.type; - } - } - } - - public convertToServerObject:Function = ():string => { - let serverObject = {}; - let mapData = { - "type": this.type, - "required": this.required || false, - "defaultValue": this.defaultValue != "" && this.defaultValue != "[]" && this.defaultValue != "{}" ? this.defaultValue :null, - "description": this.description, - "constraints": this.constraints, - "isPassword": this.password || false, - "schema": this.schema, - "name": this.name - }; - serverObject[this.name] = mapData; - - return JSON.stringify(serverObject); - }; - - - // public convertValueToView () { - // //unwrapping value {} or [] if type is complex - // if (this.defaultValue && (this.type === 'map' || this.type === 'list') && - // ['[','{'].indexOf(this.defaultValue.charAt(0)) > -1 && - // [']','}'].indexOf(this.defaultValue.slice(-1)) > -1) { - // this.defaultValue = this.defaultValue.slice(1, -1); - // } - // - // //also for value - for the modal in canvas - // if (this.value && (this.type === 'map' || this.type === 'list') && - // ['[','{'].indexOf(this.value.charAt(0)) > -1 && - // [']','}'].indexOf(this.value.slice(-1)) > -1) { - // this.value = this.value.slice(1, -1); - // } - // } - - public toJSON = ():any => { - if(!this.resourceInstanceUniqueId){ - this.value = undefined; - } - this.readonly = undefined; - this.resourceInstanceUniqueId = undefined; - this.simpleType = undefined; - this.value = this.value === "{}" || this.value === "[]" ? undefined: this.value; - this.defaultValue = this.defaultValue === "{}" || this.defaultValue === "[]" ? undefined: this.defaultValue; - return this; - }; - } -} diff --git a/catalog-ui/app/scripts/models/requirement.ts b/catalog-ui/app/scripts/models/requirement.ts deleted file mode 100644 index 091bfc139e..0000000000 --- a/catalog-ui/app/scripts/models/requirement.ts +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - /* - * Created by obarda on 4/20/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - //this is an object contains keys, when each key has matching array. - // for example: key = tosca.capabilities.network. and the match array is array of requirements objects - export class RequirementsGroup{ - constructor(requirementGroupObj?:Models.RequirementsGroup){ - _.forEach(requirementGroupObj, (requirementsArrayObj:Array<Models.Requirement>, instance) => { - this[instance] = []; - _.forEach(requirementsArrayObj, (requirement:Models.Requirement):void => { - this[instance].push(new Models.Requirement(requirement)); - }); - }); - } - } - - export class Requirement { - - //server data - capability:string; - name: string; - ownerId: string; - ownerName:string; - node:string; - uniqueId:string; - relationship: string; - minOccurrences: string; - maxOccurrences: string; - //custom - filterTerm:string; - constructor(requirement?:Requirement) { - - if(requirement) { - this.capability = requirement.capability; - this.name = requirement.name; - this.ownerId = requirement.ownerId; - this.ownerName = requirement.ownerName; - this.node = requirement.node; - this.uniqueId = requirement.uniqueId; - this.relationship = requirement.relationship; - this.minOccurrences = requirement.minOccurrences; - this.maxOccurrences = requirement.maxOccurrences; - this.initFilterTerm(); - - } - } - - public getFullTitle():string { - return this.ownerName + ': ' + this.name + - ': [' + this.minOccurrences + ', ' + this.maxOccurrences + ']'; - } - - public toJSON = ():any => { - this.filterTerm = undefined; - return this; - }; - - private initFilterTerm = ():void =>{ - this.filterTerm = (this.name + " ") + - (this.ownerName + " " ) + - (this.capability ? (this.capability.substring("tosca.capabilities.".length) + " " ) : "") + - (this.node? (this.node.substring("tosca.nodes.".length) +" ") : "") + - (this.relationship? (this.relationship.substring("tosca.relationships.".length) +" ") : "") + - this.minOccurrences+","+this.maxOccurrences; - } - } -} - - diff --git a/catalog-ui/app/scripts/models/tab.ts b/catalog-ui/app/scripts/models/tab.ts deleted file mode 100644 index cc42d4f348..0000000000 --- a/catalog-ui/app/scripts/models/tab.ts +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/31/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class Tab { - - public templateUrl:string; - public controller:string; - public data:any; - public icon:string; - public name:string; - - constructor(templateUrl:string, controller:string, name:string, data?:any, icon?:string) { - - this.templateUrl = templateUrl; - this.controller = controller; - this.icon = icon; - this.data = data; - this.name = name; - } - } -} - - - diff --git a/catalog-ui/app/scripts/models/tooltip-data.ts b/catalog-ui/app/scripts/models/tooltip-data.ts deleted file mode 100644 index 027904b245..0000000000 --- a/catalog-ui/app/scripts/models/tooltip-data.ts +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export class TooltipData{ - } -} - - diff --git a/catalog-ui/app/scripts/models/user.ts b/catalog-ui/app/scripts/models/user.ts deleted file mode 100644 index 836066f5f9..0000000000 --- a/catalog-ui/app/scripts/models/user.ts +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export enum UserRole { - ADMIN, - DESIGNER, - TESTER, - GOVERNOR, - OPS, - PRODUCT_MANAGER, - PRODUCT_STRATEGIST - } - - export interface IUserManager { - isInEditMode: boolean; - filterTerm: string; - } - - export interface IUserProperties extends IUserManager{ - firstName: string; - lastName: string; - userId: string; - email: string; - role: string; - tempRole:string; - lastLoginTime: string; - status:string; - } - - export interface IUser { - resource: Services.IUserResource; - getRole(): UserRole; - getRoleToView(): string; - getName(): string; - getFirstName(): string; - getLastName(): string; - } - - export class User implements IUser { - - constructor(public resource:Services.IUserResource) { - } - - public getLastName = () => { - return this.resource.lastName; - } - - public getFirstName = () => { - return this.resource.firstName; - } - - public getName = () => { - return this.resource.firstName + ' ' + this.resource.lastName; - } - - public getLastLogin = () => { - if (!this.resource.lastLoginTime || this.resource.lastLoginTime === "0") { - return ""; - } else { - return this.resource.lastLoginTime; - } - } - - public getRole = ():UserRole => { - let role:UserRole; - switch (UserRole[this.resource.role.toUpperCase()]) { - case UserRole.ADMIN: - role = UserRole.ADMIN; - break; - case UserRole.DESIGNER: - role = UserRole.DESIGNER; - break; - case UserRole.TESTER: - role = UserRole.TESTER; - break; - case UserRole.GOVERNOR: - role = UserRole.GOVERNOR; - break; - case UserRole.OPS: - role = UserRole.OPS; - break; - case UserRole.PRODUCT_MANAGER: - role = UserRole.PRODUCT_MANAGER; - break; - case UserRole.PRODUCT_STRATEGIST: - role = UserRole.PRODUCT_STRATEGIST; - break; - } - return role; - } - - public getRoleToView = ():string => { - let role:string = this.resource.role.toLowerCase().replace('governor','governance_Rep'); - return role.charAt(0).toUpperCase() + role.slice(1).replace('_',' '); - } - } -} diff --git a/catalog-ui/app/scripts/models/validate.ts b/catalog-ui/app/scripts/models/validate.ts deleted file mode 100644 index 21540d38b6..0000000000 --- a/catalog-ui/app/scripts/models/validate.ts +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - - export interface IValidate{ - isValid : boolean; - } -} - - diff --git a/catalog-ui/app/scripts/modules/directive-module.ts b/catalog-ui/app/scripts/modules/directive-module.ts deleted file mode 100644 index 70a15378fa..0000000000 --- a/catalog-ui/app/scripts/modules/directive-module.ts +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc { - let moduleName:string = 'Sdc.Directives'; - let directiveModule:ng.IModule = angular.module(moduleName, []); - - directiveModule.directive('clickedOutside', Directives.ClickedOutsideDirective.factory); - directiveModule.directive('loader', Directives.LoaderDirective.factory); - directiveModule.directive('userHeaderDetails', Directives.UserHeaderDetailsDirective.factory); - directiveModule.directive('ellipsis', Directives.EllipsisDirective.factory); - directiveModule.directive('downloadArtifact', Directives.DownloadArtifactDirective.factory); - directiveModule.directive('fileType', Directives.FileTypeDirective.factory); - directiveModule.directive('invalidCharacters', Directives.InvalidCharactersDirective.factory); - directiveModule.directive('tutorial', Directives.TutorialDirective.factory); - directiveModule.directive('perfectScrollbar', Directives.PerfectScrollerDirective.factory); - directiveModule.directive('expandCollapse', Directives.ExpandCollapseDirective.factory); - directiveModule.directive('sdcModal', Directives.SdcModalDirective.factory); - directiveModule.directive('sdcMessages', Directives.SdcMessagesDirective.factory); - directiveModule.directive('sdcMessage', Directives.SdcMessageDirective.factory); - directiveModule.directive('sdcErrorTooltip', Directives.SdcErrorTooltipDirective.factory); - directiveModule.directive('fileOpener', Directives.FileOpenerDirective.factory); - directiveModule.directive('fileUpload', Directives.FileUploadDirective.factory); - directiveModule.directive('structureTree', Directives.StructureTreeDirective.factory); - directiveModule.directive('sdcWizardStep', Directives.SdcWizardStepDirective.factory); - directiveModule.directive('sdcPageSelector', Directives.PageSelectorDirective.factory); - directiveModule.directive('sdcSmartTooltip', Directives.SmartTooltipDirective.factory); - directiveModule.directive('printGraphScreen', Directives.PrintGraphScreenDirective.factory); - directiveModule.directive('sdcTag', Directives.TagDirective.factory); - directiveModule.directive('sdcTags', Directives.SdcTagsDirective.factory); - directiveModule.directive('sdcKeyboardEvents', Directives.SdcKeyboardEventsDirective.factory); - directiveModule.directive('expandCollapseMenuBox', Directives.ExpandCollapseMenuBoxDirective.factory); - directiveModule.directive('sdcPageScroll', Directives.SdcPageScrollDirective.factory); - directiveModule.directive('punchOut', Directives.PunchOutDirective.factory); - directiveModule.directive('relationMenu', Directives.RelationMenuDirective.factory); - directiveModule.directive('customValidation', Directives.CustomValidationDirective.factory); - directiveModule.directive('ecompHeader', Directives.EcompHeaderDirective.factory); - directiveModule.directive('editNamePopover', Directives.EditNamePopoverDirective.factory); - directiveModule.directive('fieldsStructure', Directives.DataTypeFieldsStructureDirective.factory); - directiveModule.directive('typeMap', Directives.TypeMapDirective.factory); - directiveModule.directive('typeList', Directives.TypeListDirective.factory); - directiveModule.directive('infoTooltip', Directives.InfoTooltipDirective.factory); - - directiveModule.directive('sdcTabs', Directives.SdcTabsDirective.factory); - directiveModule.directive('sdcSingleTab', Directives.SdcSingleTabDirective.factory); - directiveModule.directive('innerSdcSingleTab', Directives.InnerSdcSingleTabDirective.factory); - - //composition - directiveModule.directive('palette', Directives.Palette.factory); - directiveModule.directive('compositionGraph', Directives.CompositionGraph.factory); - - //deployment - directiveModule.directive('deploymentGraph', Directives.DeploymentGraph.factory); - - // Layouts - directiveModule.directive('topNav', Directives.TopNavDirective.factory); - directiveModule.directive('topProgress', Directives.TopProgressDirective.factory); - - // Elements - directiveModule.directive('sdcCheckbox', Directives.CheckboxElementDirective.factory); - directiveModule.directive('sdcRadioButton', Directives.RadiobuttonElementDirective.factory); - - //Graph Utils - Common - directiveModule.service('CommonGraphUtils', Sdc.Graph.Utils.CommonGraphUtils); - - //Composition Graph Utils - directiveModule.service('CompositionGraphNodesUtils', Sdc.Graph.Utils.CompositionGraphNodesUtils); - directiveModule.service('CompositionGraphGeneralUtils', Sdc.Graph.Utils.CompositionGraphGeneralUtils); - directiveModule.service('CompositionGraphLinkUtils', Sdc.Graph.Utils.CompositionGraphLinkUtils); - directiveModule.service('MatchCapabilitiesRequirementsUtils', Sdc.Graph.Utils.MatchCapabilitiesRequirementsUtils); - - //Composition Graph Utils - directiveModule.service('DeploymentGraphGeneralUtils', Sdc.Graph.Utils.DeploymentGraphGeneralUtils); - - //Util service for graph - directiveModule.service('NodesFactory', Sdc.Utils.NodesFactory); - directiveModule.service('LinksFactory', Sdc.Utils.LinksFactory); - directiveModule.service('ImageCreatorService', Sdc.Utils.ImageCreatorService); - - //directiveModule.service('GraphUtilsServerUpdateQueue', Sdc.Directives.GraphUtilsServerUpdateQueue); - - //controller for go.js - directiveModule.controller('SdcWizardStepDirectiveController', Directives.SdcWizardStepDirectiveController); - - // Events - directiveModule.directive('onLastRepeat', Directives.OnLastRepeatDirective.factory); -} - - diff --git a/catalog-ui/app/scripts/modules/filters.ts b/catalog-ui/app/scripts/modules/filters.ts deleted file mode 100644 index 1bf31507fd..0000000000 --- a/catalog-ui/app/scripts/modules/filters.ts +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc { - - let moduleName: string = 'Sdc.Filters'; - let filterModule: ng.IModule = angular.module(moduleName, []); - filterModule.filter("resourceName", Sdc.Filters.ResourceNameFilter); - filterModule.filter("graphResourceName", Sdc.Filters.GraphResourceNameFilter); - filterModule.filter("categoryNameFilter", Sdc.Filters.CategoryNameFilter); - filterModule.filter("entityFilter", Sdc.Filters.EntityFilter); - filterModule.filter("truncate", Sdc.Filters.TruncateFilter); - filterModule.filter("catalogStatusFilter", Sdc.Filters.CatalogStatusFilter); - filterModule.filter("categoryTypeFilter", Sdc.Filters.CategoryTypeFilter); - filterModule.filter("stringToDateFilter", Sdc.Filters.StringToDateFilter); - filterModule.filter("categoryIcon", Sdc.Filters.CategoryIconFilter); - filterModule.filter("capitalizeFilter", Sdc.Filters.CapitalizeFilter); - filterModule.filter("underscoreLessFilter", Sdc.Filters.UnderscoreLessFilter); - filterModule.filter("resourceTypeName", Sdc.Filters.ResourceTypeFilter); - filterModule.filter("relationName", Sdc.Filters.RelationNameFilter); - filterModule.filter("trim", Sdc.Filters.TrimFilter); - filterModule.filter("clearWhiteSpaces", Sdc.Filters.ClearWhiteSpacesFilter); - filterModule.filter('testsId', Sdc.Filters.TestsIdFilter); - - //Added by Ikram - filterModule.filter("productCategoryNameFilter", Sdc.Filters.ProductCategoryNameFilter); -} diff --git a/catalog-ui/app/scripts/modules/service-module.ts b/catalog-ui/app/scripts/modules/service-module.ts deleted file mode 100644 index c77e8b0ad4..0000000000 --- a/catalog-ui/app/scripts/modules/service-module.ts +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc { - let moduleName:string = 'Sdc.Services'; - let serviceModule:ng.IModule = angular.module(moduleName, []); - - serviceModule.service('Sdc.Services.ConfigurationUiService', Services.ConfigurationUiService); - serviceModule.service('Sdc.Services.CookieService', Services.CookieService); - serviceModule.service('Sdc.Services.EntityService', Services.EntityService); - serviceModule.service('Sdc.Services.AvailableIconsService', Services.AvailableIconsService); - serviceModule.service('Sdc.Services.RelationIconsService', Services.RelationIconsService); - serviceModule.service('Sdc.Services.UrlToBase64Service', Services.UrlToBase64Service); - serviceModule.service('Sdc.Services.CacheService', Services.CacheService); - serviceModule.service('Sdc.Services.HeaderInterceptor', Services.HeaderInterceptor); - serviceModule.service('Sdc.Services.HttpErrorInterceptor', Services.HttpErrorInterceptor); - serviceModule.service('Sdc.Services.SharingService', Services.SharingService); - serviceModule.service('Sdc.Services.SdcVersionService', Services.SdcVersionService); - serviceModule.service('Sdc.Services.ActivityLogService', Services.ActivityLogService); - serviceModule.service('Sdc.Services.OnboardingService', Services.OnboardingService); - serviceModule.service('Sdc.Services.EcompHeaderService', Services.EcompHeaderService); - serviceModule.service('Sdc.Services.DataTypesService', Services.DataTypesService); - - //Components Services - serviceModule.service('Sdc.Services.Components.ComponentService', Services.Components.ComponentService); - serviceModule.service('Sdc.Services.Components.ServiceService', Services.Components.ServiceService); - serviceModule.service('Sdc.Services.Components.ResourceService', Services.Components.ResourceService); - serviceModule.service('Sdc.Services.Components.ProductService', Services.Components.ProductService); - serviceModule.service('LeftPaletteLoaderService', Services.Components.LeftPaletteLoaderService); - serviceModule.service('EventListenerService', Services.EventListenerService); - serviceModule.service('Sdc.Services.ProgressService', Services.ProgressService); - - //Utils - serviceModule.service('ArtifactsUtils', Sdc.Utils.ArtifactsUtils); - serviceModule.service('FileUtils', Sdc.Utils.FileUtils); - serviceModule.service('ValidationUtils', Sdc.Utils.ValidationUtils); - - - - - serviceModule.service('AngularJSBridge', Sdc.Services.AngularJSBridge); - serviceModule.service('LoaderService', Sdc.Services.LoaderService); - - serviceModule.factory('Sdc.Services.UserResourceService', Services.UserResourceService.getResource); - serviceModule.factory('Sdc.Services.CategoryResourceService', Services.CategoryResourceService.getResource); - -} diff --git a/catalog-ui/app/scripts/modules/view-model-module.ts b/catalog-ui/app/scripts/modules/view-model-module.ts deleted file mode 100644 index 19cf5b45f4..0000000000 --- a/catalog-ui/app/scripts/modules/view-model-module.ts +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc { - let moduleName: string = 'Sdc.ViewModels'; - let viewModelModule: ng.IModule = angular.module(moduleName, []); - - viewModelModule - .controller(moduleName+'.DashboardViewModel', ViewModels.DashboardViewModel) - .controller(moduleName+'.CompositionViewModel', ViewModels.CompositionViewModel) - - .controller(moduleName+'.DetailsViewModel', ViewModels.DetailsViewModel) - .controller(moduleName+'.ResourceArtifactsViewModel', ViewModels.ResourceArtifactsViewModel) - .controller(moduleName+'.PropertyFormViewModel', ViewModels.PropertyFormViewModel) - .controller(moduleName+'.ArtifactResourceFormViewModel', ViewModels.ArtifactResourceFormViewModel) - .controller(moduleName+'.AttributeFormViewModel', ViewModels.AttributeFormViewModel) - .controller(moduleName+'.ResourcePropertiesViewModel', ViewModels.ResourcePropertiesViewModel) - .controller(moduleName+'.CatalogViewModel', ViewModels.CatalogViewModel) - .controller(moduleName+'.OnboardVendorViewModel', ViewModels.OnboardVendorViewModel) - .controller(moduleName+'.DistributionViewModel', ViewModels.DistributionViewModel) - .controller(moduleName+'.SupportViewModel', ViewModels.SupportViewModel) - .controller(moduleName+'.ConfirmationModalViewModel', ViewModels.ConfirmationModalViewModel) - .controller(moduleName+'.EmailModalViewModel', ViewModels.EmailModalViewModel) - .controller(moduleName+'.MessageModalViewModel', ViewModels.MessageModalViewModel) - .controller(moduleName+'.ServerMessageModalViewModel', ViewModels.ServerMessageModalViewModel) - .controller(moduleName+'.ClientMessageModalViewModel', ViewModels.ClientMessageModalViewModel) - .controller(moduleName+'.ErrorViewModel', ViewModels.ErrorViewModel) - .controller(moduleName+'.ComponentViewerViewModel', ViewModels.ComponentViewerViewModel) - .controller(moduleName+'.RelationsViewModel', ViewModels.RelationsViewModel) - .controller(moduleName+'.ResourceInstanceNameViewModel', ViewModels.ResourceInstanceNameViewModel) - .controller(moduleName+'.WelcomeViewModel', ViewModels.WelcomeViewModel) - .controller(moduleName+'.PreLoadingViewModel', ViewModels.PreLoadingViewModel) - .controller(moduleName+'.TutorialEndViewModel', ViewModels.TutorialEndViewModel) - .controller(moduleName+'.AdminDashboardViewModel', ViewModels.AdminDashboardViewModel) - .controller(moduleName+'.EnvParametersFormViewModel', ViewModels.EnvParametersFormViewModel) - .controller(moduleName+'.StructureViewModel', ViewModels.StructureViewModel) - .controller(moduleName+'.AddCategoryModalViewModel', ViewModels.AddCategoryModalViewModel) - .controller(moduleName+'.DashboardCoverViewModel', ViewModels.DashboardCoverViewModel) - .controller(moduleName+'.UserManagementViewModel', ViewModels.UserManagementViewModel) - .controller(moduleName+'.CategoryManagementViewModel', ViewModels.CategoryManagementViewModel) - .controller(moduleName+'.WelcomeStepsControllerViewModel', ViewModels.WelcomeStepsControllerViewModel) - .controller(moduleName+'.OnboardingModalViewModel', ViewModels.OnboardingModalViewModel) - .controller(moduleName+'.DistributionStatusModalViewModel', ViewModels.DistributionStatusModalViewModel) - - .controller(moduleName+'.Wizard.EditWizardViewModel', ViewModels.Wizard.EditWizardViewModel) - .controller(moduleName+'.Wizard.CreateWizardViewModel', ViewModels.Wizard.CreateWizardViewModel) - .controller(moduleName+'.Wizard.ImportWizardViewModel', ViewModels.Wizard.ImportWizardViewModel) - .controller(moduleName+'.Wizard.GeneralStepViewModel', ViewModels.Wizard.GeneralStepViewModel) - .controller(moduleName+'.Wizard.IconsStepViewModel', ViewModels.Wizard.IconsStepViewModel) - .controller(moduleName+'.Wizard.ArtifactInformationStepViewModel', ViewModels.Wizard.ArtifactInformationStepViewModel) - .controller(moduleName+'.Wizard.ArtifactDeploymentStepViewModel', ViewModels.Wizard.ArtifactDeploymentStepViewModel) - .controller(moduleName+'.Wizard.PropertiesStepViewModel', ViewModels.Wizard.PropertiesStepViewModel) - .controller(moduleName+'.Wizard.ArtifactResourceFormStepViewModel', ViewModels.Wizard.ArtifactResourceFormStepViewModel) - .controller(moduleName+'.Wizard.PropertyFormViewModel', ViewModels.Wizard.PropertyFormViewModel) - .controller(moduleName+'.Wizard.HierarchyStepViewModel',ViewModels.Wizard.HierarchyStepViewModel) - - //NEW - .controller(moduleName+'.WorkspaceViewModel', ViewModels.WorkspaceViewModel) - .controller(moduleName+'.GeneralViewModel', ViewModels.GeneralViewModel) - .controller(moduleName+'.IconsViewModel', ViewModels.IconsViewModel) - .controller(moduleName+'.DeploymentArtifactsViewModel', ViewModels.DeploymentArtifactsViewModel) - .controller(moduleName+'.InformationArtifactsViewModel', ViewModels.InformationArtifactsViewModel) - .controller(moduleName+'.ToscaArtifactsViewModel', ViewModels.ToscaArtifactsViewModel) - .controller(moduleName+'.PropertiesViewModel', ViewModels.PropertiesViewModel) - .controller(moduleName+'.AttributesViewModel', ViewModels.AttributesViewModel) - .controller(moduleName+'.ProductHierarchyViewModel',ViewModels.ProductHierarchyViewModel) - .controller(moduleName+'.ActivityLogViewModel',ViewModels.ActivityLogViewModel) - .controller(moduleName+'.ManagementWorkflowViewModel',ViewModels.ManagementWorkflowViewModel) - .controller(moduleName+'.NetworkCallFlowViewModel',ViewModels.NetworkCallFlowViewModel) - .controller(moduleName+'.DeploymentViewModel',ViewModels.DeploymentViewModel) - .controller(moduleName+'.ResourceInputsViewModel',ViewModels.ResourceInputsViewModel) - .controller(moduleName+'.ServiceInputsViewModel', ViewModels.ServiceInputsViewModel) - .controller(moduleName+'.ReqAndCapabilitiesViewModel', ViewModels.ReqAndCapabilitiesViewModel) - - - - //TABS - .controller(moduleName+'.HierarchyViewModel',ViewModels.HierarchyViewModel) -} diff --git a/catalog-ui/app/scripts/services/activity-log-service.ts b/catalog-ui/app/scripts/services/activity-log-service.ts deleted file mode 100644 index 6fe27c447e..0000000000 --- a/catalog-ui/app/scripts/services/activity-log-service.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - // Define an interface of the object you want to use, providing it's properties - export interface IActivityLogService{ - getActivityLogService(type :string, id: string): ng.IPromise<Array<Models.Activity>>; - } - - export class ActivityLogService implements IActivityLogService{ - - - static '$inject' = ['$http', '$q','sdcConfig']; - private api: Models.IApi; - - constructor(private $http: ng.IHttpService, private $q: ng.IQService, sdcConfig: Models.IAppConfigurtaion){ - this.api = sdcConfig.api; - } - - getActivityLogService = (type:string, id:string): ng.IPromise<Array<Models.Activity>> =>{ - let defer = this.$q.defer<any>(); - this.$http.get(this.api.root + this.api.GET_activity_log.replace(':type', type).replace(':id', id)) - .success((activityLog: any) => { - defer.resolve(activityLog); - }); - return defer.promise; - } - } -} diff --git a/catalog-ui/app/scripts/services/angular-js-bridge-service.ts b/catalog-ui/app/scripts/services/angular-js-bridge-service.ts deleted file mode 100644 index 2d8fb01b13..0000000000 --- a/catalog-ui/app/scripts/services/angular-js-bridge-service.ts +++ /dev/null @@ -1,22 +0,0 @@ -module Sdc.Services { - export class AngularJSBridge{ - private static _$filter: ng.IFilterService; - private static _sdcConfig: Models.IAppConfigurtaion; - - public static getFilter(filterName: string){ - return AngularJSBridge._$filter(filterName); - } - - public static getAngularConfig(){ - return AngularJSBridge._sdcConfig; - } - - - constructor($filter: ng.IFilterService, sdcConfig: Models.IAppConfigurtaion){ - AngularJSBridge._$filter = $filter; - AngularJSBridge._sdcConfig = sdcConfig; - } - } - - AngularJSBridge.$inject = ['$filter', 'sdcConfig'] -}
\ No newline at end of file diff --git a/catalog-ui/app/scripts/services/available-icons-service.ts b/catalog-ui/app/scripts/services/available-icons-service.ts deleted file mode 100644 index 5c20afe5f2..0000000000 --- a/catalog-ui/app/scripts/services/available-icons-service.ts +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/23/2016. - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - interface IAvailableIconsService { - getIcons(componentType: Utils.Constants.ComponentType):Array<string>; - } - - export class AvailableIconsService implements IAvailableIconsService { - constructor() {} - public getIcons = (componentType: string): Array<string> => { - let icons: string[]; - switch (componentType){ - case Utils.Constants.ComponentType.SERVICE: - icons = [ - 'call_controll', - 'mobility', - 'network_l_1-3', - 'network_l_4' - ]; - break; - - case Utils.Constants.ComponentType.RESOURCE: - icons= [ - 'router', - 'database', - 'network', - 'objectStorage', - 'connector', - 'brocade', - 'cisco', - 'ericsson', - 'tropo', - 'fortinet', - 'att', - 'broadsoft', - 'alcatelLucent', - 'metaswitch', - 'aricent', - 'mySql', - 'oracle', - 'nokia_siemens', - 'juniper', - 'call_controll', - 'borderElement', - 'applicationServer', - 'server', - 'port', - 'loadBalancer', - 'compute', - 'gateway', - 'cp', - 'vl', - 'vfw', - 'firewall' - ]; - break; - - case Utils.Constants.ComponentType.PRODUCT: - icons = [ - 'vfw', - 'network', - 'security', - 'cloud', - 'setting', - 'orphan', - 'wanx', - 'vrouter', - 'ucpe', - 'mobility' - - ]; - break; - - } - return icons; - } - - } -} - - - diff --git a/catalog-ui/app/scripts/services/cache-service.ts b/catalog-ui/app/scripts/services/cache-service.ts deleted file mode 100644 index 3e5e5495c7..0000000000 --- a/catalog-ui/app/scripts/services/cache-service.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface ICacheService { - get(key:string):any; - set(key:string, value:any):void; - } - - export class CacheService implements ICacheService { - - static '$inject' = ['sdcConfig', '$document']; - private storage:Utils.Dictionary<string, any>; - - constructor() { - this.storage = new Utils.Dictionary<string, any>(); - }; - - public get = (key:string):any => { - return this.storage.getValue(key); - }; - - public set = (key:string, value:any):void => { - this.storage.setValue(key, value); - }; - - public remove = (key:string):void => { - if (this.storage.containsKey(key)){ - this.storage.remove(key); - } - }; - - public contains = (key:string):boolean => { - return this.storage.containsKey(key); - }; - - } -} diff --git a/catalog-ui/app/scripts/services/category-resource-service.ts b/catalog-ui/app/scripts/services/category-resource-service.ts deleted file mode 100644 index eef1b445e6..0000000000 --- a/catalog-ui/app/scripts/services/category-resource-service.ts +++ /dev/null @@ -1,83 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - import IMainCategory = Sdc.Models.IMainCategory; - 'use strict'; - - // Define an interface of the object you want to use, providing it's properties - export interface ICategoryResource extends Models.IUserProperties,ng.resource.IResource<ICategoryResource>{ - name:string; - uniqueId:string; - subcategories:Array<ICategoryResource>; - - getAllCategories(params?: Object, success?: Function, error?: Function): Array<IMainCategory>; - $saveSubCategory(params?: Object, success?: Function, error?: Function): any; - $deleteSubCategory(params?: Object, success?: Function, error?: Function): any; - } - - // Define your resource, adding the signature of the custom actions - export interface ICategoryResourceClass extends ng.resource.IResourceClass<ICategoryResource>{ - getAllCategories(params?: Object, success?: Function, error?: Function): Array<IMainCategory>; - saveSubCategory(params?: Object, success?: Function, error?: Function): any; - deleteSubCategory(params?: Object, success?: Function, error?: Function): any; - } - - export class CategoryResourceService{ - - public static getResource = ( - $resource: ng.resource.IResourceService, - sdcConfig: Models.IAppConfigurtaion - ): ICategoryResourceClass => { - - // Define your custom actions here as IActionDescriptor - let getAllCategoriesAction : ng.resource.IActionDescriptor = { - method: 'GET', - isArray: true, - url: sdcConfig.api.root + sdcConfig.api.GET_categories - }; - let saveSubCategory : ng.resource.IActionDescriptor = { - method: 'POST', - isArray: false, - url: sdcConfig.api.root + sdcConfig.api.POST_subcategory - }; - let deleteSubCategory: ng.resource.IActionDescriptor = { - method: 'DELETE', - isArray: false, - url: sdcConfig.api.root + sdcConfig.api.POST_subcategory - }; - - - let url: string = sdcConfig.api.root + sdcConfig.api.POST_category; - let categoryResource: ICategoryResourceClass = <ICategoryResourceClass>$resource( - url, - { types: '@types', categoryId: '@categoryId' }, - { - getAllCategories: getAllCategoriesAction, - saveSubCategory: saveSubCategory, - deleteSubCategory: deleteSubCategory - } - ); - - return categoryResource; - } - } - CategoryResourceService.getResource.$inject = ['$resource', 'sdcConfig']; -} diff --git a/catalog-ui/app/scripts/services/components/component-service.ts b/catalog-ui/app/scripts/services/components/component-service.ts deleted file mode 100644 index 393ea71c03..0000000000 --- a/catalog-ui/app/scripts/services/components/component-service.ts +++ /dev/null @@ -1,698 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.Services.Components { - - 'use strict'; - - declare let CryptoJS:any; - - export interface IComponentService { - - getComponent(id:string); - updateComponent(component:Models.Components.Component):ng.IPromise<Models.Components.Component>; - changeLifecycleState(component:Models.Components.Component, state:string, userRemarks:any):ng.IPromise<Models.Components.Component> ; - validateName(newName:string, subtype?:string):ng.IPromise<Models.IValidate>; - createComponent(component:Models.Components.Component):ng.IPromise<Models.Components.Component>; - addOrUpdateArtifact(componentId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel>; - deleteArtifact(componentId:string, artifact:string, artifactLabel):ng.IPromise<Models.ArtifactModel>; - addProperty(componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel>; - updateProperty(componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel>; - addAttribute(componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel>; - updateAttribute(componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel>; - deleteProperty(componentId:string, propertyId:string):ng.IPromise<Models.PropertyModel>; - deleteAttribute(componentId:string, attributeId:string):ng.IPromise<Models.AttributeModel>; - changeResourceInstanceVersion(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - updateInstanceArtifact(componentId:string, instanceId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel>; - addInstanceArtifact(componentId: string, instanceId: string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel>; - deleteInstanceArtifact(componentId: string, instanceId: string, artifact:string, artifactLabel):ng.IPromise<Models.ArtifactModel>; - createComponentInstance(componentId:string, componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - updateComponentInstance(componentId:string, componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - updateMultipleComponentInstances(componentId:string, instances:Array<Models.ComponentsInstances.ComponentInstance>):ng.IPromise< Array<Models.ComponentsInstances.ComponentInstance>>; - downloadArtifact(componentId:string, artifactId:string):ng.IPromise<Models.IFileDownload>; - uploadInstanceEnvFile(componentId:string, instanceId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel>; - downloadInstanceArtifact(componentId:string, instanceId:string, artifactId:string):ng.IPromise<Models.IFileDownload>; - deleteComponentInstance(componentId:string, componentInstanceId:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance>; - createRelation(componentId:string, link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel>; - deleteRelation(componentId:string, link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel>; - getRequirementsCapabilities(componentId:string):ng.IPromise<any>; - updateInstanceProperty(componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel>; - updateInstanceAttribute(componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel>; - getComponentInstancesFilteredByInputsAndProperties(componentId:string, searchText:string):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>> - getComponentInstanceInputs(componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<Models.InputModel>>; - getComponentInputs(componentId:string):ng.IPromise<Array<Models.InputModel>>; - getComponentInstanceInputProperties(componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<Models.PropertyModel>>; - getModuleForDisplay(componentId:string, moduleId:string):ng.IPromise<Models.DisplayModule>; - updateGroupMetadata(componentId:string, group:Models.Module):ng.IPromise<Models.Module>; - getComponentInputInputs(serviceId:string, input:string): ng.IPromise<Array<Models.InputModel>>; - createInputsFromInstancesInputs(serviceId:string, instancesInputsMap:Models.InstancesInputsMap): ng.IPromise<Array<Models.InputModel>>; - createInputsFromInstancesInputsProperties(resourceId:string, instanceInputsPropertiesMap:Models.InstanceInputsPropertiesMap): ng.IPromise<Array<Models.PropertyModel>>; - deleteComponentInput(serviceId:string, inputId:string):ng.IPromise<Models.InputModel>; - } - - export class ComponentService implements IComponentService { - - static '$inject' = [ - '$log', - 'Restangular', - 'sdcConfig', - 'Sdc.Services.SharingService', - '$q', - '$interval', - '$base64', - 'ComponentInstanceFactory' - ]; - - constructor(protected $log: ng.ILogService, - protected restangular:restangular.IElement, - protected sdcConfig:Models.IAppConfigurtaion, - protected sharingService:Sdc.Services.SharingService, - protected $q:ng.IQService, - protected $interval:any, - protected $base64:any, - protected ComponentInstanceFactory:Utils.ComponentInstanceFactory) { - - this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root); - this.restangular.setRequestInterceptor(function (elem, operation) { - if (operation === "remove") { - return null; - } - return elem; - }); - // this.restangular.setDefaultHeaders({'Content-Type': 'application/json; charset=UTF-8'}); - } - - //this function is override by each service, we need to change this method to abstract when updtaing typescript version - protected createComponentObject = (component:Models.Components.Component):Models.Components.Component => { - return component; - }; - - public getComponent = (id:string):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - this.restangular.one(id).get().then((response:Models.Components.Component) => { - let component:Models.Components.Component = this.createComponentObject(response); - //this.$log.debug("Component Loaded successfully : ", component); - deferred.resolve(component); - }, (err)=> { - this.$log.debug("Failed to load component with ID: " + id); - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateComponent = (component:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - // If this is resource - if (component instanceof Sdc.Models.Components.Resource) { - let resource:Sdc.Models.Components.Resource = <Sdc.Models.Components.Resource>component; - if (resource.importedFile) { - // Update resource with payload data. - return this.updateResourceWithPayload(resource); - } else { - if (component.csarUUID) { - // Update resource without payload data. - return this.updateResource(component); - } else { - // Update resource without payload data (metadata). - return this.updateResourceMetadata(component); - } - } - } else { - return this.updateService(component); - } - }; - - private updateService = (component:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - this.restangular.one(component.uniqueId).one("metadata").customPUT(JSON.stringify(component)).then((response:Models.Components.Component) => { - let component:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - private updateResource = (component:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - this.restangular.one(component.uniqueId).customPUT(JSON.stringify(component)).then((response:Models.Components.Component) => { - let component:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - private updateResourceMetadata = (component:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - this.restangular.one(component.uniqueId).one('metadata').customPUT(JSON.stringify(component)).then((response:Models.Components.Component) => { - let component:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - /** - * Only resource can be updated with payload data - * @param component - * @returns {IPromise<T>} - */ - private updateResourceWithPayload = (resource:Sdc.Models.Components.Resource):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - - resource.payloadData = resource.importedFile.base64; - resource.payloadName = resource.importedFile.filename; - let headerObj = this.getHeaderMd5(resource); - - this.restangular.one(resource.uniqueId).customPUT(JSON.stringify(resource), '', {}, headerObj).then((response:Models.Components.Component) => { - let componentResult:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(componentResult); - }, (err)=> { - deferred.reject(err); - }); - - return deferred.promise; - }; - - public createComponent = (component:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - let headerObj = this.getHeaderMd5(component); - this.restangular.customPOST(JSON.stringify(component), '', {}, headerObj).then((response:Models.Components.Component) => { - let component:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public validateName = (newName:string, subtype?:string):ng.IPromise<Models.IValidate> => { - let deferred = this.$q.defer(); - this.restangular.one("validate-name").one(newName).get({'subtype': subtype}).then((response:any) => { - deferred.resolve(response.plain()); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public changeLifecycleState = (component:Models.Components.Component, state:string, userRemarks:any):ng.IPromise<Models.Components.Component> => { - let deferred = this.$q.defer(); - this.restangular.one(component.uniqueId).one(state).customPOST(userRemarks).then((response:Models.Components.Component) => { - this.sharingService.addUuidValue(response.uniqueId, response.uuid); - let component:Models.Components.Component = this.createComponentObject(response); - deferred.resolve(component); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - // ------------------------------------------------ Artifacts API --------------------------------------------------// - public addOrUpdateArtifact = (componentId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let headerObj = {}; - if (artifact.payloadData) { - headerObj = this.getHeaderMd5(artifact); - } - this.restangular.one(componentId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { - deferred.resolve(response.plain()); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public downloadArtifact = (componentId:string, artifactId:string):ng.IPromise<Models.IFileDownload> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("artifacts").one(artifactId).get().then((response:any) => { - deferred.resolve(response.plain()); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteArtifact = (componentId:string, artifactId:string, artifactLabel:string):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response:Models.ArtifactModel) => { - deferred.resolve(response); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - - // ------------------------------------------------ Properties API --------------------------------------------------// - public addProperty = (componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("properties").customPOST(property.convertToServerObject()).then((response:any) => { - let property:Models.PropertyModel = new Models.PropertyModel(response[Object.keys(response)[0]]); - deferred.resolve(property); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateProperty = (componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("properties").one(property.uniqueId).customPUT(property.convertToServerObject()).then((response:any) => { - let property:Models.PropertyModel = new Models.PropertyModel(response[Object.keys(response)[0]]); - deferred.resolve(property); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteProperty = (componentId:string, propertyId:string):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("properties").one(propertyId).remove().then((response:any) => { - deferred.resolve(response); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - // ------------------------------------------------ Attributes API --------------------------------------------------// - public addAttribute = (componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("attributes").customPOST(attribute.convertToServerObject()).then((response:any) => { - let attribute:Models.AttributeModel = new Models.AttributeModel(response); - deferred.resolve(attribute); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateAttribute = (componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("attributes").one(attribute.uniqueId).customPUT(attribute.convertToServerObject()).then((response:any) => { - let attribute:Models.AttributeModel = new Models.AttributeModel(response); - deferred.resolve(attribute); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteAttribute = (componentId:string, attributeId:string):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("attributes").one(attributeId).remove().then((response:any) => { - deferred.resolve(response); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - // ------------------------------------------------ Component Instances API --------------------------------------------------// - - public createComponentInstance = (componentId:string, componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").customPOST(JSON.stringify(componentInstance)).then((response:any) => { - let componentInstance:Models.ComponentsInstances.ComponentInstance = Utils.ComponentInstanceFactory.createComponentInstance(response); - this.$log.debug("Component Instance created", componentInstance); - deferred.resolve(componentInstance); - }, (err)=> { - this.$log.debug("Failed to create componentInstance. With Name: " + componentInstance.name); - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateComponentInstance = (componentId:string, componentInstance:Models.ComponentsInstances.ComponentInstance):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one(componentInstance.uniqueId).customPOST(JSON.stringify(componentInstance)).then((response:any) => { - let componentInstance:Models.ComponentsInstances.ComponentInstance = Utils.ComponentInstanceFactory.createComponentInstance(response); - this.$log.debug("Component Instance was updated", componentInstance); - deferred.resolve(componentInstance); - }, (err)=> { - this.$log.debug("Failed to update componentInstance. With ID: " + componentInstance.uniqueId + "Name: " + componentInstance.name); - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateMultipleComponentInstances = (componentId:string, instances:Array<Models.ComponentsInstances.ComponentInstance>):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance/multipleComponentInstance").customPOST(JSON.stringify(instances)).then((response:any) => { - this.$log.debug("Multiple Component Instances was updated", response); - let updateInstances:Array<Models.ComponentsInstances.ComponentInstance> = new Array<Models.ComponentsInstances.ComponentInstance>(); - _.forEach(response, (componentInstance:Models.ComponentsInstances.ComponentInstance) => { - let updatedComponentInstance:Models.ComponentsInstances.ComponentInstance = Utils.ComponentInstanceFactory.createComponentInstance(componentInstance); - updateInstances.push(updatedComponentInstance); - }); - deferred.resolve(updateInstances); - }, (err)=> { - this.$log.debug("Failed to update Multiple componentInstance."); - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteComponentInstance = (componentId:string, componentInstanceId:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).remove().then(() => { - this.$log.debug("Component Instance was deleted"); - deferred.resolve(); - }, (err)=> { - this.$log.debug("Failed to delete componentInstance. With ID: " + componentInstanceId); - deferred.reject(err); - }); - return deferred.promise; - }; - - public changeResourceInstanceVersion = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<Models.ComponentsInstances.ComponentInstance> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("changeVersion").customPOST({'componentUid': componentUid}).then((response:any) => { - let componentInstance:Models.ComponentsInstances.ComponentInstance = Utils.ComponentInstanceFactory.createComponentInstance(response); - deferred.resolve(componentInstance); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public downloadInstanceArtifact = (componentId:string, instanceId:string, artifactId:string):ng.IPromise<Models.IFileDownload> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstances").one(instanceId).one("artifacts").one(artifactId).get().then((response:any) => { - deferred.resolve(response.plain()); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateInstanceArtifact = (componentId:string, instanceId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let headerObj = {}; - if(artifact.payloadData){ - headerObj = this.getHeaderMd5(artifact); - } - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId , {}, headerObj).then((response: any) => { - let newArtifact = new Models.ArtifactModel(response); - deferred.resolve(newArtifact); - }, (err)=>{ - deferred.reject(err); - }); - return deferred.promise; - }; - - public addInstanceArtifact = (componentId: string, instanceId: string, artifact:Models.ArtifactModel): ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let headerObj = {}; - if(artifact.payloadData){ - headerObj = this.getHeaderMd5(artifact); - } - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId , {}, headerObj).then((response: any) => { - let artifact:Models.ArtifactModel = new Models.ArtifactModel(response.plain()); - deferred.resolve(artifact); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteInstanceArtifact = (componentId: string , instanceId: string, artifactId:string, artifactLabel: string): ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response: Models.ArtifactModel) => { - deferred.resolve(response); - }, (err)=>{ - deferred.reject(err); - }); - return deferred.promise; - }; - - public uploadInstanceEnvFile = (componentId:string, instanceId:string, artifact:Models.ArtifactModel):ng.IPromise<Models.ArtifactModel> => { - let deferred = this.$q.defer(); - let headerObj = {}; - if (artifact.payloadData) { - headerObj = this.getHeaderMd5(artifact); - } - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { - let newArtifact = new Models.ArtifactModel(response); - deferred.resolve(newArtifact); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateInstanceProperty = (componentId:string, property:Models.PropertyModel):ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - let instanceId = property.resourceInstanceUniqueId; - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("property").customPOST(JSON.stringify(property)).then((response:any) => { - let newProperty = new Models.PropertyModel(response); - newProperty.readonly = true; - newProperty.resourceInstanceUniqueId = instanceId; - deferred.resolve(newProperty); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public updateInstanceAttribute = (componentId:string, attribute:Models.AttributeModel):ng.IPromise<Models.AttributeModel> => { - let deferred = this.$q.defer(); - let instanceId = attribute.resourceInstanceUniqueId; - this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("attribute").customPOST(JSON.stringify(attribute)).then((response:any) => { - let newAttribute = new Models.AttributeModel(response); - newAttribute.readonly = true; - newAttribute.resourceInstanceUniqueId = instanceId; - deferred.resolve(newAttribute); - }, (err)=> { - deferred.reject(err); - }); - return deferred.promise; - }; - - public createRelation = (componentId:string, link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(link)).then((response:any) => { - let relation:Models.RelationshipModel = new Models.RelationshipModel(response.plain()); - this.$log.debug("Link created successfully ", relation); - deferred.resolve(relation); - }, (err)=> { - this.$log.debug("Failed to create Link From: " + link.fromNode + "To: " + link.toNode); - deferred.reject(err); - }); - return deferred.promise; - }; - - public deleteRelation = (componentId:string, link:Models.RelationshipModel):ng.IPromise<Models.RelationshipModel> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(link)).then((response:any) => { - let relation:Models.RelationshipModel = new Models.RelationshipModel(response); - this.$log.debug("Link deleted successfully ", relation); - deferred.resolve(relation); - }, (err)=> { - this.$log.debug("Failed to delete Link From: " + link.fromNode + "To: " + link.toNode); - deferred.reject(err); - }); - return deferred.promise; - }; - - public getRequirementsCapabilities = (componentId:string):ng.IPromise<any> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response:any) => { - this.$log.debug("Component requirement capabilities recived: ", response); - deferred.resolve(response); - }, (err)=> { - this.$log.debug("Failed to get requirements & capabilities"); - deferred.reject(err); - }); - return deferred.promise; - }; - - public getModuleForDisplay = (componentId:string, moduleId:string):ng.IPromise<Models.DisplayModule> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("groups").one(moduleId).get().then((response:any) => { - this.$log.debug("module loaded successfully: ", response); - let module:Models.DisplayModule = new Models.DisplayModule(response); - deferred.resolve(module); - }, (err)=> { - this.$log.debug("Failed to get module with id: ", moduleId); - deferred.reject(err); - }); - return deferred.promise; - }; - - public getComponentInstancesFilteredByInputsAndProperties = (componentId:string, searchText?:string):ng.IPromise<Array<Models.ComponentsInstances.ComponentInstance>> => { - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("componentInstances").get({'searchText': searchText}).then((response:any) => { - this.$log.debug("component instances return successfully: ", response); - let componentInstances:Array<Models.ComponentsInstances.ComponentInstance> = Utils.CommonUtils.initComponentInstances(response); - deferred.resolve(componentInstances); - }, (err) => { - this.$log.debug("Failed to get component instances of component with id: " + componentId); - deferred.reject(err); - }); - - return deferred.promise; - }; - - public getComponentInstanceInputs = (componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<Models.InputModel>> => { - - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("componentInstances").one(instanceId).one(originComponentUid).one("inputs").get().then((response:any) => { - this.$log.debug("component instance input return successfully: ", response); - let inputsArray:Array<Models.InputModel> = new Array<Models.InputModel>(); - _.forEach(response, (inputObj:Models.InputModel) => { - inputsArray.push(new Models.InputModel(inputObj)); - }); - deferred.resolve(inputsArray); - }, (err) => { - this.$log.debug("Failed to get component instance input with id: " + instanceId); - deferred.reject(err); - }); - - return deferred.promise; - }; - - public getComponentInputs = (componentId:string):ng.IPromise<Array<Models.InputModel>> => { - - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("inputs").get().then((response:any) => { - this.$log.debug("component inputs return successfully: ", response); - let inputsArray:Array<Models.InputModel> = new Array<Models.InputModel>(); - _.forEach(response, (inputObj:Models.InputModel) => { - inputsArray.push(new Models.InputModel(inputObj)); - }); - deferred.resolve(inputsArray); - }, (err) => { - this.$log.debug("Failed to get component inputs for component with id: " + componentId); - deferred.reject(err); - }); - - return deferred.promise; - }; - - public getComponentInstanceInputProperties = (componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<Models.PropertyModel>> => { - - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("componentInstances").one(instanceId).one(inputId).one("properties").get().then((response:any) => { - this.$log.debug("component instance input properties return successfully: ", response); - let propertiesArray:Array<Models.PropertyModel> = new Array<Models.PropertyModel>(); - _.forEach(response, (propertyObj:Models.PropertyModel) => { - propertiesArray.push(new Models.PropertyModel(propertyObj)); - }); - deferred.resolve(propertiesArray); - }, (err) => { - this.$log.debug("Failed to get component instance input properties with instanceId: " + instanceId + "and input id: " + inputId); - deferred.reject(err); - }); - - return deferred.promise; - }; - - public updateGroupMetadata = (componentId:string, group:Models.Module):ng.IPromise<Models.Module> => { - - let deferred = this.$q.defer(); - this.restangular.one(componentId).one("groups").one(group.uniqueId).one("metadata").customPUT(JSON.stringify(group)).then((response:Models.Module) => { - this.$log.debug("group metadata updated successfully: ", response); - let updatedGroup:Models.Module = new Models.Module(response); - - deferred.resolve(updatedGroup); - }, (err) => { - this.$log.debug("Failed to update group metadata for component: " + componentId + " for group with id: " + group.uniqueId); - deferred.reject(err); - }); - - return deferred.promise; - }; - - public getComponentInputInputs = (serviceId:string, inputId:string): ng.IPromise<Array<Models.InputModel>> => { - let defer = this.$q.defer<any>(); - this.restangular.one(serviceId).one("inputs").one(inputId).one("inputs").get().then((response: any) => { - let inputsArray:Array<Models.InputModel> = new Array<Models.InputModel>(); - _.forEach(response, (inputObj:Models.InputModel) => { - inputsArray.push(new Models.InputModel(inputObj)); - }); - defer.resolve(inputsArray); - }, (err)=>{ - this.$log.debug("failed to get inputs of input : ", err); - defer.reject(err); - }); - return defer.promise; - }; - - createInputsFromInstancesInputsProperties = (resourceId:string, instancePropertyMap:Models.InstanceInputsPropertiesMap): ng.IPromise<Array<Models.PropertyModel>> => { - let defer = this.$q.defer<any>(); - this.restangular.one(resourceId).one("create/properties").customPOST(instancePropertyMap).then((response: any) => { - let inputsArray:Array<Models.PropertyModel> = new Array<Models.PropertyModel>(); - _.forEach(response, (inputObj:Models.PropertyModel) => { - inputsArray.push(new Models.PropertyModel(inputObj)); - }); - defer.resolve(inputsArray); - }, (err)=>{ - this.$log.debug("failed to create service inputs from VF instances inputs : ", err); - defer.reject(err); - }); - return defer.promise; - }; - - createInputsFromInstancesInputs = (serviceId:string, instancesMap:Models.InstancesInputsMap): ng.IPromise<Array<Models.InputModel>> => { - let defer = this.$q.defer<any>(); - this.restangular.one(serviceId).one("create/inputs").customPOST(instancesMap).then((response: any) => { - let inputsArray:Array<Models.InputModel> = new Array<Models.InputModel>(); - _.forEach(response, (inputObj:Models.InputModel) => { - inputsArray.push(new Models.InputModel(inputObj)); - }); - defer.resolve(inputsArray); - }, (err)=>{ - this.$log.debug("failed to create service inputs from VF instances inputs : ", err); - defer.reject(err); - }); - return defer.promise; - }; - - deleteComponentInput = (serviceId:string, inputId:string) : ng.IPromise<Models.InputModel> => { - var defer = this.$q.defer(); - this.restangular.one(serviceId).one("delete").one(inputId).one("input").remove().then((response: any) => { - var inputToDelete = new Models.InputModel(response); - - defer.resolve(inputToDelete); - }, (err)=> { - console.log("failed to delete input from service: ", err); - defer.reject(err); - }); - return defer.promise; - }; - - private getHeaderMd5 = (object:any):any => { - let headerObj={}; - // This is ugly workaround!!! - // The md5 result is not correct if we do not add the line JSON.stringify(resource); twice. - JSON.stringify(object); - let componentString:string = JSON.stringify(object); - let md5Result = md5(componentString).toLowerCase(); - headerObj = {'Content-MD5': this.$base64.encode(md5Result)}; - return headerObj; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/components/product-service.ts b/catalog-ui/app/scripts/services/components/product-service.ts deleted file mode 100644 index 69171fbbfa..0000000000 --- a/catalog-ui/app/scripts/services/components/product-service.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/8/2016. - */ -/// <reference path="../../references"/> -module Sdc.Services.Components { - 'use strict'; - - export interface IProductService extends IComponentService { - - } - - export class ProductService extends ComponentService implements IProductService { - - static '$inject' = [ - '$log', - 'Restangular', - 'sdcConfig', - 'Sdc.Services.SharingService', - '$q', - '$interval', - '$base64', - 'ComponentInstanceFactory' - ]; - - constructor(protected $log: ng.ILogService, - protected restangular: restangular.IElement, - protected sdcConfig: Models.IAppConfigurtaion, - protected sharingService: Sdc.Services.SharingService, - protected $q: ng.IQService, - protected $interval: any, - protected $base64: any, - protected ComponentInstanceFactory: Utils.ComponentInstanceFactory) { - super($log, restangular, sdcConfig, sharingService, $q, $interval, $base64, ComponentInstanceFactory); - - this.restangular = restangular.one("products"); - } - - createComponentObject = (component: Models.Components.Component): Models.Components.Component => { - return new Models.Components.Product(this, this.$q, <Models.Components.Product>component); - }; - } -} diff --git a/catalog-ui/app/scripts/services/components/resource-service.ts b/catalog-ui/app/scripts/services/components/resource-service.ts deleted file mode 100644 index 48781da48e..0000000000 --- a/catalog-ui/app/scripts/services/components/resource-service.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Services.Components { - 'use strict'; - - export interface IResourceService extends IComponentService { - - } - - export class ResourceService extends ComponentService implements IResourceService { - - static '$inject' = [ - '$log', - 'Restangular', - 'sdcConfig', - 'Sdc.Services.SharingService', - '$q', - '$interval', - '$base64', - 'ComponentInstanceFactory' - ]; - - constructor(protected $log: ng.ILogService, - protected restangular: restangular.IElement, - protected sdcConfig: Models.IAppConfigurtaion, - protected sharingService: Sdc.Services.SharingService, - protected $q: ng.IQService, - protected $interval: any, - protected $base64: any, - protected ComponentInstanceFactory: Utils.ComponentInstanceFactory) { - super($log, restangular, sdcConfig, sharingService, $q, $interval, $base64, ComponentInstanceFactory); - - this.restangular = restangular.one("resources"); - } - - createComponentObject = (component: Models.Components.Component): Models.Components.Component => { - return new Models.Components.Resource(this, this.$q, <Models.Components.Resource>component); - }; - } -} diff --git a/catalog-ui/app/scripts/services/components/service-service.ts b/catalog-ui/app/scripts/services/components/service-service.ts deleted file mode 100644 index fef0b47512..0000000000 --- a/catalog-ui/app/scripts/services/components/service-service.ts +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/4/2016. - */ -/// <reference path="../../references"/> -module Sdc.Services.Components { - 'use strict'; - - - export interface IServiceService extends IComponentService { - getDistributionsList(uuid: string): ng.IPromise<Array<Models.Distribution>>; - getDistributionComponents(distributionId: string): ng.IPromise<Array<Models.DistributionComponent>>; - markAsDeployed(serviceId: string, distributionId: string): ng.IPromise<any>; - } - - export class ServiceService extends ComponentService implements IServiceService { - - static '$inject' = [ - '$log', - 'Restangular', - 'sdcConfig', - 'Sdc.Services.SharingService', - '$q', - '$interval', - '$base64', - 'ComponentInstanceFactory' - ]; - - public distribution: string = "distribution"; - - constructor(protected $log: ng.ILogService, - protected restangular: restangular.IElement, - protected sdcConfig: Models.IAppConfigurtaion, - protected sharingService: Sdc.Services.SharingService, - protected $q: ng.IQService, - protected $interval: any, - protected $base64: any, - protected ComponentInstanceFactory: Utils.ComponentInstanceFactory) { - super($log, restangular, sdcConfig, sharingService, $q, $interval, $base64, ComponentInstanceFactory); - - this.restangular = restangular.one("services"); - } - - getDistributionsList = (uuid: string): ng.IPromise<Array<Models.Distribution>> => { - let defer = this.$q.defer<Array<Models.Distribution>>(); - this.restangular.one(uuid).one("distribution").get().then((distributions: any) => { - defer.resolve(<Array<Models.Distribution>> distributions.distributionStatusOfServiceList); - }, (err)=> { - defer.reject(err); - }); - return defer.promise; - }; - - getDistributionComponents = (distributionId: string): ng.IPromise<Array<Models.DistributionComponent>> => { - let defer = this.$q.defer<Array<Models.DistributionComponent>>(); - this.restangular.one("distribution").one(distributionId).get().then((distributions: any) => { - defer.resolve(<Array<Models.DistributionComponent>> distributions.distributionStatusList); - }, (err)=> { - defer.reject(err); - }); - return defer.promise; - }; - - markAsDeployed = (serviceId: string, distributionId: string): ng.IPromise<any> => { - let defer = this.$q.defer<any>(); - this.restangular.one(serviceId).one("distribution").one(distributionId).one("markDeployed").customPOST().then((result: any) => { - defer.resolve(result); - }, (err)=> { - - defer.reject(err); - }); - return defer.promise; - }; - - createComponentObject = (component: Models.Components.Component): Models.Components.Component => { - return new Models.Components.Service(this, this.$q, <Models.Components.Service>component); - }; - } -} diff --git a/catalog-ui/app/scripts/services/components/utils/composition-left-palette-service.ts b/catalog-ui/app/scripts/services/components/utils/composition-left-palette-service.ts deleted file mode 100644 index 25ac1cdf17..0000000000 --- a/catalog-ui/app/scripts/services/components/utils/composition-left-palette-service.ts +++ /dev/null @@ -1,248 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 3/13/2016. - */ -/// <reference path="../../../references"/> -module Sdc.Services.Components { - - 'use strict'; - - export class LeftPanelLatestVersion { - uid: string; - version: string; - } - - export class LeftPaletteDataObject { - currentUpdatingIdsList: Array<string>; - latestVersionAndIdsList: Array<LeftPanelLatestVersion>; - fullDataLeftPaletteComponents: Array<Models.Components.Component>; - displayLeftPanelComponents: Array<Models.DisplayComponent>; - onFinishLoadingEvent: string; - - constructor(onFinishEventListener: string) { - - this.fullDataLeftPaletteComponents = new Array<Models.Components.Component>(); - this.displayLeftPanelComponents = new Array<Models.DisplayComponent>(); - this.currentUpdatingIdsList = new Array<string>(); - this.latestVersionAndIdsList = new Array<LeftPanelLatestVersion>(); - this.onFinishLoadingEvent = onFinishEventListener; - } - } - - export class LeftPaletteLoaderService { - - static '$inject' = [ - 'Restangular', - 'sdcConfig', - '$q', - '$base64', - 'ComponentFactory', - 'EventListenerService' - - ]; - - constructor(protected restangular: restangular.IElement, - protected sdcConfig: Models.IAppConfigurtaion, - protected $q: ng.IQService, - protected $base64: any, - protected ComponentFactory: Utils.ComponentFactory, - protected EventListenerService: Services.EventListenerService) { - - this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root); - } - - private serviceLeftPaletteData: LeftPaletteDataObject; - private resourceLeftPaletteData: LeftPaletteDataObject; - private productLeftPaletteData: LeftPaletteDataObject; - private vlData: LeftPaletteDataObject; - - public loadLeftPanel = (): void => { - - this.serviceLeftPaletteData = new LeftPaletteDataObject(Utils.Constants.EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT); - this.resourceLeftPaletteData = new LeftPaletteDataObject(Utils.Constants.EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT); - this.productLeftPaletteData = new LeftPaletteDataObject(Utils.Constants.EVENTS.PRODUCT_LEFT_PALETTE_UPDATE_EVENT); - this.vlData = new LeftPaletteDataObject(Utils.Constants.EVENTS.VL_LEFT_PALETTE_UPDATE_EVENT); - - //initiating service palette - this.updateComponentLeftPalette(Utils.Constants.ComponentType.SERVICE); - - //initiating resource palette - this.updateComponentLeftPalette(Utils.Constants.ComponentType.RESOURCE); - - //initiating product palette - this.updateComponentLeftPalette(Utils.Constants.ComponentType.PRODUCT); - - //initiating vl - this.updateComponentLeftPalette(Utils.Constants.ResourceType.VL); - }; - - private updateData = (latestVersionComponents: Array<Models.Components.Component>, leftPaletteDataObj: LeftPaletteDataObject) => { - - let fullDataComponentsArray: Array<Models.Components.Component> = new Array<Models.Components.Component>(); - let displayComponentsArray: Array<Models.DisplayComponent> = new Array<Models.DisplayComponent>(); - - _.forEach(latestVersionComponents, (componentObj: any) => { - let component: Models.Components.Component = this.ComponentFactory.createComponent(componentObj); - fullDataComponentsArray.push(component); - displayComponentsArray.push(new Models.DisplayComponent(component)); - }); - - leftPaletteDataObj.fullDataLeftPaletteComponents = leftPaletteDataObj.fullDataLeftPaletteComponents.concat(fullDataComponentsArray); - leftPaletteDataObj.displayLeftPanelComponents = leftPaletteDataObj.displayLeftPanelComponents.concat(displayComponentsArray); - }; - - private getTypeUrl = (componentType: string): string => { - return Utils.Constants.ComponentType.PRODUCT === componentType ? "services" : "resources"; - }; - - private onFinishLoading = (componentType: string, leftPaletteData: LeftPaletteDataObject): void => { - leftPaletteData.currentUpdatingIdsList = []; - this.EventListenerService.notifyObservers(leftPaletteData.onFinishLoadingEvent); - }; - - private getPartialLastVersionFullComponents = (componentType: string, componentInternalType: string, leftPaletteData: LeftPaletteDataObject): void => { - this.restangular.one(this.getTypeUrl(componentType)).one('/latestversion/notabstract').customPOST(leftPaletteData.currentUpdatingIdsList, '', {'internalComponentType': componentInternalType}).then((componentsArray: any) => { - this.updateData(componentsArray, leftPaletteData); - this.onFinishLoading(componentType, leftPaletteData); //when finish loading update view - }); - }; - - private removeNotUpdatedComponents = (leftPaletteObject: LeftPaletteDataObject) => { - - leftPaletteObject.fullDataLeftPaletteComponents = _.filter(leftPaletteObject.fullDataLeftPaletteComponents, (component)=> { - return leftPaletteObject.currentUpdatingIdsList.indexOf(component.uniqueId) != -1; - }); - leftPaletteObject.displayLeftPanelComponents = _.filter(leftPaletteObject.displayLeftPanelComponents, (component)=> { - return leftPaletteObject.currentUpdatingIdsList.indexOf(component.uniqueId) != -1; - }); - }; - - private findIdsToUpdate = (leftPaletteObj: LeftPaletteDataObject): Array<string> => { - let idsToUpdate = <string[]>_.difference(leftPaletteObj.currentUpdatingIdsList, _.map(leftPaletteObj.fullDataLeftPaletteComponents, 'uniqueId')); - let neededUpdate = _.filter(leftPaletteObj.fullDataLeftPaletteComponents, (component) => { - let updated = _.find(leftPaletteObj.latestVersionAndIdsList, (versionAndId: LeftPanelLatestVersion) => { - return versionAndId.uid === component.uniqueId && versionAndId.version != component.version - }); - return updated != undefined; - }); - if (neededUpdate && neededUpdate.length > 0) { - let neededUpdateIds = <string[]>_.map(neededUpdate, 'uid'); - idsToUpdate.concat(neededUpdateIds); - } - return idsToUpdate; - }; - - private updateCurrentIdsList = (componentType: string, leftPaletteObj: LeftPaletteDataObject): void=> { - this.removeNotUpdatedComponents(leftPaletteObj); - leftPaletteObj.currentUpdatingIdsList = this.findIdsToUpdate(leftPaletteObj); - //remove all components that needed update from current lists - if (leftPaletteObj.currentUpdatingIdsList.length > 0) { - leftPaletteObj.displayLeftPanelComponents = _.filter(leftPaletteObj.displayLeftPanelComponents, (component)=> { - return leftPaletteObj.currentUpdatingIdsList.indexOf(component.uniqueId) === -1; - }); - leftPaletteObj.fullDataLeftPaletteComponents = _.filter(leftPaletteObj.fullDataLeftPaletteComponents, (component)=> { - return leftPaletteObj.currentUpdatingIdsList.indexOf(component.uniqueId) === -1; - }); - } - }; - - private updateLeftPalette = (componentType, componentInternalType: string, leftPaletteData: LeftPaletteDataObject): void => { - if (leftPaletteData.currentUpdatingIdsList.length > 0) return; //this means the service is still performing update - this.restangular.one(this.getTypeUrl(componentType)).one('/latestversion/notabstract/uidonly').get({'internalComponentType': componentInternalType}).then((latestVersionUniqueIds: Array<LeftPanelLatestVersion>) => { - leftPaletteData.latestVersionAndIdsList = latestVersionUniqueIds; - leftPaletteData.currentUpdatingIdsList = <string[]>_.map(latestVersionUniqueIds, 'uid') - - if (leftPaletteData.fullDataLeftPaletteComponents.length === 0) { //this is when first loading product or resource left palette - this.getPartialLastVersionFullComponents(componentType, componentInternalType, leftPaletteData); - } else { - this.updateCurrentIdsList(componentType, leftPaletteData); - if (leftPaletteData.currentUpdatingIdsList.length === 0) { - this.onFinishLoading(componentType, leftPaletteData); //when finish loading update view - return; - } - this.getPartialLastVersionFullComponents(componentType, componentInternalType, leftPaletteData); - } - }); - }; - - public getLeftPanelComponentsForDisplay = (componentType: string): Array<Models.DisplayComponent> => { - switch (componentType) { - case Utils.Constants.ComponentType.SERVICE: - return this.serviceLeftPaletteData.displayLeftPanelComponents; - case Utils.Constants.ComponentType.PRODUCT: - return this.productLeftPaletteData.displayLeftPanelComponents; - default: - return this.resourceLeftPaletteData.displayLeftPanelComponents; - } - }; - - public getFullDataComponentList = (componentType: string): Array<Models.Components.Component> => { - switch (componentType) { - case Utils.Constants.ResourceType.VL: - return this.vlData.fullDataLeftPaletteComponents; - case Utils.Constants.ComponentType.SERVICE: - return this.serviceLeftPaletteData.fullDataLeftPaletteComponents; - case Utils.Constants.ComponentType.PRODUCT: - return this.productLeftPaletteData.fullDataLeftPaletteComponents; - default : - return this.resourceLeftPaletteData.fullDataLeftPaletteComponents; - } - }; - - public getFullDataComponentListWithVls = (componentType: string): Array<Models.Components.Component> => { - let listPart1: Array<Models.Components.Component>; - let listPart2: Array<Models.Components.Component>; - if (componentType === Utils.Constants.ResourceType.VL) { - listPart1 = []; - listPart2 = this.getFullDataComponentList(Utils.Constants.ResourceType.VL); - } else { - listPart1 = this.getFullDataComponentList(componentType); - listPart2 = this.getFullDataComponentList(Utils.Constants.ResourceType.VL); - } - return listPart1.concat(listPart2); - }; - - public updateSpecificComponentLeftPalette = (component: Models.Components.Component, componentType: string): void => { - let listComponents: Array<Models.Components.Component> = this.getFullDataComponentList(componentType); - for (let i in listComponents) { - if (listComponents[i].uniqueId === component.uniqueId) { - listComponents[i] = component; - } - } - }; - - public updateComponentLeftPalette = (componentType): void => { - switch (componentType) { - case Utils.Constants.ResourceType.VL: - this.updateLeftPalette(Utils.Constants.ComponentType.RESOURCE, Utils.Constants.ResourceType.VL, this.vlData); - break; - case Utils.Constants.ComponentType.SERVICE: - this.updateLeftPalette(Utils.Constants.ComponentType.SERVICE, Utils.Constants.ComponentType.SERVICE, this.serviceLeftPaletteData); - break; - case Utils.Constants.ComponentType.PRODUCT: - this.updateLeftPalette(Utils.Constants.ComponentType.PRODUCT, Utils.Constants.ComponentType.SERVICE, this.productLeftPaletteData); - break; - default: - this.updateLeftPalette(Utils.Constants.ComponentType.RESOURCE, Utils.Constants.ResourceType.VF, this.resourceLeftPaletteData); - } - }; - } -} diff --git a/catalog-ui/app/scripts/services/cookie-service.ts b/catalog-ui/app/scripts/services/cookie-service.ts deleted file mode 100644 index b23a7dccde..0000000000 --- a/catalog-ui/app/scripts/services/cookie-service.ts +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface ICookieService { - getUserId(): string; - getFirstName(): string; - getLastName(): string; - getEmail(): string; - getUserIdSuffix(): string; - } - - export class CookieService implements ICookieService { - - static '$inject' = ['sdcConfig', '$document']; - private cookie: Sdc.Models.ICookie; - private cookiePrefix: string; - - - constructor(sdcConfig: Models.IAppConfigurtaion, private $document) { - this.cookie = sdcConfig.cookie; - - this.cookiePrefix = ''; - let junctionName: string = this.getCookieByName(this.cookie.junctionName); - if ((junctionName !== null) && (junctionName !== '')){ - this.cookiePrefix = this.cookie.prefix+junctionName+'!'; - } - } - - private getCookieByName = (cookieName: string): string => { - cookieName += '='; - let cookies: Array<string> = this.$document[0].cookie.split(';'); - let cookieVal: string = ''; - cookies.forEach((cookie: string) => { - while(cookie.charAt(0) === ' '){ - cookie = cookie.substring(1); - } - if(cookie.indexOf(cookieName) === 0){ - cookieVal = cookie.substring(cookieName.length, cookie.length); - return; - } - }); - return cookieVal; - }; - - public getUserIdSuffix = (): string => { - return this.cookie.userIdSuffix; - }; - - public getUserId = (): string => { - let userIdCookieName: string = this.cookiePrefix+this.cookie.userIdSuffix; - let userId: string = this.getCookieByName(userIdCookieName); - return userId; - }; - - public getFirstName = (): string => { - let firstNameCookieName: string = this.cookiePrefix+this.cookie.userFirstName; - let firstName: string = this.getCookieByName(firstNameCookieName); - return firstName; - }; - - public getLastName = (): string => { - let lastNameCookieName: string = this.cookiePrefix+this.cookie.userLastName; - let lastName: string = this.getCookieByName(lastNameCookieName); - return lastName; - }; - - public getEmail = (): string => { - let emailCookieName: string = this.cookiePrefix+this.cookie.userEmail; - let email: string = this.getCookieByName(emailCookieName); - return email; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/data-types-service.ts b/catalog-ui/app/scripts/services/data-types-service.ts deleted file mode 100644 index 0e5fca8b5d..0000000000 --- a/catalog-ui/app/scripts/services/data-types-service.ts +++ /dev/null @@ -1,129 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - export interface IDataTypesService { - //declare methods - getAllDataTypes():ng.IPromise<Models.PropertyModel>; - getFirsLevelOfDataTypeProperties(dataTypeName:string, dataTypes:Models.DataTypesMap):Array<Models.DataTypePropertyModel>; - isDataTypeForSchemaType(property:Models.SchemaProperty, types:Models.DataTypesMap):boolean; - isDataTypeForPropertyType(property:Models.PropertyModel, types:Models.DataTypesMap):boolean; - isDataTypeForDataTypePropertyType(property:Models.DataTypePropertyModel, types:Models.DataTypesMap):boolean; - } - - export class DataTypesService implements IDataTypesService { - - static '$inject' = [ - 'sdcConfig', - '$q', - '$http' - ]; - - constructor(private sdcConfig:Models.IAppConfigurtaion, - private $q:ng.IQService, - private $http:ng.IHttpService) { - } - - //if the dt derived from simple- return the first parent type, else- return null - private getTypeForDataTypeDerivedFromSimple = (dataTypeName:string, dataTypes:Models.DataTypesMap):string => { - /////////temporary hack for tosca primitives/////////////////////// - if(!dataTypes[dataTypeName]){ - return 'string'; - } - /////////////////////////////////////////////////////////////////// - if(dataTypes[dataTypeName].derivedFromName == "tosca.datatypes.Root" || dataTypes[dataTypeName].properties){ - return null; - } - if(Utils.Constants.PROPERTY_DATA.SIMPLE_TYPES.indexOf(dataTypes[dataTypeName].derivedFromName) > -1 ){ - return dataTypes[dataTypeName].derivedFromName - } - return this.getTypeForDataTypeDerivedFromSimple(dataTypes[dataTypeName].derivedFromName,dataTypes); - }; - - public getAllDataTypes = ():ng.IPromise<Models.PropertyModel> => { - let deferred = this.$q.defer(); - this.$http({ - url: this.sdcConfig.api.root + this.sdcConfig.api.component_api_root + "dataTypes", - method: "get" - }) - .success((response:any) => { - deferred.resolve(response); - }) - .error((err) => { - deferred.reject(err); - }); - return deferred.promise; - }; - - //return list of data type properties and all its parents properties - //(not include the properties of its properties, in case this data type has not primitive properties) - public getFirsLevelOfDataTypeProperties = (dataTypeName:string, dataTypes:Models.DataTypesMap):Array<Models.DataTypePropertyModel> => { - let properties = dataTypes[dataTypeName].properties || []; - if(dataTypes[dataTypeName].derivedFromName != "tosca.datatypes.Root" ){ - properties = this.getFirsLevelOfDataTypeProperties(dataTypes[dataTypeName].derivedFromName,dataTypes).concat(properties); - } - return properties; - }; - - //return false when type= data type (=not simple type) that not derived from simple type - public isDataTypeForSchemaType = (property:Models.SchemaProperty, types:Models.DataTypesMap):boolean=>{ - property.simpleType=""; - if(property.type && Utils.Constants.PROPERTY_DATA.TYPES.indexOf(property.type) > -1){ - return false; - } - let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type, types); - if(simpleType){ - property.simpleType=simpleType; - return false; - } - return true; - }; - - public isDataTypeForPropertyType = (property:Models.PropertyModel, types:Models.DataTypesMap):boolean=>{ - property.simpleType=""; - if(property.type && Utils.Constants.PROPERTY_DATA.TYPES.indexOf(property.type) > -1){ - return false; - } - let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type, types); - if(simpleType){ - property.simpleType=simpleType; - return false; - } - return true; - }; - - public isDataTypeForDataTypePropertyType = (property:Models.DataTypePropertyModel, types:Models.DataTypesMap):boolean=>{ - property.simpleType=""; - if(property.type && Utils.Constants.PROPERTY_DATA.TYPES.indexOf(property.type) > -1){ - return false; - } - let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type, types); - if(simpleType){ - property.simpleType=simpleType; - return false; - } - return true; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/ecomp-service.ts b/catalog-ui/app/scripts/services/ecomp-service.ts deleted file mode 100644 index d7910bd612..0000000000 --- a/catalog-ui/app/scripts/services/ecomp-service.ts +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface IEcompHeaderService { - getMenuItems(userId): ng.IPromise<Array<any>>; - } - - export class EcompHeaderService implements IEcompHeaderService { - static '$inject' = ['$http', '$q', 'sdcConfig']; - private api:Models.IApi; - - constructor(private $http:ng.IHttpService, - private $q:ng.IQService, - private sdcConfig:Models.IAppConfigurtaion) { - this.api = sdcConfig.api; - } - - getMenuItems = (userId):ng.IPromise<Array<any>> => { - let defer = this.$q.defer<Array<any>>(); - //defer.resolve(this.mockData); - this.$http.get(this.api.root + this.api.GET_ecomp_menu_items.replace(':userId', userId)) - .success((response:any) => { - defer.resolve(response); - }) - .error((response) => { - defer.reject(response); - }); - - return defer.promise; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/entity-service.ts b/catalog-ui/app/scripts/services/entity-service.ts deleted file mode 100644 index a9d5a421ce..0000000000 --- a/catalog-ui/app/scripts/services/entity-service.ts +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface IEntityService { - getAllComponents(): ng.IPromise<Array<Models.Components.Component>>; - } - - interface IComponentsArray { - services:Array<Models.Components.Service>; - resources:Array<Models.Components.Resource>; - products:Array<Models.Components.Product>; - } - - export class EntityService implements IEntityService { - static '$inject' = ['$http', '$q', 'sdcConfig', 'Sdc.Services.SharingService','ComponentFactory','Sdc.Services.CacheService']; - private api:Models.IApi; - - constructor(private $http:ng.IHttpService, - private $q:ng.IQService, - private sdcConfig:Models.IAppConfigurtaion, - private sharingService:Sdc.Services.SharingService, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private cacheService:Sdc.Services.CacheService - ) { - this.api = sdcConfig.api; - } - - getCatalog = ():ng.IPromise<Array<Models.Components.Component>> => { - let defer = this.$q.defer<Array<Models.Components.Component>>(); - this.$http.get(this.api.root + this.api.GET_catalog) - .success((followedResponse:IComponentsArray) => { - - let componentsList:Array<Models.Components.Component> = new Array(); - - followedResponse.services.forEach((serviceResponse: Models.Components.Service) => { - let component:Models.Components.Service = this.ComponentFactory.createService(serviceResponse); // new Models.Components.Service(serviceResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - - followedResponse.resources.forEach((resourceResponse:Models.Components.Resource) => { - let component:Models.Components.Resource = this.ComponentFactory.createResource(resourceResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - - followedResponse.products.forEach((productResponse:Models.Components.Product) => { - - let component:Models.Components.Product = this.ComponentFactory.createProduct(productResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - - this.cacheService.set('breadcrumbsComponents',componentsList); - defer.resolve(componentsList); - }) - .error((responce) => { - defer.reject(responce); - }); - return defer.promise; - }; - - getAllComponents = ():ng.IPromise<Array<Models.Components.Component>> => { - let defer = this.$q.defer<Array<Models.Components.Component>>(); - this.$http.get(this.api.root + this.api.GET_element) - .success((componentResponse:IComponentsArray) => { - let componentsList:Array<Models.Components.Component> = []; - - componentResponse.services && componentResponse.services.forEach((serviceResponse:Models.Components.Service) => { - let component:Models.Components.Service = this.ComponentFactory.createService(serviceResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - - componentResponse.resources && componentResponse.resources.forEach((resourceResponse:Models.Components.Resource) => { - let component:Models.Components.Resource = this.ComponentFactory.createResource(resourceResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - - componentResponse.products && componentResponse.products.forEach((productsResponse:Models.Components.Product) => { - let component:Models.Components.Product = this.ComponentFactory.createProduct(productsResponse); - componentsList.push(component); - this.sharingService.addUuidValue(component.uniqueId, component.uuid); - }); - this.cacheService.set('breadcrumbsComponents',componentsList); - defer.resolve(componentsList); - }); - - return defer.promise; - }; - } -} diff --git a/catalog-ui/app/scripts/services/event-listener-service.ts b/catalog-ui/app/scripts/services/event-listener-service.ts deleted file mode 100644 index 67afd65c56..0000000000 --- a/catalog-ui/app/scripts/services/event-listener-service.ts +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/4/2016. - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface IEventListenerService { - - } - - interface ICallbackData { - callback:Function; - args:any[]; - } - - export class EventListenerService implements IEventListenerService { - - public observerCallbacks:Utils.Dictionary<string, ICallbackData[]> = new Utils.Dictionary<string, Array<ICallbackData>>(); - - //register an observer + callback - public registerObserverCallback = (eventName:string, callback:Function, ...args) => { - let callbackData = { - callback: callback, - args: args - } - - if (this.observerCallbacks.containsKey(eventName)) { - let callbacks = this.observerCallbacks.getValue(eventName); - - // Only insert the callback if the callback is different from existing callbacks. - for (let i = 0; i < callbacks.length; i++) { - if (callbacks[i].toString() === callback.toString()) { - return; // Do not add this callback. - } - } - - callbacks.push(callbackData); - this.observerCallbacks.setValue(eventName, callbacks); - } else { - this.observerCallbacks.setValue(eventName, [callbackData]); - } - }; - - //unregister an observer - public unRegisterObserver = (eventName:string) => { - if (this.observerCallbacks.containsKey(eventName)) { - this.observerCallbacks.remove(eventName); - } - }; - - public notifyObservers = function (eventName:string, ...args) { - _.forEach(this.observerCallbacks.getValue(eventName), (callbackData:ICallbackData) => { - callbackData.callback(...args); - }); - }; - } -} diff --git a/catalog-ui/app/scripts/services/header-interceptor.ts b/catalog-ui/app/scripts/services/header-interceptor.ts deleted file mode 100644 index 7f362d3f8c..0000000000 --- a/catalog-ui/app/scripts/services/header-interceptor.ts +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - //Method name should be exactly "response" - http://docs.angularjs.org/api/ng/service/$http - export interface IInterceptor { - request: Function; - - } - - export class HeaderInterceptor implements IInterceptor { - public static $inject = [ - '$log', - '$injector', - '$q', - 'uuid4', - 'Sdc.Services.SharingService', - 'sdcConfig', - '$location' - - - ]; - - public static Factory($log: ng.ILogService, - $injector: ng.auto.IInjectorService, - $q: ng.IQService, - uuid4: any, - sharingService: Sdc.Services.SharingService, - sdcConfig: Models.IAppConfigurtaion, - $location: ng.ILocationService) { - return new HeaderInterceptor($log, $injector, $q, uuid4, sharingService, sdcConfig, $location); - } - - constructor(private $log: ng.ILogService, - private $injector: ng.auto.IInjectorService, - private $q: ng.IQService, - private uuid4: any, - private sharingService: Sdc.Services.SharingService, - private sdcConfig: Models.IAppConfigurtaion, - private $location: ng.ILocationService) { - this.$log.debug('initializing AuthenticationInterceptor'); - } - - public request = (requestSuccess): ng.IPromise<any> => { - requestSuccess.headers['X-ECOMP-RequestID'] = this.uuid4.generate(); - /** - * For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header. - * Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header. - */ - let map: Utils.Dictionary<string, string> = this.sharingService.getUuidMap(); - if (map && requestSuccess.url.indexOf(this.sdcConfig.api.root) === 0) { - this.$log.debug("url: " + requestSuccess.url); - map.forEach((key: string) => { - if (requestSuccess.url.indexOf(key) !== -1) { - requestSuccess.headers['X-ECOMP-ServiceID'] = this.sharingService.getUuidValue(key); - } - }); - } - return requestSuccess; - }; - - public response = (responseSuccess): ng.IPromise<any> => { - let responseData = responseSuccess.data; - if (responseData) { - let data = JSON.stringify(responseData); - if (data && (data.indexOf("Global Logon: Login") > 0)) { - this.$location.path('dashboard/welcome'); - window.location.reload(); - } - } - return responseSuccess; - } - } -} diff --git a/catalog-ui/app/scripts/services/http-error-interceptor.ts b/catalog-ui/app/scripts/services/http-error-interceptor.ts deleted file mode 100644 index c04659dfec..0000000000 --- a/catalog-ui/app/scripts/services/http-error-interceptor.ts +++ /dev/null @@ -1,118 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export class HttpErrorInterceptor { - public static $inject = ['$injector', '$q']; - - public static Factory($injector: ng.auto.IInjectorService, $q: angular.IQService) { - return new HttpErrorInterceptor($injector, $q); - } - - constructor(private $injector: ng.auto.IInjectorService, private $q: angular.IQService) { - } - - public formatMessageArrays = (message: string, variables: Array<string>)=> { - return message.replace(/\[%(\d+)\]/g, function (_, m) { - let tmp = []; - let list = variables[--m].split(";"); - list.forEach(function (item) { - tmp.push("<li>" + item + "</li>"); - }); - return "<ul>" + tmp.join("") + "</ul>"; - }); - }; - - public responseError = (rejection: any)=> { - - let text: string; - let variables; - let messageId: string = ""; - let isKnownException = false; - - if (rejection.data && rejection.data.serviceException) { - text = rejection.data.serviceException.text; - variables = rejection.data.serviceException.variables; - messageId = rejection.data.serviceException.messageId; - isKnownException = true; - } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.serviceException) { - text = rejection.data.requestError.serviceException.text; - variables = rejection.data.requestError.serviceException.variables; - messageId = rejection.data.requestError.serviceException.messageId; - isKnownException = true; - } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.policyException) { - text = rejection.data.requestError.policyException.text; - variables = rejection.data.requestError.policyException.variables; - messageId = rejection.data.requestError.policyException.messageId; - isKnownException = true; - } else if (rejection.data) { - text = 'Wrong error format from server'; - console.error(text); - isKnownException = false; - } - - let data: Sdc.ViewModels.IServerMessageModalModel; - if (isKnownException) { - // Remove the "Error: " text at the begining - if (text.trim().indexOf("Error:") === 0) { - text = text.replace("Error:", "").trim(); - } - - //mshitrit DE199895 bug fix - let count: number = 0; - variables.forEach(function (item) { - variables[count] = item ? item.replace('<', '<').replace('>', '>') : ''; - count++; - }); - - // Format the message in case has array to <ul><li> - text = this.formatMessageArrays(text, variables); - - // Format the message %1 %2 - text = text.format(variables); - - // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http). - data = { - title: 'Error', - message: text, - messageId: messageId, - status: rejection.status, - severity: Utils.Constants.SEVERITY.ERROR - }; - } else { - // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http). - data = { - title: 'Error', - message: rejection.status !== -1 ? rejection.statusText : "Error getting response from server", - messageId: messageId, - status: rejection.status, - severity: Utils.Constants.SEVERITY.ERROR - }; - } - - let modalsHandler = this.$injector.get('ModalsHandler'); - modalsHandler.openServerMessageModal(data); - - return this.$q.reject(rejection); - } - } -} diff --git a/catalog-ui/app/scripts/services/loader-service.ts b/catalog-ui/app/scripts/services/loader-service.ts deleted file mode 100644 index 6a1a1febe1..0000000000 --- a/catalog-ui/app/scripts/services/loader-service.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Created by obarda on 3/13/2016. - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export class LoaderService { - - - constructor(private eventListenerService: Services.EventListenerService) { - - } - - public showLoader(...args) { - this.eventListenerService.notifyObservers(Utils.Constants.EVENTS.SHOW_LOADER_EVENT, ...args); - } - - public hideLoader(...args) { - this.eventListenerService.notifyObservers(Utils.Constants.EVENTS.HIDE_LOADER_EVENT, ...args); - } - - } - - LoaderService.$inject = ['EventListenerService']; -} diff --git a/catalog-ui/app/scripts/services/onboarding-service.ts b/catalog-ui/app/scripts/services/onboarding-service.ts deleted file mode 100644 index c09871d67f..0000000000 --- a/catalog-ui/app/scripts/services/onboarding-service.ts +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - - interface IOnboardingService { - getOnboardingComponents(): ng.IPromise<Array<Models.Components.IComponent>>; - getComponentFromCsarUuid(csarUuid:string): ng.IPromise<Models.Components.Component>; - downloadOnboardingCsar(packageId:string):ng.IPromise<Models.IFileDownload>; - } - - export class OnboardingService implements IOnboardingService { - - static '$inject' = ['$http', '$q', 'sdcConfig', 'ComponentFactory']; - private api:Models.IApi; - - constructor(private $http:ng.IHttpService, - private $q:ng.IQService, - private sdcConfig:Models.IAppConfigurtaion, - private ComponentFactory: Sdc.Utils.ComponentFactory - ) { - this.api = sdcConfig.api; - } - - getOnboardingComponents = ():ng.IPromise<Array<Models.Components.IComponent>> => { - let defer = this.$q.defer<Array<Models.Components.IComponent>>(); - this.$http.get(this.api.GET_onboarding) - .success((response:any) => { - let onboardingComponents:Array<Models.ICsarComponent> = response.results; - let componentsList:Array<Models.Components.IComponent> = new Array(); - - onboardingComponents.forEach((obc: Models.ICsarComponent) => { - let component:Models.Components.Component = this.ComponentFactory.createFromCsarComponent(obc); - componentsList.push(component); - }); - - defer.resolve(componentsList); - }) - .error((response) => { - defer.reject(response); - }); - - return defer.promise; - }; - - downloadOnboardingCsar = (packageId:string):ng.IPromise<Models.IFileDownload> => { - let defer = this.$q.defer(); - this.$http({ - url: this.api.GET_onboarding + "/" + packageId, - method: "get", - responseType: "blob" - }) - .success((response:any) => { - defer.resolve(response); - }) - .error((err) => { - defer.reject(err); - }); - - return defer.promise; - }; - - getComponentFromCsarUuid = (csarUuid:string):ng.IPromise<Models.Components.Component> => { - let defer = this.$q.defer<Models.Components.Component>(); - this.$http.get(this.api.root + this.api.GET_component_from_csar_uuid.replace(':csar_uuid', csarUuid)) - .success((response:any) => { - let component:Models.Components.Resource; - // If the status is 400, this means that the component not found. - // I do not want to return error from server, because a popup will appear in client with the error. - // So returning success (200) with status 400. - if (response.status!==400) { - component = new Models.Components.Resource(null, this.$q, <Models.Components.Resource>response); - } - defer.resolve(component); - }) - .error((response) => { - defer.reject(response); - }); - - return defer.promise; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/progress-service.ts b/catalog-ui/app/scripts/services/progress-service.ts deleted file mode 100644 index caa463fc98..0000000000 --- a/catalog-ui/app/scripts/services/progress-service.ts +++ /dev/null @@ -1,112 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/7/2016. - */ -/** - * Created by obarda on 7/4/2016. - */ -/// <reference path="../references"/> -module Sdc.Services { - - 'use strict'; - import IIntervalService = angular.IIntervalService; - - export class ProgressService { - - public progresses:any = {}; - - static '$inject' = ['$interval']; - - constructor( - protected $interval:any - ) {} - - private totalProgress:number = 90; - private startProgress:number = 10; - private onePercentIntervalSeconds:number = 5; - private createComponentInterval; - - public setProgressValue(name:string, value:number):void { - if (!this.progresses[name]) { - this.progresses[name]={}; - } - this.progresses[name].value = value; - } - - public getProgressValue(name:string):number{ - if (this.progresses[name]){ - return this.progresses[name].value; - } - return 0; - } - - public deleteProgressValue(name:string):void{ - this.stopCreateComponentInterval(); - delete this.progresses[name]; - } - - - private stopCreateComponentInterval = ():void => { - this.$interval.cancel(this.createComponentInterval); - }; - - - - public initCreateComponentProgress = (componentId:string):void => { - var progressValue:number = this.startProgress; - if(!this.getProgressValue(componentId)){ - this.stopCreateComponentInterval(); - this.setProgressValue(componentId, this.startProgress); - this.createComponentInterval = this.$interval(():void => { - //TODO replace getProgressMockData to real data after BE provide the API - var progressValue = this.getProgressMockData(componentId); - if (progressValue<=this.totalProgress ) { - this.setProgressValue(componentId, progressValue); - } else { - /** - * Currently the progress is not really checking against the BE. - * So the progress can pass 100. So the workaround for now, in case we pass 90 (totalProgress) - * stop the interval, so the progress will be kept at 90 until the promise will return value and set - * the progress to 100. - */ - this.deleteProgressValue(componentId); - } - }, this.onePercentIntervalSeconds*1000); - } - - }; - - - private getProgressMockData =(id:string):number =>{ - var progressValue = this.getProgressValue(id); - if(progressValue>0){ - progressValue = progressValue + 1; - } - //if not finish always stay on 90% - if (progressValue>90){ - progressValue =90; - } - - return progressValue; - } - - } -} diff --git a/catalog-ui/app/scripts/services/relation-icons-service.ts b/catalog-ui/app/scripts/services/relation-icons-service.ts deleted file mode 100644 index 3d3b494f16..0000000000 --- a/catalog-ui/app/scripts/services/relation-icons-service.ts +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export interface IRelationIconsService { - getIconPath(iconName:string):string; - } - - export class RelationIconsService implements IRelationIconsService { - constructor() {} - private icons: Array<string> = [ - 'AttachesTo', - 'BindsTo', - 'DependsOn', - 'HostedOn', - 'LinksTo', - 'RoutesTo' - ]; - - public getIconPath = (relationshipType:string): string => { - let result:string = 'ConnectedTo'; - let baseUrl:string = '/styles/images/relationship-icons/'; - - if (relationshipType) { - let arr = relationshipType.split('.'); // looks like tosca.relationships.AttachesTo - relationshipType = arr[arr.length - 1]; - if (this.icons.indexOf(relationshipType) > -1) { - result = relationshipType; - } - if('LinksTo'==result){ - return ''; - } - } - - return baseUrl + result + '.svg'; - } - - } -} - - - diff --git a/catalog-ui/app/scripts/services/sdc-version-service.ts b/catalog-ui/app/scripts/services/sdc-version-service.ts deleted file mode 100644 index 1744381bca..0000000000 --- a/catalog-ui/app/scripts/services/sdc-version-service.ts +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export interface ISdcVersionService { - getVersion():ng.IPromise<any>; - } - export class SdcVersionService implements ISdcVersionService{ - - static '$inject' = ['$http', '$q','sdcConfig']; - private api: Models.IApi; - - constructor(private $http: ng.IHttpService, private $q: ng.IQService, sdcConfig: Models.IAppConfigurtaion){ - this.api = sdcConfig.api; - } - - public getVersion():ng.IPromise<any>{ - let defer = this.$q.defer<Array<Models.Distribution>>(); - let url = this.api.root + this.api.GET_SDC_Version; - console.log("======================>" + url); - this.$http.get(url) - .success((version: any) => { - defer.resolve(version); - }); - return defer.promise; - } - } -} - diff --git a/catalog-ui/app/scripts/services/sharing-service.ts b/catalog-ui/app/scripts/services/sharing-service.ts deleted file mode 100644 index 14c3158611..0000000000 --- a/catalog-ui/app/scripts/services/sharing-service.ts +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export class SharingService { - - private uuidMap: Utils.Dictionary<string, string> = new Utils.Dictionary<string,string>(); - - public getUuidValue = (uniqueId:string):string => { - return this.uuidMap.getValue(uniqueId); - }; - - public addUuidValue = (uniqueId:string, uuid:string):void => { - this.uuidMap.setValue(uniqueId, uuid); - }; - - public getUuidMap = ():Utils.Dictionary<string, string> => { - return this.uuidMap; - }; - - } -} diff --git a/catalog-ui/app/scripts/services/url-tobase64-service.ts b/catalog-ui/app/scripts/services/url-tobase64-service.ts deleted file mode 100644 index 2d6980da3f..0000000000 --- a/catalog-ui/app/scripts/services/url-tobase64-service.ts +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - export interface IUrlToBase64Service { - downloadUrl(url:string, callback:Function):void; - } - - export class UrlToBase64Service implements IUrlToBase64Service { - constructor() {} - - public downloadUrl = (url:string, callback:Function): void => { - let xhr :any = new XMLHttpRequest(); - - xhr.onload = ():void => { - let reader = new FileReader(); - reader.onloadend = ():void => { - if (xhr.status === 200) { - callback(reader.result); - } else { - callback(null); - } - }; - reader.readAsDataURL(xhr.response); - }; - xhr.open('GET', url); - xhr.responseType = 'blob'; - xhr.send(); - } - - } -} - diff --git a/catalog-ui/app/scripts/services/user-resource-service.ts b/catalog-ui/app/scripts/services/user-resource-service.ts deleted file mode 100644 index 7414e2221e..0000000000 --- a/catalog-ui/app/scripts/services/user-resource-service.ts +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict'; - - // Define an interface of the object you want to use, providing it's properties - export interface IUserResource extends Models.IUserProperties,ng.resource.IResource<IUserResource>{ - - } - - // Define your resource, adding the signature of the custom actions - export interface IUserResourceClass extends ng.resource.IResourceClass<IUserResource>{ - authorize(): IUserResource; - getLoggedinUser(): IUserResource; - setLoggedinUser(user: IUserResource): void; - getAllUsers(success?: Function, error?: Function): Array<IUserResource>; - createUser(IResourceResource, success?: Function, error?: Function): void; - editUserRole(IResourceResource, success?: Function, error?: Function): void; - deleteUser(IResourceResource, success?: Function, error?: Function): void; - } - - export class UserResourceService{ - - public static getResource = ( - $resource: ng.resource.IResourceService, - sdcConfig: Models.IAppConfigurtaion, - cookieService: Services.CookieService - ): IUserResourceClass => { - - let url: string = sdcConfig.api.root+sdcConfig.api.GET_user; - let authorizeUrl: string = sdcConfig.api.root+sdcConfig.api.GET_user_authorize; - let authorizeActionHeaders: any = {}; - let cookie: Models.ICookie = sdcConfig.cookie; - authorizeActionHeaders[cookie.userFirstName] = cookieService.getFirstName(); - authorizeActionHeaders[cookie.userLastName] = cookieService.getLastName(); - authorizeActionHeaders[cookie.userEmail] = cookieService.getEmail(); - authorizeActionHeaders[cookie.userIdSuffix] = cookieService.getUserId(); - - // Define your custom actions here as IActionDescriptor - let authorizeAction : ng.resource.IActionDescriptor = { - method: 'GET', - isArray: false, - url: authorizeUrl, - headers: authorizeActionHeaders - }; - - let getAllUsers : ng.resource.IActionDescriptor = { - method: 'GET', - isArray: true, - url: sdcConfig.api.root + sdcConfig.api.GET_all_users - }; - - let editUserRole : ng.resource.IActionDescriptor = { - method: 'POST', - isArray: false, - url: sdcConfig.api.root + sdcConfig.api.POST_edit_user_role, - transformRequest: (data, headers)=>{ - data.payloadData = undefined; - data.payloadName = undefined; - return JSON.stringify(data); - } - }; - - let deleteUser : ng.resource.IActionDescriptor = { - method: 'DELETE', - isArray: false, - url: sdcConfig.api.root + sdcConfig.api.DELETE_delete_user - }; - - let createUser : ng.resource.IActionDescriptor = { - method: 'POST', - isArray: false, - url: sdcConfig.api.root + sdcConfig.api.POST_create_user, - transformRequest: (data, headers)=>{ - data.payloadData = undefined; - data.payloadName = undefined; - return JSON.stringify(data); - } - }; - let userResource: IUserResourceClass = <IUserResourceClass>$resource( - url, - { id: '@id'}, - { - authorize: authorizeAction, - getAllUsers: getAllUsers, - createUser: createUser, - editUserRole:editUserRole, - deleteUser:deleteUser} - ); - - let _loggedinUser: IUserResource; - - userResource.getLoggedinUser = () => { - return _loggedinUser; - }; - - userResource.setLoggedinUser = (loggedinUser: IUserResource) => { - _loggedinUser = loggedinUser; - }; - - return userResource; - } - } - UserResourceService.getResource.$inject = ['$resource', 'sdcConfig', 'Sdc.Services.CookieService']; -} diff --git a/catalog-ui/app/scripts/utils/artifacts-utils.ts b/catalog-ui/app/scripts/utils/artifacts-utils.ts deleted file mode 100644 index 439a0e98d0..0000000000 --- a/catalog-ui/app/scripts/utils/artifacts-utils.ts +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Utils { - export class ArtifactsUtils { - - static '$inject' = [ - '$filter', - '$templateCache', - '$modal' - ]; - - constructor(private $filter:ng.IFilterService, - private $templateCache:ng.ITemplateCacheService, - private $modal:ng.ui.bootstrap.IModalService) { - - } - - public getArtifactTypeByState(currentState:string):string { - switch (currentState) { - case "workspace.composition.lifecycle": - return "interface"; - case "workspace.composition.api": - return "api"; - case "workspace.composition.deployment": - return "deployment"; - default: - return "normal"; - } - } - - public getTitle(artifactType:string, selectedComponent:Models.Components.Component):string { - switch (artifactType) { - case "interface": - return "Lifecycle Management"; - case "api": - return "API Artifacts"; - case "deployment": - return "Deployment Artifacts"; - default: - if (!selectedComponent) { - return ""; - } else { - return this.$filter("resourceName")(selectedComponent.name) + ' Artifacts'; - } - } - } - - public setArtifactType = (artifact:Models.ArtifactModel, artifactType:string):void => { - switch (artifactType) { - case "api": - artifact.artifactGroupType = 'SERVICE_API'; - break; - case "deployment": - artifact.artifactGroupType = 'DEPLOYMENT'; - break; - default: - artifact.artifactGroupType = 'INFORMATIONAL'; - break; - } - }; - - public isLicenseType = (artifactType:string) :boolean => { - let isLicense:boolean = false; - - if(Utils.Constants.ArtifactType.VENDOR_LICENSE === artifactType || Utils.Constants.ArtifactType.VF_LICENSE === artifactType) { - isLicense = true; - } - - return isLicense; - }; - - public removeArtifact = (artifact:Models.ArtifactModel, artifactsArr:Array<Models.ArtifactModel>):void => { - - if (!artifact.mandatory && (Utils.Constants.ArtifactGroupType.INFORMATION == artifact.artifactGroupType || - Utils.Constants.ArtifactGroupType.DEPLOYMENT == artifact.artifactGroupType)) { - _.remove(artifactsArr, {uniqueId: artifact.uniqueId}); - } - else { - let artifactToDelete = _.find(artifactsArr, {uniqueId: artifact.uniqueId}); - - delete artifactToDelete.esId; - delete artifactToDelete.description; - delete artifactToDelete.artifactName; - delete artifactToDelete.apiUrl; - } - }; - - public addAnotherAfterSave(scope:Sdc.ViewModels.IArtifactResourceFormViewModelScope) { - let newArtifact = new Models.ArtifactModel(); - this.setArtifactType(newArtifact, scope.artifactType); - scope.editArtifactResourceModel.artifactResource = newArtifact; - - scope.forms.editForm['description'].$setPristine(); - if(scope.forms.editForm['artifactLabel']){ - scope.forms.editForm['artifactLabel'].$setPristine(); - } - if(scope.forms.editForm['type']){ - scope.forms.editForm['type'].$setPristine(); - } - - } - } -} diff --git a/catalog-ui/app/scripts/utils/change-lifecycle-state-handler.ts b/catalog-ui/app/scripts/utils/change-lifecycle-state-handler.ts deleted file mode 100644 index 7722a899b9..0000000000 --- a/catalog-ui/app/scripts/utils/change-lifecycle-state-handler.ts +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/11/2016. - */ -/// <reference path="../references"/> -module Sdc.Utils { - - export class ChangeLifecycleStateHandler { - - static '$inject' = [ - 'sdcConfig', - 'sdcMenu', - 'ComponentFactory', - '$templateCache', - '$filter', - '$modal', - 'ModalsHandler' - ]; - - constructor( - private sdcConfig:Models.IAppConfigurtaion, - private sdcMenu:Models.IAppMenu, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private ModalsHandler: Utils.ModalsHandler - - ) { - - } - - changeLifecycleState = (component:Models.Components.Component, data:any, scope:any, onSuccessCallback?: Function, onErrorCallback?: Function):void => { - - let self = this; - - let getContacts = (component:Models.Components.Component):string =>{ - let testers = this.sdcConfig.testers; - let result:string = testers[component.componentType][component.categories[0].name]? - testers[component.componentType][component.categories[0].name]: - testers[component.componentType]['default']; - return result; - }; - - let onSuccess = (newComponent:Models.Components.Component):void => { - //scope.isLoading = false; - console.info(component.componentType.toLowerCase + ' change state ' , newComponent); - if(onSuccessCallback) { - onSuccessCallback(self.ComponentFactory.createComponent(newComponent)); - } - }; - - let onError = (error):void => { - scope.isLoading = false; - console.info('Failed to changeLifecycleState to ', data.url); - if(onErrorCallback) { - onErrorCallback(error); - } - }; - - let comment:Models.AsdcComment = new Models.AsdcComment(); - if (data.alertModal) { - // Show alert dialog if defined in menu.json - //------------------------------------------------- - let onOk = (confirmationText):void => { - comment.userRemarks = confirmationText; - scope.isLoading = true; - component.changeLifecycleState(data.url, comment).then(onSuccess, onError); - }; - - let onCancel = ():void => { - console.info('Cancel pressed'); - scope.isLoading = false; - }; - - let modalTitle = this.sdcMenu.alertMessages[data.alertModal].title; - let modalMessage = this.sdcMenu.alertMessages[data.alertModal].message.format([component.componentType.toLowerCase()]); - this.ModalsHandler.openAlertModal(modalTitle, modalMessage).then(onOk, onCancel); - } else if (data.confirmationModal) { - // Show confirmation dialog if defined in menu.json - //------------------------------------------------- - let onOk = (confirmationText):void => { - comment.userRemarks = confirmationText; - scope.isLoading = true; - component.changeLifecycleState(data.url, comment).then(onSuccess, onError); - }; - - let onCancel = ():void => { - console.info('Cancel pressed'); - scope.isLoading = false; - }; - - let modalTitle = this.sdcMenu.confirmationMessages[data.confirmationModal].title; - let modalMessage = this.sdcMenu.confirmationMessages[data.confirmationModal].message.format([component.componentType.toLowerCase()]); - let modalShowComment = this.sdcMenu.confirmationMessages[data.confirmationModal].showComment; - this.ModalsHandler.openConfirmationModal(modalTitle, modalMessage, modalShowComment).then(onOk, onCancel); - - } else if (data.emailModal) { - // Show email dialog if defined in menu.json - //------------------------------------------------- - let onOk = (resource):void => { - if (resource){ - onSuccess(resource); - } else { - onError("Error changing life cycle state"); - } - }; - - let onCancel = ():void => { - scope.isLoading = false; - }; - - let emailModel: ViewModels.IEmailModalModel = <ViewModels.IEmailModalModel>{}; - emailModel.email = <ViewModels.IEmailModalModel_Email>{}; - emailModel.data = <ViewModels.IEmailModalModel_Data>{}; - emailModel.title = this.$filter('translate')("EMAIL_MODAL_TITLE"); - emailModel.email.to = getContacts(component); - emailModel.email.subject = this.$filter('translate')("EMAIL_MODAL_SUBJECT", "{'entityName': '" + this.$filter('resourceName')(component.name) + "','entityVersion': '" + component.version + "'}"); - emailModel.email.message = ''; - emailModel.data.component = component; - emailModel.data.stateUrl = data.url; - - this.ModalsHandler.openEmailModal(emailModel).then(onOk, onCancel); - - } else { - // Submit to server only (no modal is shown). - scope.isLoading = true; - component.changeLifecycleState(data.url, comment).then(onSuccess, onError); - } - - } - } -} diff --git a/catalog-ui/app/scripts/utils/common-utils.ts b/catalog-ui/app/scripts/utils/common-utils.ts deleted file mode 100644 index aef6b9908d..0000000000 --- a/catalog-ui/app/scripts/utils/common-utils.ts +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 6/30/2016. - */ -/// <reference path="../references.ts"/> -module Sdc.Utils { - - export class CommonUtils { - - static initProperties(propertiesObj:Array<Sdc.Models.PropertyModel>, uniqueId?:string):Array<Sdc.Models.PropertyModel> { - - let properties = new Array<Sdc.Models.PropertyModel>(); - if (propertiesObj) { - _.forEach(propertiesObj, (property:Sdc.Models.PropertyModel):void => { - if (uniqueId) { - property.readonly = property.parentUniqueId != uniqueId; - } - properties.push(new Sdc.Models.PropertyModel(property)); - }); - } - return properties; - }; - - static initAttributes(attributesObj:Array<Sdc.Models.AttributeModel>, uniqueId?:string):Array<Sdc.Models.AttributeModel> { - - let attributes = new Array<Sdc.Models.AttributeModel>(); - if (attributesObj) { - _.forEach(attributesObj, (attribute:Sdc.Models.AttributeModel):void => { - if (uniqueId) { - attribute.readonly = attribute.parentUniqueId != uniqueId; - } - attributes.push(new Sdc.Models.AttributeModel(attribute)); - }); - } - return attributes; - }; - - static initComponentInstances(componentInstanceObj:Array<Models.ComponentsInstances.ResourceInstance>):Array<Models.ComponentsInstances.ResourceInstance> { - - let componentInstances = new Array<Models.ComponentsInstances.ResourceInstance>(); - if (componentInstanceObj) { - _.forEach(componentInstanceObj, (instance:Models.ComponentsInstances.ResourceInstance):void => { - componentInstances.push(Utils.ComponentInstanceFactory.createComponentInstance(instance)); - }); - } - return componentInstances; - }; - - static initModules(moduleArrayObj:Array<Models.Module>):Array<Models.Module> { - - let modules = new Array<Models.Module>(); - - if (moduleArrayObj) { - _.forEach(moduleArrayObj, (module:Models.Module):void => { - if(module.type === "org.openecomp.groups.VfModule"){ - modules.push(new Models.Module(module)); - } - }); - } - return modules; - }; - } -} diff --git a/catalog-ui/app/scripts/utils/component-factory.ts b/catalog-ui/app/scripts/utils/component-factory.ts deleted file mode 100644 index 1bb139dc45..0000000000 --- a/catalog-ui/app/scripts/utils/component-factory.ts +++ /dev/null @@ -1,181 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/8/2016. - */ -/// <reference path="../references"/> -module Sdc.Utils { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - - export class ComponentFactory { - - static '$inject' = [ - 'Sdc.Services.Components.ResourceService', - 'Sdc.Services.Components.ServiceService', - 'Sdc.Services.Components.ProductService', - 'Sdc.Services.CacheService', - '$q' - ]; - - constructor( - private ResourceService:Services.Components.ResourceService, - private ServiceService:Services.Components.ServiceService, - private ProductService:Services.Components.ProductService, - private cacheService:Services.CacheService, - private $q: ng.IQService) { - } - - public createComponent = (component:Models.Components.Component):Models.Components.Component => { - let newComponent:Models.Components.Component; - switch (component.componentType) { - - case 'SERVICE': - newComponent = new Models.Components.Service(this.ServiceService, this.$q, <Models.Components.Service> component); - break; - - case 'RESOURCE': - newComponent = new Models.Components.Resource(this.ResourceService, this.$q, <Models.Components.Resource> component); - break; - - case 'PRODUCT': - newComponent = new Models.Components.Product(this.ProductService, this.$q, <Models.Components.Product> component); - break; - } - return newComponent; - }; - - public createProduct = (product:Models.Components.Product):Models.Components.Product => { - let newProduct:Models.Components.Product = new Models.Components.Product(this.ProductService, this.$q, <Models.Components.Product> product); - return newProduct; - }; - - public createService = (service:Models.Components.Service):Models.Components.Service => { - let newService:Models.Components.Service = new Models.Components.Service(this.ServiceService, this.$q, <Models.Components.Service> service); - return newService; - }; - - public createResource = (resource:Models.Components.Resource):Models.Components.Resource => { - let newResource:Models.Components.Resource = new Models.Components.Resource(this.ResourceService, this.$q, <Models.Components.Resource> resource); - return newResource; - }; - - public createFromCsarComponent = (csar:Models.ICsarComponent):Models.Components.Component => { - let newResource:Sdc.Models.Components.Resource = <Sdc.Models.Components.Resource>this.createEmptyComponent(Sdc.Utils.Constants.ComponentType.RESOURCE); - newResource.name = csar.vspName; - - /** - * Onboarding CSAR contains category and sub category that are uniqueId. - * Need to find the category and sub category and extract the name from them. - * First concat all sub categories to one array. - * Then find the selected sub category and category. - * @type {any} - */ - let availableCategories = angular.copy(this.cacheService.get('resourceCategories')); - let allSubs = []; - _.each(availableCategories, (main:Models.IMainCategory)=>{ - if (main.subcategories) { - allSubs = allSubs.concat(main.subcategories); - } - }); - - let selectedCategory:Models.IMainCategory = _.find(availableCategories, function(main:Models.IMainCategory){ - return main.uniqueId === csar.category; - }); - - let selectedSubCategory:Models.ISubCategory = _.find(allSubs,(sub:Models.ISubCategory)=>{ - return sub.uniqueId === csar.subCategory; - }); - - // Build the categories and sub categories array (same format as component category) - let categories:Array<Models.IMainCategory> = new Array(); - let subcategories:Array<Models.ISubCategory> = new Array(); - if (selectedCategory && selectedSubCategory) { - subcategories.push(selectedSubCategory); - selectedCategory.subcategories = subcategories; - categories.push(selectedCategory); - } - - // Fill the component with details from CSAR - newResource.selectedCategory = selectedCategory && selectedSubCategory ? selectedCategory.name + "_#_" + selectedSubCategory.name : ''; - newResource.categories = categories; - newResource.vendorName = csar.vendorName; - newResource.vendorRelease = csar.vendorRelease; - newResource.csarUUID = csar.packageId; - newResource.csarPackageType = csar.packageType; - newResource.csarVersion = csar.version; - newResource.packageId = csar.packageId; - newResource.description = csar.description; - return newResource; - }; - - public createEmptyComponent = (componentType: string):Models.Components.Component => { - let newComponent:Models.Components.Component; - - switch (componentType) { - - case Utils.Constants.ComponentType.SERVICE: - newComponent = new Models.Components.Service(this.ServiceService, this.$q); - break; - - case Utils.Constants.ComponentType.RESOURCE: - case Utils.Constants.ResourceType.VF: - case Utils.Constants.ResourceType.VL: - case Utils.Constants.ResourceType.VFC: - case Utils.Constants.ResourceType.CP: - newComponent = new Models.Components.Resource(this.ResourceService, this.$q); - break; - - case Utils.Constants.ComponentType.PRODUCT: - newComponent = new Models.Components.Product(this.ProductService, this.$q); - break; - } - newComponent.componentType = componentType; - newComponent.tags = []; - newComponent.icon = Utils.Constants.DEFAULT_ICON; - return newComponent; - }; - - - public getServiceFromServer = (componentId: string): ng.IPromise<Models.Components.Service> => { - let service: Models.Components.Service = <Models.Components.Service>this.createEmptyComponent(Utils.Constants.ComponentType.SERVICE); - service.setUniqueId(componentId); - return service.getComponent(); - }; - - public getResourceFromServer = (componentId: string): ng.IPromise<Models.Components.Resource> => { - let resource: Models.Components.Resource = <Models.Components.Resource>this.createEmptyComponent(Utils.Constants.ComponentType.RESOURCE); - resource.setUniqueId(componentId); - return resource.getComponent(); - }; - - public getComponentFromServer = (componentType: string, componentId: string): ng.IPromise<Models.Components.Component> => { - let newComponent: Models.Components.Component = this.createEmptyComponent(componentType); - newComponent.setUniqueId(componentId); - return newComponent.getComponent(); - }; - - public createComponentOnServer = (componentObject:Models.Components.Component):ng.IPromise<Models.Components.Component> => { - let component: Models.Components.Component = this.createComponent(componentObject); - return component.createComponentOnServer(); - - }; - } -} diff --git a/catalog-ui/app/scripts/utils/component-instance-factory.ts b/catalog-ui/app/scripts/utils/component-instance-factory.ts deleted file mode 100644 index 5f698aa46c..0000000000 --- a/catalog-ui/app/scripts/utils/component-instance-factory.ts +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 3/7/2016. - */ -/** - * Created by obarda on 2/8/2016. - */ -/// <reference path="../references"/> -module Sdc.Utils { - 'use strict'; - - export class ComponentInstanceFactory { - - static createComponentInstance(componentInstance:Models.ComponentsInstances.ComponentInstance):Models.ComponentsInstances.ComponentInstance { - let newComponentInstance:Models.ComponentsInstances.ComponentInstance; - switch (componentInstance.originType) { - case 'SERVICE': - newComponentInstance = new Models.ComponentsInstances.ServiceInstance(componentInstance); - break; - - case 'PRODUCT': - newComponentInstance = new Models.ComponentsInstances.ProductInstance(componentInstance); - break; - - default : - newComponentInstance = new Models.ComponentsInstances.ResourceInstance(componentInstance); - break; - } - return newComponentInstance; - }; - - public createEmptyComponentInstance = (componentInstanceType?: string):Models.ComponentsInstances.ComponentInstance => { - let newComponentInstance:Models.ComponentsInstances.ComponentInstance; - switch (componentInstanceType) { - case 'SERVICE': - newComponentInstance = new Models.ComponentsInstances.ServiceInstance(); - break; - - case 'PRODUCT': - newComponentInstance = new Models.ComponentsInstances.ProductInstance(); - break; - - default : - newComponentInstance = new Models.ComponentsInstances.ResourceInstance(); - break; - } - return newComponentInstance; - }; - - public createComponentInstanceFromComponent = (component: Models.Components.Component):Models.ComponentsInstances.ComponentInstance => { - let newComponentInstance:Models.ComponentsInstances.ComponentInstance = this.createEmptyComponentInstance(component.componentType); - newComponentInstance.uniqueId = component.uniqueId + (new Date()).getTime(); - newComponentInstance.posX = 0; - newComponentInstance.posY = 0; - newComponentInstance.name = component.name; - newComponentInstance.componentVersion = component.version; - newComponentInstance.originType = component.getComponentSubType(); - //new component instance -> req. & cap. are added on successful instance creation - newComponentInstance.requirements = component.requirements; - newComponentInstance.capabilities = component.capabilities; - newComponentInstance.icon = component.icon; - newComponentInstance.componentUid = component.uniqueId; - return newComponentInstance; - }; - - } -} diff --git a/catalog-ui/app/scripts/utils/constants.ts b/catalog-ui/app/scripts/utils/constants.ts deleted file mode 100644 index 6db1edf29d..0000000000 --- a/catalog-ui/app/scripts/utils/constants.ts +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/18/2016. - */ -/// <reference path="../references"/> -module Sdc.Utils.Constants { - - import SuiteOrSpec = jasmine.SuiteOrSpec; - export let DEFAULT_ICON = 'defaulticon'; - export let CP_END_POINT = 'CpEndPoint'; - export let CHANGE_COMPONENT_CSAR_VERSION_FLAG = 'changeComponentCsarVersion'; - export let IMAGE_PATH = ''; - - export class ComponentType { - static SERVICE = 'SERVICE'; - static RESOURCE = 'RESOURCE'; - static PRODUCT = 'PRODUCT'; - } - - export class ResourceType { - static VF = 'VF'; - static VL = 'VL'; - static CP = 'CP'; - static VFC = 'VFC'; - } - - export class ComponentState { - static CERTIFICATION_IN_PROGRESS = 'CERTIFICATION_IN_PROGRESS'; - static CERTIFIED = 'CERTIFIED'; - static NOT_CERTIFIED_CHECKOUT = 'NOT_CERTIFIED_CHECKOUT'; - static NOT_CERTIFIED_CHECKIN = 'NOT_CERTIFIED_CHECKIN'; - static READY_FOR_CERTIFICATION = 'READY_FOR_CERTIFICATION'; - } - - export class DistributionStatus { - DISTRIBUTION_NOT_APPROVED = 'DISTRIBUTION_NOT_APPROVED'; - DISTRIBUTION_APPROVED = 'DISTRIBUTION_APPROVED'; - DISTRIBUTED = 'DISTRIBUTED'; - DISTRIBUTION_REJECTED = 'DISTRIBUTION_REJECTED'; - } - - export class ArtifactGroupType { - static DEPLOYMENT = "DEPLOYMENT"; - static INFORMATION = "INFORMATIONAL"; - static SERVICE_API = "SERVICE_API"; - } - - export class ArtifactType { - static HEAT = "HEAT"; - static VF_LICENSE = "VF_LICENSE"; - static VENDOR_LICENSE = "VENDOR_LICENSE"; - static THIRD_PARTY_RESERVED_TYPES = { WORKFLOW:"WORKFLOW", - NETWORK_CALL_FLOW:"NETWORK_CALL_FLOW", - AAI_SERVICE_MODEL:"AAI_SERVICE_MODEL", - AAI_VF_MODEL:"AAI_VF_MODEL", - AAI_VF_MODULE_MODEL:"AAI_VF_MODULE_MODEL", - AAI_VF_INSTANCE_MODEL:"AAI_VF_INSTANCE_MODEL"}; - static TOSCA = { TOSCA_TEMPLATE:"TOSCA_TEMPLATE", TOSCA_CSAR:"TOSCA_CSAR"}; - } - - export class SEVERITY { - public static DEBUG = 'DEBUG'; - public static INFO = 'INFO'; - public static WARNING = 'WARNING'; - public static ERROR = 'ERROR'; - } - - export class PROPERTY_TYPES { - public static STRING = 'string'; - public static INTEGER = 'integer'; - public static FLOAT = 'float'; - public static BOOLEAN = 'boolean'; - public static JSON = 'json'; - public static MAP = 'map'; - public static LIST = 'list'; - } - - export class SOURCES { - public static A_AND_AI = 'A&AI'; - public static ORDER = 'Order'; - public static RUNTIME = 'Runtime'; - } - - export class PROPERTY_DATA { - public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP]; - public static SIMPLE_TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON]; - public static SOURCES = [SOURCES.A_AND_AI, SOURCES.ORDER, SOURCES.RUNTIME]; - } - - export class PROPERTY_VALUE_CONSTRAINTS { - public static MAX_LENGTH = 100; - public static JSON_MAX_LENGTH = 4096; - } - - export class Role { - public static ADMIN = 'ADMIN'; - public static DESIGNER = 'DESIGNER'; - public static PRODUCT_STRATEGIST = 'PRODUCT_STRATEGIST'; - public static PRODUCT_MANAGER = 'PRODUCT_MANAGER'; - public static TESTER = 'TESTER'; - public static OPS = 'OPS'; - public static GOVERNOR = 'GOVERNOR'; - } - - export enum FormState{ - CREATE, - UPDATE, - IMPORT, - VIEW - } - - export class WorkspaceMode { - public static CREATE = 'create'; - public static EDIT = 'edit'; - public static IMPORT = 'import'; - public static VIEW = 'view'; - } - - export class ImagesUrl { - public static RESOURCE_ICONS = '/styles/images/resource-icons/'; - public static SERVICE_ICONS = '/styles/images/service-icons/'; - public static SELECTED_UCPE_INSTANCE = '/styles/images/resource-icons/selectedUcpeInstance.png'; - public static SELECTED_CP_INSTANCE = '/styles/images/resource-icons/selectedCPInstance.png'; - public static SELECTED_VL_INSTANCE = '/styles/images/resource-icons/selectedVLInstance.png'; - public static CANVAS_PLUS_ICON = '/styles/images/resource-icons/canvasPlusIcon.png'; - public static MODULE_ICON = '/styles/images/resource-icons/module.png'; - public static OPEN_MODULE_ICON = '/styles/images/resource-icons/openModule.png'; - public static OPEN_MODULE_HOVER_ICON = '/styles/images/resource-icons/openModuleHover.png'; - public static CLOSE_MODULE_ICON = '/styles/images/resource-icons/closeModule.png'; - public static CLOSE_MODULE_HOVER_ICON = '/styles/images/resource-icons/closeModuleHover.png'; - } - - export class ModalType { - static STANDARD = 'standard'; - static ERROR = 'error'; - static ALERT = 'alert'; - } - - export class GraphColors { - public static NOT_CERTIFIED_LINK = 'rgb(218,31,61)'; - public static VL_LINK = 'rgb(216,216,216)'; - public static ACTIVE_LINK = '#30bdf2'; - public static BASE_LINK = 'rgb(55,55,55)'; - public static NODE_BACKGROUND_COLOR = 'rgba(46, 162, 157, 0.24)'; - public static NODE_SHADOW_COLOR = 'rgba(198, 230, 228, 0.7)'; - public static NODE_OVERLAPPING_BACKGROUND_COLOR = 'rgba(179, 10, 60, 0.24)'; - public static NODE_OVERLAPPING_SHADOW_COLOR = 'rgba(236, 194, 206, 0.7)'; - public static NODE_UCPE_CP = '#9063cd'; - public static NODE_UCPE = '#fbfbfb'; - public static NODE_SELECTED_BORDER_COLOR = '#30bdf2'; - } - - export class GraphTransactionLogText { - public static REMOVE_TEMP_LINK = "remove tempLink"; - public static DELETE_LINK = "delete link"; - public static ADD_LINK = "delete link"; - public static ADD_NODE = "adding node"; - } - - export class GraphUIObjects { - public static LINK_MENU_HEIGHT = 420; - public static TOP_HEADER_HEIGHT = 200; - public static TOOLTIP_OFFSET_X = 50; - public static TOOLTIP_OFFSET_Y = 145; - public static TOOLTIP_LINK_OFFSET_X = 35; - public static TOOLTIP_LINK_OFFSET_Y = 75; - public static MENU_LINK_VL_HEIGHT_OFFSET = 250; - public static MENU_LINK_VL_WIDTH_OFFSET = 200; - public static MENU_LINK_SIMPLE_HEIGHT_OFFSET = 180; - public static MENU_LINK_SIMPLE_WIDTH_OFFSET = 130; - public static DIAGRAM_RIGHT_WIDTH_OFFSET = 248; - public static DIAGRAM_HEADER_OFFSET = 103; - public static DIAGRAM_PALETTE_WIDTH_OFFSET = 247; - - } - - export class States { - public static WORKSPACE_GENERAL = 'workspace.general'; - public static WORKSPACE_ICONS = 'workspace.icons'; - public static WORKSPACE_ACTIVITY_LOG = 'workspace.activity_log'; - public static WORKSPACE_DEPLOYMENT_ARTIFACTS = 'workspace.deployment_artifacts'; - public static WORKSPACE_PROPERTIES = 'workspace.properties'; - public static WORKSPACE_SERVICE_INPUTS = 'workspace.service_inputs'; - public static WORKSPACE_RESOURCE_INPUTS = 'workspace.resource_inputs'; - public static WORKSPACE_ATTRIBUTES = 'workspace.attributes'; - public static WORKSPACE_HIERARCHY = 'workspace.hierarchy'; - public static WORKSPACE_INFORMATION_ARTIFACTS = 'workspace.information_artifacts'; - public static WORKSPACE_TOSCA_ARTIFACTS = 'workspace.tosca_artifacts'; - public static WORKSPACE_COMPOSITION = 'workspace.composition'; - public static WORKSPACE_NETWORK_CALL_FLOW = 'workspace.network_call_flow'; - public static WORKSPACE_MANAGEMENT_WORKFLOW = 'workspace.management_workflow'; - public static WORKSPACE_DEPLOYMENT = 'workspace.deployment'; - public static WORKSPACE_DISTRIBUTION = 'workspace.distribution'; - public static WORKSPACE_REQUIREMENTS_AND_CAPABILITIES = 'workspace.reqAndCap'; - } - - export class EVENTS { - static RESOURCE_LEFT_PALETTE_UPDATE_EVENT = "resourceLeftPanelUpdateEvent"; - static SERVICE_LEFT_PALETTE_UPDATE_EVENT = "serviceLeftPanelUpdateEvent"; - static PRODUCT_LEFT_PALETTE_UPDATE_EVENT = "productLeftPanelUdateEvent"; - static VL_LEFT_PALETTE_UPDATE_EVENT = "vlLeftPanelUdateEvent"; - static ON_CSAR_LOADING = "onCsarLoading"; - static DOWNLOAD_ARTIFACT_FINISH_EVENT = "downloadArtifactFinishEvent"; - static ON_WORKSPACE_SAVE_BUTTON_CLICK = "onWorkspaceSaveButtonClick"; - static ON_WORKSPACE_SAVE_BUTTON_SUCCESS = "onWorkspaceSaveButtonSuccess"; - static ON_WORKSPACE_SAVE_BUTTON_ERROR = "onWorkspaceSaveButtonError"; - - //Loader events - static SHOW_LOADER_EVENT = "showLoaderEvent"; - static HIDE_LOADER_EVENT = "hideLoaderEvent"; - } - - export class GRAPH_EVENTS { - static ON_NODE_SELECTED = "onNodeSelected"; - static ON_GRAPH_BACKGROUND_CLICKED = "onGraphBackgroundClicked"; - static ON_PALETTE_COMPONENT_HOVER_IN = 'onPaletteComponentHoverIn'; - static ON_PALETTE_COMPONENT_HOVER_OUT = 'onPaletteComponentHoverOut'; - static ON_PALETTE_COMPONENT_DRAG_START = 'onPaletteComponentDragStart'; - static ON_PALETTE_COMPONENT_DRAG_ACTION = 'onPaletteComponentDragAction'; - static ON_COMPONENT_INSTANCE_NAME_CHANGED = 'onComponentInstanceNameChanged'; - static ON_DELETE_COMPONENT_INSTANCE = 'onDeleteComponentInstance'; - static ON_DELETE_MULTIPLE_COMPONENTS = 'onDeleteMultipleComponents'; - static ON_DELETE_EDGE = 'onDeleteEdge'; - static ON_INSERT_NODE_TO_UCPE = 'onInsertNodeToUCPE'; - static ON_REMOVE_NODE_FROM_UCPE = 'onRemoveNodeFromUCPE'; - static ON_VERSION_CHANGED = 'onVersionChanged'; - } - -} diff --git a/catalog-ui/app/scripts/utils/dictionary/dictionary.ts b/catalog-ui/app/scripts/utils/dictionary/dictionary.ts deleted file mode 100644 index ef9a1bc4ea..0000000000 --- a/catalog-ui/app/scripts/utils/dictionary/dictionary.ts +++ /dev/null @@ -1,257 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - - This code was copy from collections.ts lib - https://github.com/basarat/typescript-collections -**/ - -module Sdc.Utils{ - 'use strict'; - - // Used internally by dictionary - interface IDictionaryPair<K, V>{ - key: K; - value: V; - } - - export class Dictionary<K, V>{ - - /** - * Object holding the key-value pairs. - * @type {Object} - * @private - */ - private table: { [key: string]: IDictionaryPair<K, V> }; - //: [key: K] will not work since indices can only by strings in javascript and typescript enforces this. - - /** - * Number of elements in the list. - * @type {number} - * @private - */ - private nElements: number; - - /** - * Function used to convert keys to strings. - * @type {function(Object):string} - * @private - */ - private toStr: (key: K) => string; - - - /** - * Creates an empty dictionary. - * @class <p>Dictionaries map keys to values; each key can map to at most one value. - * This implementation accepts any kind of objects as keys.</p> - * - * <p>If the keys are custom objects a function which converts keys to unique - * strings must be provided. Example:</p> - * <pre> - * function petToString(pet) { - * return pet.name; - * } - * </pre> - * @constructor - * @param {function(Object):string=} toStrFunction optional function used - * to convert keys to strings. If the keys aren"t strings or if toString() - * is not appropriate, a custom function which receives a key and returns a - * unique string must be provided. - */ - constructor(toStrFunction?: (key: K) => string) { - this.table = {}; - this.nElements = 0; - this.toStr = toStrFunction || this.defaultToString; - } - - - /** - copy from angular.js isUndefined - */ - private isUndefined = (value: any):boolean => { - return typeof value === 'undefined'; - } - - defaultToString = (item: any): string => { - return item.toString(); - } - - /** - * Returns the value to which this dictionary maps the specified key. - * Returns undefined if this dictionary contains no mapping for this key. - * @param {Object} key key whose associated value is to be returned. - * @return {*} the value to which this dictionary maps the specified key or - * undefined if the map contains no mapping for this key. - */ - getValue = (key: K): V => { - let pair: IDictionaryPair<K, V> = this.table[this.toStr(key)]; - if (this.isUndefined(pair)) { - return undefined; - } - return pair.value; - } - - - /** - * Associates the specified value with the specified key in this dictionary. - * If the dictionary previously contained a mapping for this key, the old - * value is replaced by the specified value. - * @param {Object} key key with which the specified value is to be - * associated. - * @param {Object} value value to be associated with the specified key. - * @return {*} previous value associated with the specified key, or undefined if - * there was no mapping for the key or if the key/value are undefined. - */ - setValue = (key: K, value: V): V => { - - if (this.isUndefined(key) || this.isUndefined(value)) { - return undefined; - } - - let ret: V; - let k = this.toStr(key); - let previousElement: IDictionaryPair<K, V> = this.table[k]; - if (this.isUndefined(previousElement)) { - this.nElements++; - ret = undefined; - } else { - ret = previousElement.value; - } - this.table[k] = { - key: key, - value: value - }; - return ret; - } - - /** - * Removes the mapping for this key from this dictionary if it is present. - * @param {Object} key key whose mapping is to be removed from the - * dictionary. - * @return {*} previous value associated with specified key, or undefined if - * there was no mapping for key. - */ - remove = (key: K): V => { - let k = this.toStr(key); - let previousElement: IDictionaryPair<K, V> = this.table[k]; - if (!this.isUndefined(previousElement)) { - delete this.table[k]; - this.nElements--; - return previousElement.value; - } - return undefined; - } - - /** - * Returns an array containing all of the keys in this dictionary. - * @return {Array} an array containing all of the keys in this dictionary. - */ - keys = (): K[] => { - let array: K[] = []; - for (let name in this.table) { - if (this.table.hasOwnProperty(name)) { - let pair: IDictionaryPair<K, V> = this.table[name]; - array.push(pair.key); - } - } - return array; - } - - /** - * Returns an array containing all of the values in this dictionary. - * @return {Array} an array containing all of the values in this dictionary. - */ - values = (): V[] => { - let array: V[] = []; - for (let name in this.table) { - if (this.table.hasOwnProperty(name)) { - let pair: IDictionaryPair<K, V> = this.table[name]; - array.push(pair.value); - } - } - return array; - } - - /** - * Executes the provided function once for each key-value pair - * present in this dictionary. - * @param {function(Object,Object):*} callback function to execute, it is - * invoked with two arguments: key and value. To break the iteration you can - * optionally return false. - */ - forEach = (callback: (key: K, value: V) => any): void => { - for (let name in this.table) { - if (this.table.hasOwnProperty(name)) { - let pair: IDictionaryPair<K, V> = this.table[name]; - let ret = callback(pair.key, pair.value); - if (ret === false) { - return; - } - } - } - } - - /** - * Returns true if this dictionary contains a mapping for the specified key. - * @param {Object} key key whose presence in this dictionary is to be - * tested. - * @return {boolean} true if this dictionary contains a mapping for the - * specified key. - */ - containsKey = (key: K): boolean => { - return !this.isUndefined(this.getValue(key)); - } - - /** - * Removes all mappings from this dictionary. - * @this {Dictionary} - */ - clear = () => { - - this.table = {}; - this.nElements = 0; - } - - /** - * Returns the number of keys in this dictionary. - * @return {number} the number of key-value mappings in this dictionary. - */ - size = (): number => { - return this.nElements; - } - - /** - * Returns true if this dictionary contains no mappings. - * @return {boolean} true if this dictionary contains no mappings. - */ - isEmpty = (): boolean => { - return this.nElements <= 0; - } - - toString = (): string => { - let toret = "{"; - this.forEach((k, v) => { - toret = toret + "\n\t" + k.toString() + " : " + v.toString(); - }); - return toret + "\n}"; - } - } // End of dictionary - -} diff --git a/catalog-ui/app/scripts/utils/file-utils.ts b/catalog-ui/app/scripts/utils/file-utils.ts deleted file mode 100644 index db6251f199..0000000000 --- a/catalog-ui/app/scripts/utils/file-utils.ts +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Utils { - export class FileUtils { - - static '$inject' = [ - '$window' - ]; - - constructor(private $window: any) { - } - - public byteCharactersToBlob = (byteCharacters, contentType): any => { - contentType = contentType || ''; - let sliceSize = 1024; - let bytesLength = byteCharacters.length; - let slicesCount = Math.ceil(bytesLength / sliceSize); - let byteArrays = new Array(slicesCount); - - for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) { - let begin = sliceIndex * sliceSize; - let end = Math.min(begin + sliceSize, bytesLength); - - let bytes = new Array(end - begin); - for (let offset = begin, i = 0; offset < end; ++i, ++offset) { - bytes[i] = byteCharacters[offset].charCodeAt(0); - } - byteArrays[sliceIndex] = new Uint8Array(bytes); - } - return new Blob(byteArrays, {type: contentType}); - }; - - public base64toBlob = (base64Data, contentType): any => { - let byteCharacters = atob(base64Data); - return this.byteCharactersToBlob(byteCharacters, contentType); - }; - - public downloadFile = (blob, fileName): void=> { - let url = this.$window.URL.createObjectURL(blob); - let downloadLink = document.createElement("a"); - - downloadLink.setAttribute('href', url); - downloadLink.setAttribute('download', fileName); - document.body.appendChild(downloadLink); - downloadLink.click(); - - //time out for firefox - setTimeout(()=> { - document.body.removeChild(downloadLink); - this.$window.URL.revokeObjectURL(url); - }, 100); - } - - } -} diff --git a/catalog-ui/app/scripts/utils/functions.ts b/catalog-ui/app/scripts/utils/functions.ts deleted file mode 100644 index 32bc9243cf..0000000000 --- a/catalog-ui/app/scripts/utils/functions.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Utils.Functions { - - export class QueueUtils { - - private executionQueue : any; - - constructor(private $q:ng.IQService){ - this.executionQueue = this.getDummyPromise(); - } - - - private getDummyPromise = (): ng.IPromise<boolean> => { - let deferred : ng.IDeferred<boolean>= this.$q.defer(); - deferred.resolve(true); - return deferred.promise; - }; - - - private addMethodToQueue = (runMe:Function) : void => { - this.executionQueue = this.executionQueue.then(runMe, runMe); - }; - - addNonBlockingUIAction = (update:Function , releaseUIcallBack:Function) : void => { - releaseUIcallBack(); - this.addMethodToQueue(update); - }; - - // The Method call is responsible for releasing the UI - addBlockingUIAction = ( blockingServerRequest : Function ):void => { - this.addMethodToQueue(blockingServerRequest); - }; - - addBlockingUIActionWithReleaseCallback = ( blockingServerRequest : Function, releaseUIcallBack:Function):void=>{ - this.addMethodToQueue(blockingServerRequest); - this.addMethodToQueue(releaseUIcallBack); - }; - } -} diff --git a/catalog-ui/app/scripts/utils/menu-handler.ts b/catalog-ui/app/scripts/utils/menu-handler.ts deleted file mode 100644 index 0f2b7de3be..0000000000 --- a/catalog-ui/app/scripts/utils/menu-handler.ts +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references.ts"/> -module Sdc.Utils { - - 'use strict'; - - export class MenuItem { - text: string; - callback: (...args: Array<any>) => ng.IPromise<boolean>; - state: string; - action: string; - params: Array<any>; - isDisabled: boolean; - disabledRoles: Array<string>; - blockedForTypes:Array<string>; // This item will not be shown for specific components types. - - //TODO check if needed - confirmationModal:string; // Open confirmation modal (user should select "OK" or "Cancel"), and continue with the action. - emailModal:string; // Open email modal (user should fill email details), and continue with the action. - url:string; // Data added to menu item, in case the function need to use it, example: for function "changeLifecycleState", I need to pass also the state "CHECKOUT" that I want the state to change to. - - - constructor(text: string, callback: (...args: Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?: Array<any>, blockedForTypes?:Array<string>) { - this.text = text; - this.callback = callback; - this.state = state; - this.action = action; - this.params = params; - this.blockedForTypes = blockedForTypes; - } - } - - export class MenuItemGroup { - selectedIndex: number; - menuItems: Array<MenuItem>; - itemClick: boolean; - - constructor(selectedIndex?:number, menuItems?: Array<MenuItem>, itemClick?: boolean) { - this.selectedIndex = selectedIndex; - this.menuItems = menuItems; - this.itemClick = itemClick; - } - - public updateSelectedMenuItemText (newText: string) { - this.menuItems[this.selectedIndex].text = newText; - } - } - - - export class MenuHandler { - - static '$inject' = [ - 'sdcConfig', - 'sdcMenu', - 'ComponentFactory', - '$templateCache', - '$filter', - '$modal', - 'ModalsHandler', - '$state', - '$q' - ]; - - constructor( - private sdcConfig:Models.IAppConfigurtaion, - private sdcMenu:Models.IAppMenu, - private ComponentFactory: ComponentFactory, - private $templateCache:ng.ITemplateCacheService, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private ModalsHandler: ModalsHandler, - private $state:ng.ui.IStateService, - private $q:ng.IQService - ) { - - } - - - generateBreadcrumbsModelFromComponents = (components: Array<Sdc.Models.Components.Component>, selected:Sdc.Models.Components.Component):MenuItemGroup => { - let result = new MenuItemGroup(0, [], false); - if (components) { - - // Search the component in all components by uuid (and not uniqueid, gives access to an assets's minor versions). - let selectedItem = _.find(components, (item:Sdc.Models.Components.Component) => { - return item.uuid === selected.uuid; - }); - - // If not found search by invariantUUID - if(undefined == selectedItem){ - selectedItem = _.find(components, (item:Sdc.Models.Components.Component) => { - //invariantUUID && Certified State matches between major versions - return item.invariantUUID === selected.invariantUUID && item.lifecycleState === Utils.Constants.ComponentState.CERTIFIED; - }); - } - - // If not found search by name (name is unique). - if(undefined == selectedItem){ - selectedItem = _.find(components, (item:Sdc.Models.Components.Component) => { - return item.name === selected.name; - }); - } - - result.selectedIndex = components.indexOf(selectedItem); - components[result.selectedIndex] = selected; - let clickItemCallback = (component: Sdc.Models.Components.Component): ng.IPromise<boolean> => { - this.$state.go('workspace.general', {id: component.uniqueId, type:component.componentType.toLowerCase(), mode: Utils.Constants.WorkspaceMode.VIEW}); - return this.$q.when(true); - }; - - components.forEach((component:Sdc.Models.Components.Component) => { - let menuItem = new MenuItem( - // component.name, - component.getComponentSubType() + ': ' + this.$filter('resourceName')(component.name), - clickItemCallback, - null, - null, - [component] - ); - // menuItem.text = component.name; - result.menuItems.push(menuItem); - }); - } - return result; - }; - - } -} diff --git a/catalog-ui/app/scripts/utils/modals-handler.ts b/catalog-ui/app/scripts/utils/modals-handler.ts deleted file mode 100644 index f3e80a7a24..0000000000 --- a/catalog-ui/app/scripts/utils/modals-handler.ts +++ /dev/null @@ -1,275 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 2/11/2016. - */ -/// <reference path="../references"/> -module Sdc.Utils { - - export interface IModalsHandler { - - openViewerModal(component:Models.Components.Component):void; - openDistributionStatusModal(distribution: Models.Distribution,status:string):void; - openConfirmationModal (title:string, message:string, showComment:boolean, size?: string):ng.IPromise<any>; - openAlertModal (title:string, message:string, size?: string):ng.IPromise<any>; - openStandardModal (title:string, message:string, size?: string):ng.IPromise<any>; - openErrorModal (title:string, message:string, size?: string):ng.IPromise<any>; - openEmailModal(emailModel:ViewModels.IEmailModalModel) :ng.IPromise<any>; - openServerMessageModal(data:Sdc.ViewModels.IServerMessageModalModel): ng.IPromise<any>; - openClientMessageModal(data:Sdc.ViewModels.IClientMessageModalModel): ng.IPromise<ng.ui.bootstrap.IModalServiceInstance>; - openWizardArtifactModal(artifact: Models.ArtifactModel, component:Models.Components.Component): ng.IPromise<any>; - openWizard(componentType: Utils.Constants.ComponentType, component?:Models.Components.Component, importedFile?: any): ng.IPromise<any>; - } - - export class ModalsHandler implements IModalsHandler{ - - static '$inject' = [ - '$templateCache', - '$modal', - '$q' - ]; - - constructor(private $templateCache:ng.ITemplateCacheService, - private $modal:ng.ui.bootstrap.IModalService, - private $q:ng.IQService) { - } - - openViewerModal = (component:Models.Components.Component):void => { - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/component-viewer/component-viewer.html'), - controller: 'Sdc.ViewModels.ComponentViewerViewModel', - size: 'lg', - backdrop: 'static', - resolve: { - component: ():Models.Components.Component=> { - return component; - } - } - }; - this.$modal.open(modalOptions); - }; - - - openDistributionStatusModal = (distribution: Models.Distribution,status:string): ng.IPromise<any> => { - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html'), - controller: 'Sdc.ViewModels.DistributionStatusModalViewModel', - size: 'sdc-xl', - backdrop: 'static', - resolve: { - data: ():any => { - return { - 'distribution': distribution, - 'status': status - }; - } - } - }; - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - - - openAlertModal = (title:string, message:string, size?: string):ng.IPromise<any> => { - return this.openConfirmationModalBase(title, message, false, Utils.Constants.ModalType.ALERT, size); - }; - - openStandardModal = (title:string, message:string, size?: string):ng.IPromise<any> => { - return this.openConfirmationModalBase(title, message, false, Utils.Constants.ModalType.STANDARD, size); - }; - - openErrorModal = (title:string, message:string, size?: string):ng.IPromise<any> => { - return this.openConfirmationModalBase(title, message, false, Utils.Constants.ModalType.ERROR, size); - }; - - openConfirmationModal = (title:string, message:string, showComment:boolean, size?: string):ng.IPromise<any> => { - return this.openConfirmationModalBase(title, message, showComment, Utils.Constants.ModalType.STANDARD, size); - }; - - private openConfirmationModalBase = (title:string, message:string, showComment:boolean, type:Utils.Constants.ModalType, size?: string):ng.IPromise<any> => { - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view.html'), - controller: 'Sdc.ViewModels.ConfirmationModalViewModel', - size: size? size:'sdc-sm', - backdrop: 'static', - resolve: { - confirmationModalModel: ():Sdc.ViewModels.IConfirmationModalModel => { - let model:Sdc.ViewModels.IConfirmationModalModel = { - title: title, - message: message, - showComment: showComment, - type: type - }; - return model; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - openEmailModal = (emailModel:ViewModels.IEmailModalModel):ng.IPromise<any> => { - - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/modals/email-modal/email-modal-view.html'), - controller: 'Sdc.ViewModels.EmailModalViewModel', - size: 'sdc-sm', - backdrop: 'static', - resolve: { - emailModalModel: ():ViewModels.IEmailModalModel => { - return emailModel; - } - } - }; - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - - }; - - openServerMessageModal = (data:Sdc.ViewModels.IServerMessageModalModel):ng.IPromise<any> => { - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view.html'), - controller: 'Sdc.ViewModels.ServerMessageModalViewModel', - size: 'sdc-sm', - backdrop: 'static', - resolve: { - serverMessageModalModel: ():Sdc.ViewModels.IServerMessageModalModel => { - return data; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - openClientMessageModal = (data:Sdc.ViewModels.IClientMessageModalModel):ng.IPromise<any> => { - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view.html'), - controller: 'Sdc.ViewModels.ClientMessageModalViewModel', - size: 'sdc-sm', - backdrop: 'static', - resolve: { - clientMessageModalModel: ():Sdc.ViewModels.IClientMessageModalModel => { - return data; - } - } - }; - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance); - return deferred.promise; - }; - - openOnboadrdingModal = (okButtonText:string,currentCsarUUID?:string): ng.IPromise<any> => { - let deferred = this.$q.defer(); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view.html'), - controller: 'Sdc.ViewModels.OnboardingModalViewModel', - size: 'sdc-xl', - backdrop: 'static', - resolve: { - okButtonText:():string=>{ - return okButtonText; - }, - currentCsarUUID:():string=>{ - return currentCsarUUID||null; - } - } - }; - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - - openWizard = (componentType: Utils.Constants.ComponentType, component?:Models.Components.Component, importedFile?: any): ng.IPromise<any> => { - let deferred = this.$q.defer(); - let template = this.$templateCache.get('/app/scripts/view-models/wizard/wizard-creation-base.html'); - - let controller:string; - if(component){ - controller = 'Sdc.ViewModels.Wizard.EditWizardViewModel'; //Edit mode - } else { - if (importedFile){ - controller = 'Sdc.ViewModels.Wizard.ImportWizardViewModel'; // Import Mode - } else { - controller = 'Sdc.ViewModels.Wizard.CreateWizardViewModel'; // Create Mode - } - } - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: template, - controller: controller, - size: 'sdc-xl', - backdrop: 'static', - keyboard: false, - resolve: { - data: ():any => { - return { - 'componentType': componentType, - 'component': component, - 'importFile':importedFile - }; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - openWizardArtifactModal = (artifact: Models.ArtifactModel, component:Models.Components.Component): ng.IPromise<any> => { - let deferred = this.$q.defer(); - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'wizard/artifact-form-step/artifact-form-step-view.html'), - controller: 'Sdc.ViewModels.Wizard.ArtifactResourceFormStepViewModel', - size: 'sdc-md', - backdrop: 'static', - keyboard: false, - resolve: { - artifact: ():Models.ArtifactModel => { - return artifact; - }, - component: (): Models.Components.Component => { - return component; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - deferred.resolve(modalInstance.result); - return deferred.promise; - }; - - } -} diff --git a/catalog-ui/app/scripts/utils/prototypes.ts b/catalog-ui/app/scripts/utils/prototypes.ts deleted file mode 100644 index de961cfc4b..0000000000 --- a/catalog-ui/app/scripts/utils/prototypes.ts +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -interface String { - format(variables:Array<string>):string -} - -interface Array<T> { - clean(o: T): Array<T>; -} - - -/** - * This function will replace the %<number> with strings (from array). - * Example: "Requested '%1' resource was not found.".format(["MyResource"]); - * Note: in case the array contains empty string the function will also remove the '' or the "". - */ -if (!String.hasOwnProperty("format")) { - String.prototype["format"] = function (variables:Array<string>) : string { - - if (variables===null || variables===undefined || variables.length===0){ - variables=['']; - } - - for (let i=0;i<variables.length;i++){ - if (variables[i]==='' || variables[i]===null){ - variables[i]='--DELETE--'; - } - } - - let res = this.replace(/%(\d+)/g, function(_,m) { - return variables[--m]; - }); - - res = res.replace(" '--DELETE--' "," "); - res = res.replace(" \"--DELETE--\" "," "); - res = res.replace("'--DELETE--'",""); - res = res.replace("\"--DELETE--\"",""); - res = res.replace("--DELETE--",""); - - return res; - }; -} - -if (!String.hasOwnProperty("capitalizeFirstLetter")) { - String.prototype["capitalizeFirstLetter"] = function() { - return this.charAt(0).toUpperCase() + this.slice(1); - }; -} - -if (!String.hasOwnProperty("replaceAll")) { - String.prototype["replaceAll"] = function (find:string, replace:string) : string { - return this.replace(new RegExp(find, 'g'), replace); - }; -} - -if (!Array.hasOwnProperty("clean")) { - Array.prototype.clean = function (deleteValue) { - for (let i = 0; i < this.length; i++) { - if (this[i] == deleteValue) { - this.splice(i, 1); - i--; - } - } - return this; - }; -} - -if (!Array.prototype.map) { - Array.prototype.map = function(callback, thisArg) { - - let T, A, k; - - if (this == null) { - throw new TypeError(" this is null or not defined"); - } - - // 1. Let O be the result of calling ToObject passing the |this| value as the argument. - let O = Object(this); - - // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length". - // 3. Let len be ToUint32(lenValue). - let len = O.length >>> 0; - - // 4. If IsCallable(callback) is false, throw a TypeError exception. - // See: http://es5.github.com/#x9.11 - if (typeof callback !== "function") { - throw new TypeError(callback + " is not a function"); - } - - // 5. If thisArg was supplied, let T be thisArg; else let T be undefined. - if (thisArg) { - T = thisArg; - } - - // 6. Let A be a new array created as if by the expression new Array(len) where Array is - // the standard built-in constructor with that name and len is the value of len. - A = new Array(len); - - // 7. Let k be 0 - k = 0; - - // 8. Repeat, while k < len - while(k < len) { - - let kValue, mappedValue; - - // a. Let Pk be ToString(k). - // This is implicit for LHS operands of the in operator - // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk. - // This step can be combined with c - // c. If kPresent is true, then - if (k in O) { - - // i. Let kValue be the result of calling the Get internal method of O with argument Pk. - kValue = O[ k ]; - - // ii. Let mappedValue be the result of calling the Call internal method of callback - // with T as the this value and argument list containing kValue, k, and O. - mappedValue = callback.call(T, kValue, k, O); - - // iii. Call the DefineOwnProperty internal method of A with arguments - // Pk, Property Descriptor {Value: mappedValue, : true, Enumerable: true, Configurable: true}, - // and false. - - // In browsers that support Object.defineProperty, use the following: - // Object.defineProperty(A, Pk, { value: mappedValue, writable: true, enumerable: true, configurable: true }); - - // For best browser support, use the following: - A[ k ] = mappedValue; - } - // d. Increase k by 1. - k++; - } - - // 9. return A - return A; - }; -} diff --git a/catalog-ui/app/scripts/utils/validation-utils.ts b/catalog-ui/app/scripts/utils/validation-utils.ts deleted file mode 100644 index 7618e7d0e3..0000000000 --- a/catalog-ui/app/scripts/utils/validation-utils.ts +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> - -module Sdc.Utils { - class basePattern{ - pattern:RegExp; - base:number; - constructor(pattern:RegExp, base:number){ - this.pattern = pattern; - this.base = base; - } - } - - export interface IMapRegex{ - integer: RegExp; - boolean: RegExp; - float: RegExp; - string: RegExp; - } - - export class ValidationUtils { - - static '$inject' = [ - 'IntegerNoLeadingZeroValidationPattern', - 'FloatValidationPattern', - 'CommentValidationPattern', - 'BooleanValidationPattern', - 'NumberValidationPattern', - 'LabelValidationPattern', - ]; - private trueRegex : string = '[t][r][u][e]|[t]|[o][n]|[y]|[y][e][s]|[1]'; - private falseRegex : string = '[f][a][l][s][e]|[f]|[o][f][f]|[n]|[n][o]|[0]'; - private heatBooleanValidationPattern : RegExp = new RegExp( '^('+this.trueRegex+'|'+this.falseRegex+')$'); - - - constructor(private IntegerNoLeadingZeroValidationPattern:RegExp, - private FloatValidationPattern:RegExp, - private CommentValidationPattern:RegExp, - private BooleanValidationPattern:RegExp, - private NumberValidationPattern:RegExp, - private LabelValidationPattern:RegExp) {} - - public stripAndSanitize(text:string):string{ - if(!text){ - return null; - } - return text.replace(/\s+/g, ' ').replace(/%[A-Fa-f0-9]{2}/g, '').trim(); - } - - public getValidationPattern = (validationType:string , parameterType?:string) : RegExp => { - switch (validationType){ - case 'integer': - return this.IntegerNoLeadingZeroValidationPattern; - case 'float': - return this.FloatValidationPattern; - case 'number': - return this.NumberValidationPattern; - case 'string': - return this.CommentValidationPattern; - case 'boolean': - { - //Bug Fix DE197437 [Patch]Mismatch between BE to FE regarding supported characters in Boolean filed - if( parameterType && parameterType === 'heat'){ - return this.heatBooleanValidationPattern; - } - else{ - return this.BooleanValidationPattern; - } - - } - - case 'label': - return this.LabelValidationPattern; - case 'category': - return this.LabelValidationPattern; - default : - return null; - } - }; - - public getPropertyListPatterns():IMapRegex { - return { - integer: /^(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)(,?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+))*$/, - string: /^"[\u0000-\u0021\u0023-\u00BF]+"(\s*,?\s*"[\u0000-\u0021\u0023-\u00BF]+")*$/, - boolean: /^([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])(,?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]))*$/, - float: /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(,?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?)*$/ - }; - } - public getPropertyMapPatterns():IMapRegex { - return { - integer: /^"\w+"\s*:\s?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)+(\s*,?\s*"\w+"\s?:\s?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)+)*$/, - string: /^"\w+"\s?:\s?"[\u0000-\u0021\u0023-\u00BF]*"(\s*,?\s*"\w+"\s?:\s?"[\u0000-\u0021\u0023-\u00BF]*")*$/, - boolean: /^"\w+"\s?:\s?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])(\s*,?\s*"\w+"\s?:\s?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]))*$/, - float: /^"\w+"\s?:\s?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?(\s*,?\s*"\w+"\s?:\s?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?)*$/ - }; - } - public validateUniqueKeys(viewValue:string):boolean { - if(!viewValue) { - return true; //allow empty value - } - - let json:string = "{" + viewValue.replace(/\s\s+/g, ' ') + "}"; - try{ - let obj:any = JSON.parse(json); - /* - //Method #1 : check json string length before & after parsing - let newJson:string = JSON.stringify(obj); - if (newJson.length < json.length) { - return false; - }*/ - - //Method #2 : check how many times we can find "KEY": in json string - let result:boolean = true; - Object.keys(obj).forEach((key:string) => { - result = result && json.split('"' + key + '":').length === 2; - }); - return result; - - }catch(e){ - return false; //not a valid JSON - } - - //return true; - } - - public validateJson = (json:string):boolean => { - try{ - JSON.parse(json); - return true; - }catch(err){ - console.log('invalid json'); - return false; - } - }; - - public validateIntRange = (value:string):boolean => { - - let base8 = new basePattern(/^([-+]?0o[0-7]+)$/, 8); - let base10 = new basePattern(/^(0|[-+]?[1-9][0-9]*)$/, 10); - let base16 = new basePattern(/^([-+]?0x[0-9a-fA-F]+)$/, 16); - - let min:number = -0x80000000; - let max:number = 0x7fffffff; - let intPatterns:Array<basePattern> = [base8, base10, base16]; - let matchedBase = _.find(intPatterns, (item)=> { - return item.pattern.test(value); - }); - - let parsed:number = parseInt(value.replace('o',''), matchedBase.base); - if(parsed){ - return min <= parsed && max >= parsed; - } - } - } -} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts b/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts deleted file mode 100644 index 93c1dac174..0000000000 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IAddCategoryModalViewModelScope extends ng.IScope { - category:Sdc.Services.ICategoryResource; - modelType:string; - footerButtons: Array<any>; - forms:any; - - save():void; - close():void; - } - - export class AddCategoryModalViewModel { - - static '$inject' = [ - '$scope', - 'Sdc.Services.CategoryResourceService', - '$modalInstance', - 'parentCategory', - 'type' - ]; - - constructor( - private $scope:IAddCategoryModalViewModelScope, - private categoryResourceService:Sdc.Services.ICategoryResourceClass, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private parentCategory:Sdc.Services.ICategoryResource, - private type:string - ){ - this.initScope(); - } - - private initScope = ():void => { - this.$scope.forms = {}; - this.$scope.modelType = this.parentCategory ? 'sub category' : 'category'; - this.$scope.category = new this.categoryResourceService(); - - this.$scope.close = ():void => { - this.$modalInstance.dismiss(); - }; - - this.$scope.save = ():void => { - - let onOk = (newCategory :Sdc.Services.ICategoryResource):void => { - this.$modalInstance.close(newCategory); - }; - - let onCancel = ():void => { - //error - }; - - if(!this.parentCategory) { - this.$scope.category.$save({types: this.type+"s"}, onOk, onCancel); - }else{ - this.$scope.category.$saveSubCategory({types: this.type+"s", categoryId: this.parentCategory.uniqueId}, onOk, onCancel); - } - - }; - - this.$scope.footerButtons = [ - {'name': 'OK', 'css': 'blue', 'callback': this.$scope.save, 'disabled': true}, - {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} - ]; - - this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - }); - - } - - - } -} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard-view-model.ts b/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard-view-model.ts deleted file mode 100644 index d7cbbcc68d..0000000000 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard-view-model.ts +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - - 'use strict'; - - interface IAdminDashboardViewModelScope extends ng.IScope { - version:string; - sdcConfig:Models.IAppConfigurtaion; - isLoading: boolean; - currentTab: string; - templateUrl:string; - monitorUrl:string; - moveToTab(tab:string):void; - isSelected(tab:string):boolean; - } - - - export class AdminDashboardViewModel { - static '$inject' = [ - '$scope', - 'Sdc.Services.CacheService', - 'sdcConfig' - ]; - - constructor(private $scope:IAdminDashboardViewModelScope, - private cacheService:Services.CacheService, - private sdcConfig:Models.IAppConfigurtaion) { - - this.initScope(); - } - - - private initScope = ():void => { - - this.$scope.version = this.cacheService.get('version'); - this.$scope.sdcConfig = this.sdcConfig; - this.$scope.monitorUrl = this.$scope.sdcConfig.api.kibana; - this.$scope.isSelected=(tab:string):boolean => { - return tab===this.$scope.currentTab; - } - - this.$scope.moveToTab=(tab:string):void => { - if (tab===this.$scope.currentTab){ - return; - } - else if(tab === 'USER_MANAGEMENT'){ - this.$scope.templateUrl = '/app/scripts/view-models/admin-dashboard/user-management/user-management-view.html'; - } - else if(tab ==='CATEGORY_MANAGEMENT'){ - this.$scope.templateUrl = '/app/scripts/view-models/admin-dashboard/category-management/category-management-view.html'; - } - /* else if(tab ==='ECOMP'){ - this.$scope.templateUrl = '/app/scripts/view-models/admin-dashboard/ecomp/ecomp-view.html'; - }*/ - this.$scope.currentTab = tab; - }; - - this.$scope.moveToTab('USER_MANAGEMENT'); - - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management-view-model.ts b/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management-view-model.ts deleted file mode 100644 index a3ad7a2714..0000000000 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management-view-model.ts +++ /dev/null @@ -1,197 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface ICategoryManagementViewModelScope extends ng.IScope { - SERVICE:string; - RESOURCE:string; - categoriesToShow: Array<Sdc.Services.ICategoryResource>; - serviceCategories: Array<Sdc.Services.ICategoryResource>; - resourceCategories: Array<Sdc.Services.ICategoryResource>; - selectedCategory: Sdc.Services.ICategoryResource; - selectedSubCategory: Sdc.Services.ICategoryResource; - modalInstance:ng.ui.bootstrap.IModalServiceInstance; - isLoading:boolean; - type:string; - namePattern:RegExp; - - selectCategory(category:Sdc.Services.ICategoryResource) :void; - selectSubCategory(subcategory:Sdc.Services.ICategoryResource) :void; - selectType(type:string) :void; - deleteCategory(category:Sdc.Services.ICategoryResource, subCategory:Sdc.Services.ICategoryResource) :void; - createCategoryModal(parentCategory:Sdc.Services.ICategoryResource) :void; - } - - export class CategoryManagementViewModel { - static '$inject' = [ - '$scope', - 'sdcConfig', - 'Sdc.Services.CacheService', - '$templateCache', - '$modal', - '$filter', - 'ValidationUtils', - 'ModalsHandler' - ]; - - constructor(private $scope:ICategoryManagementViewModelScope, - private sdcConfig:Models.IAppConfigurtaion, - private cacheService:Services.CacheService, - private $templateCache:ng.ITemplateCacheService, - private $modal:ng.ui.bootstrap.IModalService, - private $filter:ng.IFilterService, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private ModalsHandler: Utils.ModalsHandler - ) { - - this.initScope(); - this.$scope.selectType(Sdc.Utils.Constants.ComponentType.SERVICE.toLocaleLowerCase()); - - } - - private initScope = ():void => { - let scope:ICategoryManagementViewModelScope = this.$scope; - scope.SERVICE = Sdc.Utils.Constants.ComponentType.SERVICE.toLocaleLowerCase(); - scope.RESOURCE = Sdc.Utils.Constants.ComponentType.RESOURCE.toLocaleLowerCase(); - - scope.namePattern = this.ValidationUtils.getValidationPattern('cssClasses'); - - scope.selectCategory = (category :Sdc.Services.ICategoryResource) => { - if(scope.selectedCategory !== category) { - scope.selectedSubCategory = null; - } - scope.selectedCategory = category; - }; - scope.selectSubCategory = (subcategory :Sdc.Services.ICategoryResource) => { - scope.selectedSubCategory = subcategory; - }; - scope.selectType = (type:string):void => { - if (scope.type !== type) { - scope.selectedCategory = null; - scope.selectedSubCategory = null; - } - - scope.type = type; - scope.categoriesToShow = scope[type + 'Categories']; - }; - - scope.createCategoryModal = (parentCategory:Sdc.Services.ICategoryResource):void => { - //can't create a sub category for service - if(parentCategory && scope.type === Sdc.Utils.Constants.ComponentType.SERVICE.toLowerCase()) { - return; - } - - let type:string = scope.type; - - let onOk = (newCategory :Sdc.Services.ICategoryResource):void => { - if(!parentCategory) { - scope[type + 'Categories'].push(newCategory); - }else{ - if(!parentCategory.subcategories) { - parentCategory.subcategories = []; - } - parentCategory.subcategories.push(newCategory); - } - }; - - let onCancel = ():void => { - - }; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html'), - controller: 'Sdc.ViewModels.AddCategoryModalViewModel', - size: 'sdc-xsm', - backdrop: 'static', - scope: scope, - resolve: { - parentCategory: function () { - return parentCategory; - }, - type: function () { - return type; - } - } - }; - - scope.modalInstance = this.$modal.open(modalOptions); - scope.modalInstance.result.then(onOk, onCancel); - - }; - - scope.deleteCategory = (category: Sdc.Services.ICategoryResource, subCategory: Sdc.Services.ICategoryResource): void => { - - let onOk = ():void => { - - scope.isLoading = true; - let type:string = scope.type; - - let onError = (response):void => { - scope.isLoading = false; - console.info('onFaild', response); - }; - - let onSuccess = (response: any) :void => { - let arr:Array<Sdc.Services.ICategoryResource>; - - if(!subCategory) { - arr = this.$scope[type + 'Categories']; - arr.splice(arr.indexOf(category), 1); - if(category === scope.selectedCategory) { - scope.selectedCategory = null; - scope.selectedSubCategory = null; - } - } else { - arr = category.subcategories; - arr.splice(arr.indexOf(subCategory), 1); - } - - scope.isLoading = false; - }; - - if(!subCategory) { - category.$delete({ - types: type+"s", - categoryId: category.uniqueId - } - , onSuccess, onError); - } else { - category.$deleteSubCategory({ - types: type+"s", - categoryId: category.uniqueId, - subCategoryId: subCategory.uniqueId, - } - , onSuccess, onError); - } - }; - let modelType:string = subCategory ? 'sub category' : 'cssClasses'; - let title:string = this.$filter('translate')("DELETE_CATEGORY_MODAL_HEADER", "{'modelType': '" + modelType +"' }"); - let message:string = this.$filter('translate')("DELETE_CATEGORY_MODAL_CATEGORY_NAME", "{'modelType': '" + modelType +"' }"); - - this.ModalsHandler.openConfirmationModal(title, message, false, 'sdc-xsm').then(onOk); - }; - - this.$scope.serviceCategories = this.cacheService.get('serviceCategories'); - this.$scope.resourceCategories = this.cacheService.get('resourceCategories'); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management-view-model.ts b/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management-view-model.ts deleted file mode 100644 index 3921d0cf8f..0000000000 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management-view-model.ts +++ /dev/null @@ -1,220 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - - import IUserProperties = Sdc.Models.IUserProperties; - 'use strict'; - - interface IUserManagementViewModelScope extends ng.IScope { - sdcConfig:Models.IAppConfigurtaion; - usersList: Array<Models.IUserProperties>; - isLoading: boolean; - isNewUser: boolean; - sortBy:string; - reverse:boolean; - tableHeadersList:any; - roles:Array<string>; - newUser: Models.IUser; - currentUser: Sdc.Services.IUserResource; - userIdValidationPattern: RegExp; - editForm:ng.IFormController; - getAllUsers():void; - editUserRole(user:IUserProperties); - sort(sortBy:string): void; - createUser(): void; - deleteUser(userId:string) : void; - onEditUserPressed(user:IUserProperties): void; - saveUserChanges(user:IUserProperties) :void; - getTitle(role:string): string; - clearForm():void; - - } - - - export class UserManagementViewModel { - static '$inject' = [ - '$scope', - 'sdcConfig', - 'Sdc.Services.UserResourceService', - '$templateCache', - '$modal', - 'UserIdValidationPattern', - '$filter', - 'ModalsHandler' - ]; - - constructor(private $scope:IUserManagementViewModelScope, - private sdcConfig:Models.IAppConfigurtaion, - private userResourceService:Sdc.Services.IUserResourceClass, - private $templateCache:ng.ITemplateCacheService, - private $modal:ng.ui.bootstrap.IModalService, - private UserIdValidationPattern:RegExp, - private $filter:ng.IFilterService, - private ModalsHandler: Utils.ModalsHandler - ) { - - this.initScope(); - - } - - - - private getAllUsers = ():void => { - this.$scope.isLoading = true; - - let onError = (response) => { - this.$scope.isLoading = false; - console.info('onFaild', response); - }; - let onSuccess = (response: Array<Models.IUserProperties>) => { - this.$scope.usersList = response; - _.forEach(this.$scope.usersList,(user:any,i:number)=>{ - user.index = i; - }); - this.$scope.isLoading = false; - }; - this.userResourceService.getAllUsers(onSuccess, onError); - }; - - private updateUserFilterTerm = (user: IUserProperties): void =>{ - user.filterTerm = user.firstName + ' ' + user.lastName + ' ' + user.userId + ' ' + user.email + ' ' + user.role + ' ' + this.$filter('date')(user.lastLoginTime, "MM/dd/yyyy"); - }; - - private initScope = ():void => { - let self=this; - - this.$scope.tableHeadersList = [ - {title: "First Name", property: 'firstName'}, - {title: "Last Name", property: 'lastName'}, - {title: this.$filter('translate')("USER_MANAGEMENT_TABLE_HEADER_USER_ID"), property: 'userId'}, - {title: "Email", property: 'email'}, - {title: "Role", property: 'role'}, - {title: "Last Active", property: 'lastLoginTime'} - ]; - this.$scope.userIdValidationPattern = this.UserIdValidationPattern; - this.$scope.sortBy = 'lastLoginTime'; - this.$scope.reverse = false; - this.$scope.roles = this.sdcConfig.roles; - this.$scope.isNewUser = false; - this.$scope.currentUser = this.userResourceService.getLoggedinUser(); - this.getAllUsers(); - - let resource : Services.IUserResource = <Services.IUserResource>{}; - this.$scope.newUser = new Sdc.Models.User(resource); - - this.$scope.sort = (sortBy:string):void => {//default sort by descending last update. default for alphabetical = ascending - this.$scope.isNewUser = false; - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? ( !this.$scope.reverse) : this.$scope.reverse = false; - this.$scope.sortBy = sortBy; - }; - - this.$scope.createUser = () : void => { - - let onError = (response) => { - this.$scope.isLoading = false; - console.info('onFaild', response); - }; - - let onSuccess = (response: Models.IUserProperties) => { - this.$scope.newUser.resource['index'] = this.$scope.usersList.length; - this.$scope.newUser.resource.lastLoginTime = "0"; - this.$scope.newUser.resource.status = response.status; - this.updateUserFilterTerm(this.$scope.newUser.resource); - this.$scope.usersList.unshift(this.$scope.newUser.resource); - this.$scope.isNewUser = true; - this.$scope.sortBy = 'index'; - this.$scope.reverse = true; - this.$scope.isLoading = false; - this.$scope.newUser = new Sdc.Models.User(null); - this.$scope.editForm.$setPristine(); - let _self = this; - setTimeout(function () { - _self.$scope.isNewUser = false; - }, 7000); - }; - this.userResourceService.createUser({ userId: this.$scope.newUser.resource.userId, role: this.$scope.newUser.resource.role}, onSuccess, onError); - }; - - - this.$scope.onEditUserPressed = (user:IUserProperties): void => { - user.isInEditMode = true; - user.tempRole = user.role; - }; - - this.$scope.editUserRole = (user:IUserProperties): void => { - let roleBeforeUpdate: string = user.role; - user.role= user.tempRole; - - let onError = (response) => { - this.$scope.isLoading = false; - user.role = roleBeforeUpdate; - console.info('onFaild', response); - }; - let onSuccess = (response: any) => { - this.$scope.isLoading = false; - user.tempRole = user.role; - this.updateUserFilterTerm(user); - }; - - this.userResourceService.editUserRole({ id: user.userId, role: user.role}, onSuccess, onError); - }; - - this.$scope.saveUserChanges = (user:IUserProperties): void => { - if(user.tempRole != user.role){ - this.$scope.editUserRole(user) - } - user.isInEditMode = false; - }; - - this.$scope.deleteUser = (userId:string): void => { - - let onOk = ():void => { - this.$scope.isLoading = true; - - let onError = (response):void => { - this.$scope.isLoading = false; - console.info('onFaild', response); - }; - - let onSuccess = (response: any) :void => { - _.remove(this.$scope.usersList, {userId: userId }); - this.$scope.isLoading = false; - }; - this.userResourceService.deleteUser({ id: userId}, onSuccess, onError); - }; - - let title:string = this.$filter('translate')("USER_MANAGEMENT_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("USER_MANAGEMENT_VIEW_DELETE_MODAL_TEXT"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - - this.$scope.getTitle = (role:string):string =>{ - return role.toLowerCase().replace('governor','governance_Rep').replace('_',' '); - }; - - this.$scope.clearForm =():void =>{ - if(!this.$scope.editForm['contactId'].$viewValue && !this.$scope.editForm['role'].$viewValue){ - this.$scope.editForm.$setPristine(); - } - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/catalog/catalog-view-model.ts b/catalog-ui/app/scripts/view-models/catalog/catalog-view-model.ts deleted file mode 100644 index bf37e92e56..0000000000 --- a/catalog-ui/app/scripts/view-models/catalog/catalog-view-model.ts +++ /dev/null @@ -1,312 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - - 'use strict'; - - interface Checkboxes { - componentTypes:Array<string>; - resourceSubTypes:Array<string>; - } - - interface CheckboxesFilter { - // Types - selectedComponentTypes:Array<string>; - selectedResourceSubTypes:Array<string>; - // Categories - selectedCategoriesModel:Array<string>; - // Statuses - selectedStatuses:Array<string>; - } - - interface Gui { - isLoading: boolean; - onResourceSubTypesClick:Function; - onComponentTypeClick:Function; - onCategoryClick:Function; - onSubcategoryClick:Function; - onGroupClick:Function; - } - - export interface ICatalogViewModelScope extends ng.IScope { - checkboxes:Checkboxes; - checkboxesFilter:CheckboxesFilter; - gui:Gui; - - categories: Array<Models.IMainCategory>; - confStatus: Models.IConfigStatuses; - sdcMenu:Models.IAppMenu; - catalogFilterdItems: Array<Models.Components.Component>; - expandedSection: Array<string>; - actionStrategy: any; - user: Models.IUserProperties; - catalogMenuItem: any; - version:string; - sortBy:string; - reverse:boolean; - - //this is for UI paging - numberOfItemToDisplay:number; - isAllItemDisplay: boolean; - - openViewerModal(isResource: boolean, uniqueId: string): void; - changeLifecycleState(entity:any,state:string): void; - sectionClick (section:string):void; - order(sortBy:string): void; - getNumOfElements(num:number): string; - goToComponent(component:Models.Components.Component):void; - raiseNumberOfElementToDisplay():void; - } - - export class CatalogViewModel { - static '$inject' = [ - '$scope', - '$filter', - 'Sdc.Services.EntityService', - 'sdcConfig', - 'sdcMenu', - '$state', - '$q', - 'Sdc.Services.UserResourceService', - '$modal', - '$templateCache', - 'Sdc.Services.CacheService', - 'ComponentFactory', - 'ChangeLifecycleStateHandler', - 'ModalsHandler', - 'MenuHandler' - ]; - - constructor(private $scope:ICatalogViewModelScope, - private $filter:ng.IFilterService, - private EntityService:Services.EntityService, - private sdcConfig:Models.IAppConfigurtaion, - private sdcMenu:Models.IAppMenu, - private $state:any, - private $q:any, - private userResourceService:Sdc.Services.IUserResourceClass, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private cacheService:Services.CacheService, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private ChangeLifecycleStateHandler: Sdc.Utils.ChangeLifecycleStateHandler, - private OpenViewModalHandler: Utils.ModalsHandler, - private MenuHandler: Utils.MenuHandler - ) { - - this.initScopeMembers(); - this.initCatalogData(); // Async task to get catalog from server. - this.initScopeMethods(); - } - - private initCatalogData = ():void => { - let onSuccess = (followedResponse:Array<Models.Components.Component>):void => { - this.$scope.catalogFilterdItems = followedResponse; - this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; - this.$scope.categories = this.cacheService.get('serviceCategories').concat(this.cacheService.get('resourceCategories')).concat(this.cacheService.get('productCategories')); - this.$scope.gui.isLoading = false; - }; - - let onError = ():void => { - console.info('Failed to load catalog CatalogViewModel::initCatalog'); - this.$scope.gui.isLoading = false; - }; - this.EntityService.getCatalog().then(onSuccess, onError); - }; - - - - private initScopeMembers = ():void => { - // Gui init - this.$scope.gui = <Gui>{}; - this.$scope.gui.isLoading = true; - this.$scope.numberOfItemToDisplay = 0; - //this.$scope.categories = this.cacheService.get('categoriesMap'); - this.$scope.sdcMenu = this.sdcMenu; - this.$scope.confStatus = this.sdcMenu.statuses; - this.$scope.expandedSection = ["type", "cssClasses", "product-category", "status"]; - this.$scope.user = this.userResourceService.getLoggedinUser(); - this.$scope.catalogMenuItem = this.sdcMenu.catalogMenuItem; - this.$scope.version = this.cacheService.get('version'); - this.$scope.sortBy = 'lastUpdateDate'; - this.$scope.reverse = true; - - - // Checklist init - this.$scope.checkboxes = <Checkboxes>{}; - this.$scope.checkboxes.componentTypes = ['Resource', 'Service', 'Product']; - this.$scope.checkboxes.resourceSubTypes = ['VF', 'VFC', 'CP', 'VL']; - - // Checkboxes filter init - this.$scope.checkboxesFilter = <CheckboxesFilter>{}; - this.$scope.checkboxesFilter.selectedComponentTypes = []; - this.$scope.checkboxesFilter.selectedResourceSubTypes = []; - this.$scope.checkboxesFilter.selectedCategoriesModel = []; - this.$scope.checkboxesFilter.selectedStatuses = []; - - // this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; - }; - - private initScopeMethods = ():void => { - this.$scope.sectionClick = (section:string):void => { - let index:number = this.$scope.expandedSection.indexOf(section); - if (index!==-1) { - this.$scope.expandedSection.splice(index,1); - } else { - this.$scope.expandedSection.push(section); - } - }; - - - this.$scope.order = (sortBy:string):void => {//default sort by descending last update. default for alphabetical = ascending - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : (sortBy === 'lastUpdateDate') ? true: false; - this.$scope.sortBy = sortBy; - }; - - - this.$scope.goToComponent = (component:Models.Components.Component):void => { - this.$scope.gui.isLoading = true; - this.$state.go('workspace.general', {id: component.uniqueId, type:component.componentType.toLowerCase()}); - }; - - - // Will print the number of elements found in catalog - this.$scope.getNumOfElements = (num:number) : string => { - if (!num || num===0){ - return "No Elements found"; - } else if (num===1){ - return "1 Element found"; - }else { - return num + " Elements found"; - } - }; - - /** - * Select | unselect sub resource when resource is clicked | unclicked. - * @param type - */ - this.$scope.gui.onComponentTypeClick = (type:string): void => { - if (type==='Resource'){ - if (this.$scope.checkboxesFilter.selectedComponentTypes.indexOf('Resource')===-1){ - // If the resource was not selected, unselect all childs. - this.$scope.checkboxesFilter.selectedResourceSubTypes = []; - } else { - // If the resource was selected, select all childs - this.$scope.checkboxesFilter.selectedResourceSubTypes = angular.copy(this.$scope.checkboxes.resourceSubTypes); - } - } - }; - - /** - * Selecting | unselect resources when sub resource is clicked | unclicked. - */ - this.$scope.gui.onResourceSubTypesClick = ():void => { - if (this.$scope.checkboxesFilter.selectedResourceSubTypes && this.$scope.checkboxesFilter.selectedResourceSubTypes.length===this.$scope.checkboxes.resourceSubTypes.length){ - this.$scope.checkboxesFilter.selectedComponentTypes.push('Resource'); - } else { - this.$scope.checkboxesFilter.selectedComponentTypes = _.without(this.$scope.checkboxesFilter.selectedComponentTypes,'Resource'); - } - }; - - this.$scope.gui.onCategoryClick = (category:Models.IMainCategory): void => { - // Select | Unselect all childs - if (this.isCategorySelected(category.uniqueId)){ - this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(category.subcategories, (item) => { return item.uniqueId; }))); - if (category.subcategories) { - category.subcategories.forEach((sub:Models.ISubCategory)=> { // Loop on all selected subcategories and mark the childrens - this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(sub.groupings, (item) => { - return item.uniqueId; - }))); - }); - } - } else { - this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(category.subcategories, (item) => { return item.uniqueId; })); - if (category.subcategories) { - category.subcategories.forEach((sub:Models.ISubCategory)=> { // Loop on all selected subcategories and un mark the childrens - this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(sub.groupings, (item) => { - return item.uniqueId; - })); - }); - } - } - }; - - this.$scope.gui.onSubcategoryClick = (category:Models.IMainCategory, subCategory:Models.ISubCategory) : void => { - // Select | Unselect all childs - if (this.isCategorySelected(subCategory.uniqueId)){ - this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(subCategory.groupings, (item) => { return item.uniqueId; }))); - } else { - this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(subCategory.groupings, (item) => { return item.uniqueId; })); - } - - // Mark | Un mark the parent when all childs selected. - if (this.areAllCategoryChildsSelected(category)){ - // Add the category to checkboxesFilter.selectedCategoriesModel - this.$scope.checkboxesFilter.selectedCategoriesModel.push(category.uniqueId); - } else { - this.$scope.checkboxesFilter.selectedCategoriesModel = _.without(this.$scope.checkboxesFilter.selectedCategoriesModel, category.uniqueId); - } - - }; - - this.$scope.raiseNumberOfElementToDisplay = () : void => { - this.$scope.numberOfItemToDisplay = this.$scope.numberOfItemToDisplay +35; - if(this.$scope.catalogFilterdItems) { - this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; - } - }; - - this.$scope.gui.onGroupClick = (subCategory:Models.ISubCategory) : void => { - // Mark | Un mark the parent when all childs selected. - if (this.areAllSubCategoryChildsSelected(subCategory)){ - // Add the category to checkboxesFilter.selectedCategoriesModel - this.$scope.checkboxesFilter.selectedCategoriesModel.push(subCategory.uniqueId); - } else { - this.$scope.checkboxesFilter.selectedCategoriesModel = _.without(this.$scope.checkboxesFilter.selectedCategoriesModel, subCategory.uniqueId); - } - }; - - - }; - - private areAllCategoryChildsSelected = (category:Models.IMainCategory):boolean => { - if (!category.subcategories){return false;} - let allIds = _.map(category.subcategories, (sub:Models.ISubCategory)=>{return sub.uniqueId;}); - let total = _.intersection(this.$scope.checkboxesFilter.selectedCategoriesModel, allIds); - return total.length === category.subcategories.length?true:false; - }; - - private areAllSubCategoryChildsSelected = (subCategory:Models.ISubCategory):boolean => { - if (!subCategory.groupings){return false;} - let allIds = _.map(subCategory.groupings, (group:Models.IGroup)=>{return group.uniqueId;}); - let total = _.intersection(this.$scope.checkboxesFilter.selectedCategoriesModel, allIds); - return total.length === subCategory.groupings.length?true:false; - }; - - private isCategorySelected = (uniqueId:string):boolean => { - if (this.$scope.checkboxesFilter.selectedCategoriesModel.indexOf(uniqueId)!==-1){ - return true; - } - return false; - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/catalog/catalog-view-tests.ts b/catalog-ui/app/scripts/view-models/catalog/catalog-view-tests.ts deleted file mode 100644 index 3e21835233..0000000000 --- a/catalog-ui/app/scripts/view-models/catalog/catalog-view-tests.ts +++ /dev/null @@ -1,309 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -describe("test catalog-view", () => { - - let $controllerMock:ng.IControllerService; - let $qMock:ng.IQService; - let $httpBackendMock:ng.IHttpBackendService; - let $scopeMock:Sdc.ViewModels.ICatalogViewModelScope; - let $stateMock:ng.ui.IStateService; - let $stateParams:any; - let entityServiceMock; - let cacheServiceMock; - - beforeEach(angular.mock.module('sdcApp')); - - let getAllEntitiesResponseMock = [ - { - "uniqueId": "855acdc7-7976-4913-9fa6-25220bd5a069", - "uuid": "8bc54f94-082c-42fa-9049-84767df3ff05", - "contactId": "qa1234", - "category": "VoIP Call Control", - "creationDate": 1447234712398, - "description": "ddddd", - "highestVersion": true, - "icon": "mobility", - "lastUpdateDate": 1447234712398, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "distributionStatus": "DISTRIBUTION_NOT_APPROVED", - "projectCode": "233233", - "name": "mas mas mas mas mas mas mas mas mas mas mas mas ma", - "version": "0.1", - "type": 0, - "tags": [ - "mas mas mas mas mas mas mas mas mas mas mas mas ma" - ], - "systemName": "MasMasMasMasMasMasMasMasMasMasMasMasMa", - "vnf": true, - "$$hashKey": "object:30" - }, - { - "uniqueId": "4bb577ce-cb2c-4cb7-bb39-58644b5e73cb", - "uuid": "e27f4723-c9ec-4160-89da-dbf84d19a7e3", - "contactId": "qa1111", - "category": "Mobility", - "creationDate": 1447238503181, - "description": "aqa", - "highestVersion": true, - "icon": "call_controll", - "lastUpdateDate": 1447248991388, - "lastUpdaterUserId": "jm0007", - "lastUpdaterFullName": "Joni Mitchell", - "lifecycleState": "CERTIFIED", - "distributionStatus": "DISTRIBUTION_REJECTED", - "projectCode": "111111", - "name": "martin18", - "version": "1.0", - "type": 0, - "tags": [ - "martin18" - ], - "systemName": "Martin18", - "vnf": true - }, - { - "uniqueId": "f192f4a6-7fbf-42e4-a546-37509df28dc1", - "uuid": "0b77dc0d-222e-4d10-85cd-e420c9481417", - "contactId": "fd1212", - "category": "Application Layer 4+/Web Server", - "creationDate": 1447233679778, - "description": "geefw", - "highestVersion": true, - "icon": "database", - "lastUpdateDate": 1447233681582, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "ger", - "version": "0.1", - "type": 1, - "tags": [ - "ger" - ], - "vendorName": "fewwfe", - "vendorRelease": "fewew", - "systemName": "Ger", - "$$hashKey": "object:31" - }, - { - "uniqueId": "78392d08-1859-47c2-b1f2-1a35b7f8c30e", - "uuid": "8cdd63b2-6a62-4376-9012-624f424f71d4", - "contactId": "qw1234", - "category": "Application Layer 4+/Application Servers", - "creationDate": 1447234046114, - "description": "test", - "highestVersion": true, - "icon": "router", - "lastUpdateDate": 1447234050545, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "test", - "version": "0.1", - "type": 1, - "tags": [ - "test" - ], - "vendorName": "test", - "vendorRelease": "test", - "systemName": "Test", - "$$hashKey": "object:32" - }, - { - "uniqueId": "939e153d-2236-410f-b4a9-3b4bf8c79c9e", - "uuid": "84862547-4f56-4058-b78e-40df5f374d7e", - "contactId": "qw1234", - "category": "Application Layer 4+/Application Servers", - "creationDate": 1447235242560, - "description": "jlk", - "highestVersion": true, - "icon": "database", - "lastUpdateDate": 1447235328062, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKIN", - "name": "new", - "version": "0.1", - "type": 1, - "tags": [ - "new" - ], - "vendorName": "e", - "vendorRelease": "e", - "systemName": "New", - "$$hashKey": "object:33" - }, - { - "uniqueId": "ece818e0-fd59-477a-baf6-e27461a7ce23", - "uuid": "8db823c2-6a9c-4636-8676-f5e713270dd7", - "contactId": "uf2345", - "category": "Network Layer 2-3/Router", - "creationDate": 1447235352429, - "description": "u", - "highestVersion": true, - "icon": "network", - "lastUpdateDate": 1447235370064, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "u", - "version": "0.1", - "type": 1, - "tags": [ - "u" - ], - "vendorName": "u", - "vendorRelease": "u", - "systemName": "U", - "$$hashKey": "object:34" - } - ]; - - let resourceCategoriesResponseMock = [{"name":"Network L2-3","normalizedName":"network l2-3","uniqueId":"resourceNewCategory.network l2-3","subcategories":[{"name":"Gateway","normalizedName":"gateway","uniqueId":"resourceNewCategory.network l2-3.gateway","icons":["gateway"]},{"name":"Infrastructure","normalizedName":"infrastructure","uniqueId":"resourceNewCategory.network l2-3.infrastructure","icons":["ucpe"]},{"name":"WAN Connectors","normalizedName":"wan connectors","uniqueId":"resourceNewCategory.network l2-3.wan connectors","icons":["network","connector","port"]},{"name":"LAN Connectors","normalizedName":"lan connectors","uniqueId":"resourceNewCategory.network l2-3.lan connectors","icons":["network","connector","port"]},{"name":"Router","normalizedName":"router","uniqueId":"resourceNewCategory.network l2-3.router","icons":["router","vRouter"]}]},{"name":"Network L4+","normalizedName":"network l4+","uniqueId":"resourceNewCategory.network l4+","subcategories":[{"name":"Common Network Resources","normalizedName":"common network resources","uniqueId":"resourceNewCategory.network l4+.common network resources","icons":["network"]}]},{"name":"Application L4+","normalizedName":"application l4+","uniqueId":"resourceNewCategory.application l4+","subcategories":[{"name":"Load Balancer","normalizedName":"load balancer","uniqueId":"resourceNewCategory.application l4+.load balancer","icons":["loadBalancer"]},{"name":"Media Servers","normalizedName":"media servers","uniqueId":"resourceNewCategory.application l4+.media servers","icons":["applicationServer"]},{"name":"Application Server","normalizedName":"application server","uniqueId":"resourceNewCategory.application l4+.application server","icons":["applicationServer"]},{"name":"Database","normalizedName":"database","uniqueId":"resourceNewCategory.application l4+.database","icons":["database"]},{"name":"Call Control","normalizedName":"call control","uniqueId":"resourceNewCategory.application l4+.call control","icons":["call_controll"]},{"name":"Border Element","normalizedName":"border element","uniqueId":"resourceNewCategory.application l4+.border element","icons":["borderElement"]},{"name":"Web Server","normalizedName":"web server","uniqueId":"resourceNewCategory.application l4+.web server","icons":["applicationServer"]},{"name":"Firewall","normalizedName":"firewall","uniqueId":"resourceNewCategory.application l4+.firewall","icons":["firewall"]}]},{"name":"Generic","normalizedName":"generic","uniqueId":"resourceNewCategory.generic","subcategories":[{"name":"Database","normalizedName":"database","uniqueId":"resourceNewCategory.generic.database","icons":["database"]},{"name":"Abstract","normalizedName":"abstract","uniqueId":"resourceNewCategory.generic.abstract","icons":["objectStorage","compute"]},{"name":"Network Elements","normalizedName":"network elements","uniqueId":"resourceNewCategory.generic.network elements","icons":["network","connector"]},{"name":"Infrastructure","normalizedName":"infrastructure","uniqueId":"resourceNewCategory.generic.infrastructure","icons":["connector"]}]},{"name":"NewCategory","normalizedName":"newcategory","uniqueId":"resourceNewCategory.newcategory","subcategories":[{"name":"MyNewSubCategory","normalizedName":"mynewsubcategory","uniqueId":"resourceNewCategory.newcategory.mynewsubcategory"}]}]; - - let getAllEntitiesDefered:ng.IDeferred<any> = null; - - beforeEach(angular.mock.inject((_$controller_:ng.IControllerService, - _$httpBackend_:ng.IHttpBackendService, - _$rootScope_, - _$q_:ng.IQService, - _$state_:ng.ui.IStateService, - _$stateParams_:any) => { - - $controllerMock = _$controller_; - $httpBackendMock = _$httpBackend_ - $scopeMock = _$rootScope_.$new(); - $qMock = _$q_; - $stateMock = _$state_; - $stateParams = _$stateParams_; - - - //handle all http request thet not relevant to the tests - $httpBackendMock.expectGET(/.*languages\/en_US.json.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*rest\/version.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*configuration\/ui.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*user\/authorize.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/services.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/resources.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/products.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET('http://feHost:8181/sdc1/feProxy/rest/version').respond(200, JSON.stringify({})); - - /** - * Mock the service - * @type {any} - */ - getAllEntitiesDefered = $qMock.defer(); - getAllEntitiesDefered.resolve(getAllEntitiesResponseMock); - - cacheServiceMock = jasmine.createSpyObj('cacheServiceMock', ['get']); - cacheServiceMock.get.and.callFake(function(string){return resourceCategoriesResponseMock;}); - /* - cacheServiceMock.get.and.callFake(function(value:string){ - switch(value){ - case 'serviceCategories': - console.log('serviceCategories'); - break; - case 'resourceCategories': - console.log('resourceCategories'); - break; - case 'productCategories': - console.log('productCategories'); - break; - default : - console.log('default'); - break; - } - }); - */ - - entityServiceMock = jasmine.createSpyObj('entityServiceMock', ['getCatalog']); - entityServiceMock.getCatalog.and.returnValue(getAllEntitiesDefered.promise); - - // $stateParams['show'] = ''; - - /** - * Need to inject into the controller only the objects that we want to MOCK - * those that we need to change theirs behaviors - */ - $controllerMock(Sdc.ViewModels.CatalogViewModel, { - '$scope': $scopeMock, - '$stateParams': $stateParams, - 'Sdc.Services.EntityService': entityServiceMock, - 'Sdc.Services.CacheService': cacheServiceMock - }); - - })); - - - beforeEach(function () { - }); - - describe("test GUI events on checkbox type resource click", function () { - - /** - * The function checks only for resource type. - * Select the Resource and verify that the sub resources are selected. - * - */ - it('test onComponentTypeClick (check select checkbox of Resource type)', function () { - $scopeMock.$apply(); - $scopeMock.checkboxesFilter.selectedComponentTypes = ['Resource']; - $scopeMock.gui.onComponentTypeClick('Resource'); - expect($scopeMock.checkboxesFilter.selectedResourceSubTypes.length === 4).toBeTruthy(); - }); - - /** - * The function checks only for resource type. - * Un select the Resource and verify that the sub resources are selected. - * - */ - it('test onComponentTypeClick (check un select checkbox of Resource type)', function () { - $scopeMock.$apply(); - $scopeMock.gui.onComponentTypeClick('Resource'); - expect($scopeMock.checkboxesFilter.selectedResourceSubTypes.length === 0).toBeTruthy(); - }); - - }); - - describe("test GUI events on checkbox main category click -> sub categories are selected", function () { - - /** - * The function checks that after selecting 2 main categories, the subcategories are selected also. - * - */ - it('test onComponentTypeClick (check select checkbox of Resource type)', function () { - let category1 = resourceCategoriesResponseMock[0]; - let category2 = resourceCategoriesResponseMock[1]; - - $scopeMock.$apply(); - $scopeMock.checkboxesFilter.selectedCategoriesModel = [category1.uniqueId, category2.uniqueId]; - $scopeMock.gui.onCategoryClick(category1); - $scopeMock.gui.onCategoryClick(category2); - - expect($scopeMock.checkboxesFilter.selectedCategoriesModel.length===8).toBeTruthy(); - }); - - }); - - -}); diff --git a/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.html b/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.html deleted file mode 100644 index ac51e9014c..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.html +++ /dev/null @@ -1,16 +0,0 @@ -<div ng-repeat="activityDate in activityDateArray " class="w-sdc-component-viewer-right-activity-log" > - <div class="w-sdc-component-viewer-right-activity-log-date" >{{activityDate | date: 'longDate'}}</div> - <div ng-repeat="activity in activityLog[activityDate] | orderBy: '-TIMESTAMP'"> - <div class="w-sdc-component-viewer-right-activity-log-time">{{activity.TIMESTAMP.replace(" UTC", '') | stringToDateFilter | date: 'mediumTime':'UTC'}}</div> - <div class="w-sdc-component-viewer-right-activity-log-content">{{"Action: " + parseAction(activity.ACTION) + " Performed by: " + activity.MODIFIER + " Status: " + activity.STATUS}}</div> - </div> - </div> -</div> - - - - - - - - diff --git a/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.less b/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.less deleted file mode 100644 index 4a7676b6e2..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/activity-log/activity-log-view.less +++ /dev/null @@ -1,18 +0,0 @@ -.w-sdc-component-viewer-right-activity-log{ - - .w-sdc-component-viewer-right-activity-log-date{ - .backgroundColor.n; - .font-color.g; - padding: 4px 11px - } - .w-sdc-component-viewer-right-activity-log-time{ - .g_3; - padding: 12px 0px 0px 11px; - } - - .w-sdc-component-viewer-right-activity-log-content{ - .g_1; - padding: 0px 0px 12px 11px; - border-bottom: 1px solid rgba(0, 0, 0, 0.17); - } -} diff --git a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer-view-model.ts b/catalog-ui/app/scripts/view-models/component-viewer/component-viewer-view-model.ts deleted file mode 100644 index 3ae8ad70fb..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer-view-model.ts +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - interface IComponentViewerViewModelScope extends ng.IScope { - component: Models.Components.Component; - additionalInformations: Array<Models.AdditionalInformationModel>; - activityLog: any; - activityDateArray: Array<any>; //this is in order to sort the dates - inputs: Array<any>; - isLoading: boolean; - templateUrl: string; - currentTab:string; - preVersion:string; - sdcMenu:Models.IAppMenu; - versionsList:Array<any>; - close(): void; - hasItems(obj:any): boolean; - onVersionChanged(version:any) : void; - moveToTab(tab:string):void; - isSelected(tab:string):boolean; - getActivityLog(uniqueId:string):void; - parseAction(action:string):string; - } - - export class ComponentViewerViewModel { - - static '$inject' = [ - '$scope', - '$modalInstance', - 'component', - 'Sdc.Services.ActivityLogService', - 'sdcMenu', - 'ComponentFactory' - ]; - - constructor(private $scope:IComponentViewerViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private component:Models.Components.Component, - private activityLogService:Services.ActivityLogService, - private sdcMenu:Models.IAppMenu, - private ComponentFactory: Utils.ComponentFactory) { - this.initScope(component); - } - - //creating objects for versions - private initVersionObject:Function = ():void => { - this.$scope.versionsList = []; - for (let version in this.$scope.component.allVersions) { - this.$scope.versionsList.push({ - versionNumber: version, - versioning: this.versioning(version), - versionId: this.$scope.component.allVersions[version] - }); - } - - }; - - private versioning:Function = (versionNumber:string):string => { - let version:Array<string> = versionNumber.split('.'); - return '00000000'.slice(version[0].length) + version[0] + '.' + '00000000'.slice(version[1].length) + version[1]; - }; - - private showComponentInformationView:Function = ():void => { - if (this.$scope.component.isResource()) { - this.$scope.templateUrl = '/app/scripts/view-models/component-viewer/properties/resource-properties-view.html'; - } else if(this.$scope.component.isService()) { - this.$scope.templateUrl = '/app/scripts/view-models/component-viewer/properties/service-properties-view.html'; - } else { - this.$scope.templateUrl = '/app/scripts/view-models/component-viewer/properties/product-properties-view.html'; - } - }; - - private showActivityLogView:Function = ():void => { - this.$scope.templateUrl = '/app/scripts/view-models/component-viewer/activity-log/activity-log-view.html'; - }; - - private initComponent = (component:Models.Components.Component):void => { - this.$scope.component = component; - this.$scope.additionalInformations = component.getAdditionalInformation(); - this.initVersionObject(); - this.$scope.isLoading = false; - }; - - private initScope = (component:Models.Components.Component):void => { - this.$scope.isLoading = false; - this.initComponent(component); - this.$scope.currentTab = 'PROPERTIES'; - this.$scope.preVersion = component.version; - this.$scope.sdcMenu = this.sdcMenu; - this.showComponentInformationView(); - //service inputs - if (component.isService()) { - let inputs:Array<any> = []; - - for (let group in component.componentInstancesProperties) { - if (component.componentInstancesProperties[group]) { - component.componentInstancesProperties[group].forEach((property:Models.PropertyModel):void => { - if (!property.value) { - property.value = property.defaultValue; - } - inputs.push({ - name: property.name, - value: property.value, - type: property.type - }); - }); - } - } - this.$scope.inputs = inputs; - } - - this.$scope.hasItems = (obj:any):boolean => { - return Object.keys(obj).length > 0; - }; - - this.$scope.close = ():void => { - this.$modalInstance.dismiss(); - }; - - this.$scope.onVersionChanged = (version:any):void => { - if (version.versionNumber != this.$scope.component.version) { - this.$scope.isLoading = true; - this.ComponentFactory.getComponentFromServer(this.component.componentType, version.versionId).then((component: Models.Components.Component):void => { - this.initComponent(component); - }); - if (this.$scope.currentTab === 'ACTIVITY_LOG') { - this.$scope.getActivityLog(version.versionId); - } - - } - }; - - this.$scope.getActivityLog = (uniqueId:any):void => { - - let onError = (response) => { - this.$scope.isLoading = false; - console.info('onFaild', response); - - }; - let onSuccess = (response:Array<Models.Activity>) => { - this.$scope.activityLog = _.groupBy(response, function (activity:Models.Activity) { //group by date only - let dateTime:Date = new Date(activity.TIMESTAMP.replace(" UTC", '').replace(" ", 'T')); - // let date:Date = new Date(dateTime.getFullYear(), dateTime.getMonth(), dateTime.getDate()); - return dateTime.getTime(); - }); - /*this is in order to sort the jsonObject by date*/ - this.$scope.activityDateArray = Object.keys(this.$scope.activityLog); - this.$scope.activityDateArray.sort().reverse(); - this.$scope.isLoading = false; - }; - - this.$scope.isLoading = true; - if (this.$scope.component.isResource()) { - this.activityLogService.getActivityLogService('resources', uniqueId).then(onSuccess, onError); - } - if (this.$scope.component.isService()) { - this.activityLogService.getActivityLogService('services', uniqueId).then(onSuccess, onError); - } - - }; - - this.$scope.moveToTab = (tab:string):void => { - if (tab === this.$scope.currentTab) { - return; - } else if (tab === 'PROPERTIES') { - this.showComponentInformationView(); - this.$scope.preVersion = this.$scope.component.version; - } else if (tab === 'ACTIVITY_LOG') { - if (!this.$scope.activityLog || this.$scope.preVersion != this.$scope.component.version) { - this.$scope.activityLog = this.$scope.getActivityLog(this.$scope.component.uniqueId); - } - this.showActivityLogView(); - } else { - console.error("Tab " + tab + " not found!"); - return; - } - this.$scope.currentTab = tab; - }; - - this.$scope.isSelected = (tab:string):boolean => { - return tab === this.$scope.currentTab; - }; - - this.$scope.parseAction = (action:string) => { - return action ? action.split(/(?=[A-Z])/).join(' ') : ''; - }; - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.html b/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.html deleted file mode 100644 index 6f244b048e..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.html +++ /dev/null @@ -1,55 +0,0 @@ -<div class="w-sdc-resource-viewer"> - <loader data-display="isLoading"></loader> - <div class="w-sdc-resource-viewer-modal-close sprite x-btn-black" data-ng-click="close()">X</div> - <div class="w-sdc-resource-viewer-content" data-ng-if="component"> - <div class="w-sdc-resource-viewer-left"> - <h3 class="w-sdc-resource-viewer-left-title clearfix"> - <div class="w-sdc-resource-viewer-left-title-icon i-sdc-form-item-suggested-icon borderElement large {{component.iconSprite}} {{component.icon}}"></div> - <span class="w-sdc-resource-viewer-left-title-name" - tooltips tooltip-content="{{component.name | resourceName}}">{{component.name | resourceName}}</span> - <br/> - <span class="w-sdc-resource-viewer-left-title-version">v{{component.version}}</span> - </h3> - <p class="w-sdc-resource-viewer-left-title-uuid"> - UUID: {{component.uuid}} - </p> - <div class="w-sdc-resource-viewer-leftbar-section"> - <div class="w-sdc-resource-viewer-leftbar-section-title">Version History</div> - <perfect-scrollbar class="w-sdc-resource-viewer-version"> - <div class="i-sdc-resource-viewer-version-container"> - <div data-ng-repeat="version in versionsList | orderBy: '-versioning'"> - <span class="i-sdc-resource-viewer-version-item" data-ng-class="{'active': version.versionNumber == component.version}" data-ng-click="onVersionChanged(version)">{{ version.versionNumber }}</span> - </div> - </div> - </perfect-scrollbar> - </div> - - <div class="w-sdc-resource-viewer-leftbar-section"> - <div class="w-sdc-resource-viewer-leftbar-section-title">Composition</div> - <perfect-scrollbar class="w-sdc-resource-viewer-leftbar-section-structure" ng-show="component.isComplex()"> - <structure-tree component="component"></structure-tree> - </perfect-scrollbar> - </div> - </div> - - <div class="w-sdc-resource-viewer-right"> - <button class="w-sdc-resource-viewer-right-tab" - data-ng-class="{'selected': isSelected('PROPERTIES')}" - data-ng-click="moveToTab('PROPERTIES')" - translate="ENTITY_VIEWER_PROPERTIES_TAB"> - </button> - - <button class="w-sdc-resource-viewer-right-tab" - data-ng-if="component.isResource() || component.isService()" - data-ng-class="{'selected': isSelected('ACTIVITY_LOG')}" - data-ng-click="moveToTab('ACTIVITY_LOG')" - translate="ENTITY_VIEWER_ACTIVITY_LOG_TAB"> - </button> - - <perfect-scrollbar include-padding="true" class="w-sdc-resource-viewer-right-content"> - <ng-include src="templateUrl" ng-if="true"></ng-include> - </perfect-scrollbar> - <div style="clear:both;"></div> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.less b/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.less deleted file mode 100644 index 2fe5676d62..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/component-viewer.less +++ /dev/null @@ -1,148 +0,0 @@ -html .modal-component-viewer{ - width: 1084px; -} - -.w-sdc-resource-viewer { - .b_7; - .w-sdc-resource-viewer-modal-close{ - z-index: 2; - text-indent: -100px; - overflow: hidden; - top: 19px; - } - .w-sdc-resource-viewer-content { - position: relative; - overflow: hidden; - - .w-sdc-resource-viewer-left { - - .bg_j; - display: table-cell; - width: 282px; - - .w-sdc-resource-viewer-left-title { - margin: 0; - display: block; - height: 100px; - padding: 20px 0; - } - - .w-sdc-resource-viewer-left-title-icon { - margin: 0 15px; - vertical-align: middle; - float: left; - } - - .w-sdc-resource-viewer-left-title-name { - .g_7; - max-width: 160px; - overflow: hidden; - display: inline-block; - text-overflow: ellipsis; - vertical-align: middle; - line-height: 23px; - padding-top: 10px; - font-weight: bold; - white-space: nowrap; - } - - .w-sdc-resource-viewer-left-title-version { - .g_13; - float: left; - } - - .w-sdc-resource-viewer-left-title-uuid { - .g_14; - text-align: center; - border-top: 1px solid rgba(120, 136, 148, 0.26); - width: 95%; - margin: auto; - padding: 7px 0; - } - - .w-sdc-resource-viewer-leftbar-section { - font-family: omnes-medium, sans-serif; - } - - .w-sdc-resource-viewer-leftbar-section-title { - .bg_o; - color: #fff; - font-size: 14px; - padding: 12px 20px; - text-transform: uppercase; - } - - .w-sdc-resource-viewer-leftbar-section-structure{ - .perfect-scrollbar; - max-height: 525px; - } - .w-sdc-resource-viewer-version { - font-weight: bold; - .perfect-scrollbar; - } - - .i-sdc-resource-viewer-version-container { - padding: 13px 0px 13px 13px; - max-height: 218px; - - .i-sdc-resource-viewer-version-item { - - &.active { - .a_7; - } - &:hover { - cursor: pointer; - } - } - - } - } - - .w-sdc-resource-viewer-right { - .bg_c; - display: table-cell; - vertical-align: top; - padding: 0; // for the scroller to be on all width - width: 716px; - padding: 25px 0px 0px 35px; - - .w-sdc-resource-viewer-right-content { - padding: 0 52px 0 0px; - margin-bottom: 25px; - height: 700px; - overflow: hidden; - position: relative; - - } - - .w-sdc-resource-viewer-right-tab { - .b_6; - - .hand; - background-color: transparent; - position: relative; - font-weight: 500; - line-height: 30px; - border: none; - border-bottom: solid 1px @color_c; - vertical-align: middle; - padding: 0px 30px 20px 0px; - - - &:focus, - &:active { - outline: none; - - } - &.selected { - outline: none; - font-weight: 700; - .font-color.a; - } - } - - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/component-viewer/properties/product-properties-view.html b/catalog-ui/app/scripts/view-models/component-viewer/properties/product-properties-view.html deleted file mode 100644 index 8aeda603f8..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/properties/product-properties-view.html +++ /dev/null @@ -1,76 +0,0 @@ -<div class="w-sdc-component-viewer-right-properties"> - - <h4 class="w-sdc-resource-viewer-right-title">General Information</h4> - <div class="w-sdc-resource-viewer-right-content-section"> - <div class='sdc-resource-viewer-sidebar-section-content-column-1'> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TYPE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" translate="GENERAL_LABEL_PRODUCT"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_VERSION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.version"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CATEGORY"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.category}}" data-ng-bind="component.category"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CREATION_DATE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creationDate | date: 'MM/dd/yyyy'"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_AUTHOR"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creatorFullName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CONTACT_ID"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.contacts[0]"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_PROJECT_CODE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.projectCode"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">Life Cycle Status:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value"> - {{sdcMenu.LifeCycleStatuses[component.lifecycleState].text}} - </span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">Distribution Status:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value"> - {{sdcMenu.DistributionStatuses[component.distributionStatus].text}} - </span> - </div> - </div> - <div class='sdc-resource-viewer-sidebar-section-content-column-2'> - <div class="sdc-resource-viewer-sidebar-section-content-item description"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_DESCRIPTION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.description"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item" > - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TAGS"></span> - <span tooltips tooltip-content="{{component.tags.join(', ')}}" class="sdc-resource-viewer-sidebar-section-content-tags" data-ng-repeat="(tag, tagName) in component.tags"> - {{tagName}}{{$last ? '' : ','}} - </span> - </div> - </div> - </div> - <h4 class="w-sdc-resource-viewer-right-title">Additional Information</h4> - - <div class="sdc-properties-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="additionalInformations.length"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Key</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Value</th> - </thead> - <tbody> - <tr data-ng-repeat="additionalInformation in additionalInformations"> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.key}}">{{additionalInformation.key}}</span></td> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.value}}">{{additionalInformation.value}}</span></td> - </tr> - </tbody> - </table> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/component-viewer/properties/properties-view.less b/catalog-ui/app/scripts/view-models/component-viewer/properties/properties-view.less deleted file mode 100644 index c0beed338f..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/properties/properties-view.less +++ /dev/null @@ -1,128 +0,0 @@ -.w-sdc-component-viewer-right-properties { - .w-sdc-resource-viewer-tabs { - height: 42px; - } - - .w-sdc-resource-viewer-right-content-section { - margin: 0 0 20px 16px; - } - - .sdc-resource-viewer-sidebar-section-content-column-1, - .sdc-resource-viewer-sidebar-section-content-column-2 { - display: table-cell; - width: 50%; - } - .sdc-resource-viewer-sidebar-section-content-item { - .b_7; - margin-bottom: 5px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - width: 305px; - } - .sdc-resource-viewer-sidebar-section-content-item-label { - .bold; - .g_9; - } - .w-sdc-resource-viewer-right .sdc-resource-viewer-sidebar-section-content-column-1 { - .sdc-resource-viewer-sidebar-section-content-item { - width: 390px; - } - } - .sdc-resource-viewer-sidebar-section-content-item.description { - margin: 0; - - .sdc-resource-viewer-sidebar-section-content-item-value { - word-wrap: break-word; - white-space: normal; - display: block; - - } - .sdc-resource-viewer-sidebar-section-content-tags { - word-wrap: break-word; - white-space: pre-wrap; - display: inline-block; - max-width: 167px; - - } - } - - .w-sdc-resource-viewer-right-title { - .g_1; - .bg_n; - padding: 7px 15px; - margin: 0px 0 25px; - font-weight: bold; - } - - .w-sdc-resource-viewer-right-table-head-cell { - .g_9; - text-align: left; - } - - .cols-1 { - width: 100%; - } - .cols-2 { - width: 50%; - } - .cols-3 { - width: 33%; - } - - .sdc-properties-container table tbody td.label { - .bold; - } - - .w-sdc-designer-sidebar-section-content, - .w-sdc-resource-viewer-right-table { - display: table; - width: 100%; - .b_9; - word-break: break-all; - - tbody td { - padding: 4px 20px 0 0; - - .ellipsis-directive-more-less { - display: none; - } - - .ellipsis-cols2 { - .sdc-ellipsis; - max-width: 340px; - } - .ellipsis-cols3 { - .sdc-ellipsis; - max-width: 200px; - } - } - - } - - .i-sdc-designer-sidebar-section-content-column-1 { - display: table-cell; - width: 50%; - } - - .i-sdc-designer-sidebar-section-content-column-2 { - display: table-cell; - width: 50%; - } - - .i-sdc-resource-viewer-artifacts-item-action, - .sdc-information-artifacts-icon { - .sprite; - display: inline-block; - width: 20px; - height: 20px; - cursor: pointer; - vertical-align: middle; - &.download { - .sprite.e-sdc-small-download; - } - &.preview { - .e-sdc-small-icon-eye; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/component-viewer/properties/resource-properties-view.html b/catalog-ui/app/scripts/view-models/component-viewer/properties/resource-properties-view.html deleted file mode 100644 index c02e7aba7e..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/properties/resource-properties-view.html +++ /dev/null @@ -1,169 +0,0 @@ -<div class="w-sdc-component-viewer-right-properties"> - - <h4 class="w-sdc-resource-viewer-right-title">General Information</h4> - <div class="w-sdc-resource-viewer-right-content-section"> - <div class='sdc-resource-viewer-sidebar-section-content-column-1'> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TYPE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" >Resource</span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_RESOURCE_TYPE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.resourceType | resourceTypeName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_VERSION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.version"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CATEGORY"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.categories[0].name}}" data-ng-bind="component.categories[0].name"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_SUB_CATEGORY"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.categories[0].subcategories[0].name}}" data-ng-bind="component.categories[0].subcategories[0].name"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CREATION_DATE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creationDate | date: 'MM/dd/yyyy'"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_AUTHOR"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creatorFullName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_VENDOR_NAME"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.vendorName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_VENDOR_RELEASE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.vendorRelease"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CONTACT_ID"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.contactId"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">Life Cycle Status:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value"> - {{sdcMenu.LifeCycleStatuses[component.lifecycleState].text}} - </span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">System Name:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.systemName}}" data-ng-bind="component.systemName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_LICENSE_TYPE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.licenseType"></span> - </div> - </div> - <div class='sdc-resource-viewer-sidebar-section-content-column-2'> - <div class="sdc-resource-viewer-sidebar-section-content-item description"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_DESCRIPTION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.description"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TAGS"></span> - <span class="sdc-resource-viewer-sidebar-section-content-tags" data-ng-repeat="(tag, tagName) in component.tags" tooltips tooltip-content="{{component.tags.join(', ')}}">{{tagName}}{{$last ? '' : ','}}</span> - </div> - </div> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Additional Information</h4> - - <div class="sdc-properties-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="additionalInformations.length"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Key</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Value</th> - </thead> - <tbody> - <tr data-ng-repeat="additionalInformation in additionalInformations"> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.key}}">{{additionalInformation.key}}</span></td> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.value}}">{{additionalInformation.value}}</span></td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Properties</h4> - <div class="sdc-properties-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="component.properties.length"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Type (Constraints)</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Default Value</th> - </thead> - <tbody> - <tr data-ng-repeat="property in component.properties"> - <td><span class="ellipsis-cols2" data-tests-id="{{property.name}}" tooltips tooltip-content="{{property.name}}">{{property.name}}</span></td> - <td><span data-tests-id="{{property.type}}">{{property.type}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{property.defaultValue}}" tooltips tooltip-content="{{property.defaultValue}}">{{property.defaultValue}}</span></td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Requirements</h4> - <div class="sdc-requirements-container w-sdc-resource-viewer-right-content-section" > - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.requirements)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-1">Type</th> - </thead> - <tbody> - <tr data-ng-repeat="(key, value) in component.requirements"> - <td>{{value[0].name}}</td> - </tr> - </tbody> - </table> - </div> - - - <h4 class="w-sdc-resource-viewer-right-title">Deployment Artifacts</h4> - - <div class="sdc-information-container w-sdc-resource-viewer-right-content-section" > - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.deploymentArtifacts)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">File</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Version</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3"></th> - </thead> - <tbody> - <tr data-ng-repeat="(artifactLogicName, artifact) in component.deploymentArtifacts"> - <td><span class="ellipsis-cols2" data-tests-id="{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactDisplayName}}">{{artifact.artifactDisplayName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactName}}" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactVersion}}" tooltips tooltip-content="{{artifact.artifactVersion}}" data-ng-if="artifact.esId">{{artifact.artifactVersion}}</span></td> - <td class="cols-3"> - <download-artifact class="sdc-information-artifacts-icon download" data-ng-if="artifact.artifactName" component="component" artifact="artifact"></download-artifact> - <!--span class="sdc-information-artifacts-icon preview"></span--> - </td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Information Artifacts</h4> - <div class="sdc-information-container w-sdc-resource-viewer-right-content-section" > - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.artifacts)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">File</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Version</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3"></th> - </thead> - <tbody> - <tr data-ng-repeat="(artifactLogicName, artifact) in component.artifacts"> - <td><span class="ellipsis-cols2" data-tests-id="{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactDisplayName}}">{{artifact.artifactDisplayName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactName}}" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactVersion}}" tooltips tooltip-content="{{artifact.artifactVersion}}" data-ng-if="artifact.esId">{{artifact.artifactVersion}}</span></td> - <td class="cols-3"> - <download-artifact class="sdc-information-artifacts-icon download" data-ng-if="artifact.artifactName" component="component" artifact="artifact"></download-artifact> - <!--span class="sdc-information-artifacts-icon preview"></span--> - </td> - </tr> - </tbody> - </table> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/component-viewer/properties/service-properties-view.html b/catalog-ui/app/scripts/view-models/component-viewer/properties/service-properties-view.html deleted file mode 100644 index 01f872c13c..0000000000 --- a/catalog-ui/app/scripts/view-models/component-viewer/properties/service-properties-view.html +++ /dev/null @@ -1,167 +0,0 @@ -<div class="w-sdc-component-viewer-right-properties"> - - <h4 class="w-sdc-resource-viewer-right-title">General Information</h4> - <div class="w-sdc-resource-viewer-right-content-section"> - <div class='sdc-resource-viewer-sidebar-section-content-column-1'> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TYPE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" translate="GENERAL_LABEL_SERVICE"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_VERSION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.version"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CATEGORY"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.categories[0].name}}" data-ng-bind="component.categories[0].name"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CREATION_DATE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creationDate | date: 'MM/dd/yyyy'"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_AUTHOR"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.creatorFullName"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CONTACT_ID"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.contactId"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_PROJECT_CODE"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.projectCode"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">Life Cycle Status:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value"> {{sdcMenu.LifeCycleStatuses[component.lifecycleState].text}}</span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">Distribution Status:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value">{{sdcMenu.DistributionStatuses[component.distributionStatus].text}}</span> - </div> - - <div class="sdc-resource-viewer-sidebar-section-content-item"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label">System Name:</span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" tooltips tooltip-content="{{component.systemName}}" data-ng-bind="component.systemName"></span> - </div> - </div> - <div class='sdc-resource-viewer-sidebar-section-content-column-2'> - <div class="sdc-resource-viewer-sidebar-section-content-item description"> - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_DESCRIPTION"></span> - <span class="sdc-resource-viewer-sidebar-section-content-item-value" data-ng-bind="component.description"></span> - </div> - <div class="sdc-resource-viewer-sidebar-section-content-item" > - <span class="sdc-resource-viewer-sidebar-section-content-item-label" translate="GENERAL_LABEL_TAGS"></span> - <span tooltips tooltip-content="{{component.tags.join(', ')}}" class="sdc-resource-viewer-sidebar-section-content-tags" data-ng-repeat="(tag, tagName) in component.tags">{{tagName}}{{$last ? '' : ','}}</span> - </div> - </div> - </div> - <h4 class="w-sdc-resource-viewer-right-title">Additional Information</h4> - - <div class="sdc-properties-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="additionalInformations.length"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Key</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Value</th> - </thead> - <tbody> - <tr data-ng-repeat="additionalInformation in additionalInformations"> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.key}}">{{additionalInformation.key}}</span></td> - <td><span class="ellipsis-cols2" tooltips tooltip-content="{{additionalInformation.value}}">{{additionalInformation.value}}</span></td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Inputs</h4> - - <div class="sdc-properties-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="inputs.length"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Type (Constraints)</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Default Value</th> - </thead> - <tbody> - <tr data-ng-repeat="input in inputs"> - <td><span class="ellipsis-cols2" data-tests-id="{{input.name}}" tooltips tooltip-content="{{input.name}}">{{input.name}}</span></td> - <td>{{input.type}}</td> - <td><span class="ellipsis-cols3" data-tests-id="{{input.value}}" tooltips tooltip-content="{{input.value}}">{{input.value}}</span></td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">API Artifacts</h4> - - <div class="sdc-requirements-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.serviceApiArtifacts)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">File</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Version</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3"></th> - </thead> - <tbody> - <tr data-ng-repeat="(artifactLogicName, artifact) in component.serviceApiArtifacts"> - <td><span class="ellipsis-cols2" data-tests-id="{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactDisplayName}}">{{artifact.artifactDisplayName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactName}}" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactVersion}}" tooltips tooltip-content="{{artifact.artifactVersion}}" data-ng-if="artifact.esId">{{artifact.artifactVersion}}</span></td> - <td class="cols-3"> - <download-artifact class="sdc-information-artifacts-icon download" data-ng-if="artifact.artifactName" component="component" artifact="artifact"></download-artifact> - <!--span class="sdc-information-artifacts-icon preview"></span--> - </td> - </tr> - </tbody> - </table> - </div> - - <h4 class="w-sdc-resource-viewer-right-title">Deployment Artifacts</h4> - - <div class="sdc-information-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.deploymentArtifacts)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">File</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Version</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3"></th> - </thead> - <tbody> - <tr data-ng-repeat="(artifactLogicName, artifact) in component.deploymentArtifacts"> - <td><span class="ellipsis-cols2" data-tests-id="{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactDisplayName}}">{{artifact.artifactDisplayName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactName}}" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactVersion}}" tooltips tooltip-content="{{artifact.artifactVersion}}" data-ng-if="artifact.esId">{{artifact.artifactVersion}}</span></td> - <td class="cols-3"> - <download-artifact class="sdc-information-artifacts-icon download" data-ng-if="artifact.artifactName" component="component" artifact="artifact"></download-artifact> - <!--span class="sdc-information-artifacts-icon preview"></span--> - </td> - </tr> - </tbody> - </table> - </div> - - - <h4 class="w-sdc-resource-viewer-right-title">Information Artifacts</h4> - - <div class="sdc-information-container w-sdc-resource-viewer-right-content-section"> - <table class="w-sdc-resource-viewer-right-table" data-ng-show="hasItems(component.artifacts)"> - <thead class="w-sdc-resource-viewer-right-table-head"> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-2">Name</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">File</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3">Version</th> - <th class="w-sdc-resource-viewer-right-table-head-cell cols-3"></th> - </thead> - <tbody> - <tr data-ng-repeat="(artifactLogicName, artifact) in component.artifacts"> - <td><span class="ellipsis-cols2" data-tests-id="{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactDisplayName}}">{{artifact.artifactDisplayName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactName}}" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</span></td> - <td><span class="ellipsis-cols3" data-tests-id="{{artifact.artifactVersion}}" tooltips tooltip-content="{{artifact.artifactVersion}}" data-ng-if="artifact.esId">{{artifact.artifactVersion}}</span></td> - <td class="cols-3"> - <download-artifact class="sdc-information-artifacts-icon download" data-ng-if="artifact.artifactName" component="component" artifact="artifact"></download-artifact> - <!--span class="sdc-information-artifacts-icon preview"></span--> - </td> - </tr> - </tbody> - </table> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view-model.ts b/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view-model.ts deleted file mode 100644 index 9979b6451b..0000000000 --- a/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view-model.ts +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - - 'use strict'; - - export interface IDashboardCoverViewModelScope extends ng.IScope { - showTutorial:boolean; - version:string; - modalInstance:ng.ui.bootstrap.IModalServiceInstance; - } - - export class DashboardCoverViewModel { - static '$inject' = [ - '$scope', - '$stateParams', - 'Sdc.Services.CacheService', - '$templateCache', - '$state', - '$modal', - 'sdcConfig' - ]; - - constructor(private $scope:IDashboardCoverViewModelScope, - private $stateParams:any, - private cacheService:Services.CacheService, - private $templateCache:ng.ITemplateCacheService, - private $state:any, - private $modal:ng.ui.bootstrap.IModalService, - private sdcConfig:Models.IAppConfigurtaion) { - - // Show the tutorial if needed when the dashboard page is opened.<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script> - // This is called from the welcome page. - if (this.$stateParams.show === 'tutorial') { - this.$scope.showTutorial = true; - } else if (this.$stateParams.show === 'whatsnew') { - this.$scope.version = this.cacheService.get('version'); - this.openWhatsNewModal(this.$scope); - } - - this.initScope(); - } - - private initScope = ():void => { - - }; - - private openWhatsNewModal = (scope:IDashboardCoverViewModelScope):void => { - - let onOk = ():void => {}; - - let onCancel = ():void => { - this.$state.go('dashboard.welcome', {show: ''}); - }; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/whats-new/whats-new-view.html'), - controller: 'Sdc.ViewModels.WhatsNewViewModel', - size: 'sdc-l', - backdrop: 'static', - scope: scope, - resolve: { - 'version': scope.version - } - }; - - scope.modalInstance = this.$modal.open(modalOptions); - scope.modalInstance.result.then(onOk, onCancel); - }; - - } - -} diff --git a/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view.html b/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view.html deleted file mode 100644 index c8657cba23..0000000000 --- a/catalog-ui/app/scripts/view-models/dashboard/cover/dashboard-cover-view.html +++ /dev/null @@ -1 +0,0 @@ -<div class="sdc-welcome-page"></div> diff --git a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model-tests.ts b/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model-tests.ts deleted file mode 100644 index d97d9bb5ec..0000000000 --- a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model-tests.ts +++ /dev/null @@ -1,276 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> - -describe("dashboard View Model ", () => { - - let $controllerMock:ng.IControllerService; - let $qMock:ng.IQService; - let $httpBackendMock:ng.IHttpBackendService; - let $scopeMock:Sdc.ViewModels.IDashboardViewModelScope; - let $stateMock:ng.ui.IStateService; - let $stateParams:any; - let entityServiceMock; - - - let getAllEntitiesResponseMock = [ - { - "uniqueId": "855acdc7-7976-4913-9fa6-25220bd5a069", - "uuid": "8bc54f94-082c-42fa-9049-84767df3ff05", - "contactId": "qa1234", - "category": "VoIP Call Control", - "creationDate": 1447234712398, - "description": "ddddd", - "highestVersion": true, - "icon": "mobility", - "lastUpdateDate": 1447234712398, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "distributionStatus": "DISTRIBUTION_NOT_APPROVED", - "projectCode": "233233", - "name": "mas mas mas mas mas mas mas mas mas mas mas mas ma", - "version": "0.1", - "type": 0, - "tags": [ - "mas mas mas mas mas mas mas mas mas mas mas mas ma" - ], - "systemName": "MasMasMasMasMasMasMasMasMasMasMasMasMa", - "vnf": true, - "$$hashKey": "object:30" - }, - { - "uniqueId": "4bb577ce-cb2c-4cb7-bb39-58644b5e73cb", - "uuid": "e27f4723-c9ec-4160-89da-dbf84d19a7e3", - "contactId": "qa1111", - "category": "Mobility", - "creationDate": 1447238503181, - "description": "aqa", - "highestVersion": true, - "icon": "call_controll", - "lastUpdateDate": 1447248991388, - "lastUpdaterUserId": "jm0007", - "lastUpdaterFullName": "Joni Mitchell", - "lifecycleState": "CERTIFIED", - "distributionStatus": "DISTRIBUTION_REJECTED", - "projectCode": "111111", - "name": "martin18", - "version": "1.0", - "type": 0, - "tags": [ - "martin18" - ], - "systemName": "Martin18", - "vnf": true - }, - { - "uniqueId": "f192f4a6-7fbf-42e4-a546-37509df28dc1", - "uuid": "0b77dc0d-222e-4d10-85cd-e420c9481417", - "contactId": "fd1212", - "category": "Application Layer 4+/Web Server", - "creationDate": 1447233679778, - "description": "geefw", - "highestVersion": true, - "icon": "database", - "lastUpdateDate": 1447233681582, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "ger", - "version": "0.1", - "type": 1, - "tags": [ - "ger" - ], - "vendorName": "fewwfe", - "vendorRelease": "fewew", - "systemName": "Ger", - "$$hashKey": "object:31" - }, - { - "uniqueId": "78392d08-1859-47c2-b1f2-1a35b7f8c30e", - "uuid": "8cdd63b2-6a62-4376-9012-624f424f71d4", - "contactId": "qw1234", - "category": "Application Layer 4+/Application Servers", - "creationDate": 1447234046114, - "description": "test", - "highestVersion": true, - "icon": "router", - "lastUpdateDate": 1447234050545, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "test", - "version": "0.1", - "type": 1, - "tags": [ - "test" - ], - "vendorName": "test", - "vendorRelease": "test", - "systemName": "Test", - "$$hashKey": "object:32" - }, - { - "uniqueId": "939e153d-2236-410f-b4a9-3b4bf8c79c9e", - "uuid": "84862547-4f56-4058-b78e-40df5f374d7e", - "contactId": "qw1234", - "category": "Application Layer 4+/Application Servers", - "creationDate": 1447235242560, - "description": "jlk", - "highestVersion": true, - "icon": "database", - "lastUpdateDate": 1447235328062, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKIN", - "name": "new", - "version": "0.1", - "type": 1, - "tags": [ - "new" - ], - "vendorName": "e", - "vendorRelease": "e", - "systemName": "New", - "$$hashKey": "object:33" - }, - { - "uniqueId": "ece818e0-fd59-477a-baf6-e27461a7ce23", - "uuid": "8db823c2-6a9c-4636-8676-f5e713270dd7", - "contactId": "uf2345", - "category": "Network Layer 2-3/Router", - "creationDate": 1447235352429, - "description": "u", - "highestVersion": true, - "icon": "network", - "lastUpdateDate": 1447235370064, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "u", - "version": "0.1", - "type": 1, - "tags": [ - "u" - ], - "vendorName": "u", - "vendorRelease": "u", - "systemName": "U", - "$$hashKey": "object:34" - } - ]; - let getAllEntitiesDefered:ng.IDeferred<any> = null; - - beforeEach(angular.mock.module('sdcApp')); - - beforeEach(angular.mock.inject((_$controller_:ng.IControllerService, - _$httpBackend_:ng.IHttpBackendService, - _$rootScope_, - _$q_:ng.IQService, - _$state_:ng.ui.IStateService, - _$stateParams_:any) => { - - $controllerMock = _$controller_; - $httpBackendMock = _$httpBackend_ - $scopeMock = _$rootScope_.$new(); - $qMock = _$q_; - $stateMock = _$state_; - $stateParams = _$stateParams_; - - - //handle all http request thet not relevant to the tests - $httpBackendMock.expectGET(/.*languages\/en_US.json.*/).respond(200, JSON.stringify({})); - // $httpBackendMock.expectGET(/.*resources\/certified\/abstract.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*rest\/version.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*configuration\/ui.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*user\/authorize.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/services.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/resources.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/products.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET('http://feHost:8181/sdc1/feProxy/rest/version').respond(200, JSON.stringify({})); - - /** - * Mock the service - * @type {any} - */ - getAllEntitiesDefered = $qMock.defer(); - getAllEntitiesDefered.resolve(getAllEntitiesResponseMock); - entityServiceMock = jasmine.createSpyObj('entityServiceMock', ['getAllComponents']); - entityServiceMock.getAllComponents.and.returnValue(getAllEntitiesDefered.promise); - - // $stateParams['show'] = ''; - - /** - * Need to inject into the controller only the objects that we want to MOCK - * those that we need to change theirs behaviors - */ - $controllerMock(Sdc.ViewModels.DashboardViewModel, { - '$scope': $scopeMock, - '$stateParams': $stateParams, - 'Sdc.Services.EntityService': entityServiceMock, - }); - - })); - - - describe("when Controller 'DashboardViewModel' created", () => { - - it('should generate all entities', () => { - $scopeMock.$apply(); - expect($scopeMock.components.length).toBe(getAllEntitiesResponseMock.length); - }); - - - it('should show tutorial page ', () => { - $stateParams.show = 'tutorial'; - - $controllerMock(Sdc.ViewModels.DashboardViewModel, { - '$scope': $scopeMock, - '$stateParams': $stateParams, - 'Sdc.Services.EntityService': entityServiceMock, - //to complete injects - }); - - $scopeMock.$apply(); - expect($scopeMock.isFirstTime).toBeTruthy(); - expect($scopeMock.showTutorial).toBeTruthy(); - }); - - }); - - - describe("when function 'entitiesCount' invoked", () => { - - beforeEach(() => { - $controllerMock(Sdc.ViewModels.DashboardViewModel, { - '$scope': $scopeMock, - 'Sdc.Services.EntityService': entityServiceMock, - }); - $scopeMock.$apply(); - }); - - it('should return entities count per folder', () => { - - }); - - - }); -}); diff --git a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model.ts b/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model.ts deleted file mode 100644 index 8325a3f133..0000000000 --- a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view-model.ts +++ /dev/null @@ -1,415 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - - 'use strict'; - import ResourceType = Sdc.Utils.Constants.ResourceType; - - export interface IDashboardViewModelScope extends ng.IScope { - - isLoading: boolean; - components: Array<Models.Components.Component>; - folders: FoldersMenu; - roles: Models.IConfigRoles; - user: Models.IUserProperties; - sdcConfig:Models.IAppConfigurtaion; - sdcMenu:Models.IAppMenu; - sharingService:Sdc.Services.SharingService; - showTutorial:boolean; - isFirstTime:boolean; - version:string; - checkboxesFilter:CheckboxesFilter; - - onImportVfc(file:any):void; - onImportVf(file:any):void; - openCreateModal(componentType: Utils.Constants.ComponentType, importedFile:any): void; - openWhatsNewModal(version:string):void; - openDesignerModal(isResource:boolean, uniqueId:string): void; - openViewerModal(entity:any) : void; - setSelectedFolder(folderItem: FoldersItemsMenu): void; - entitiesCount(folderItem: FoldersItemsMenu): number; - getCurrentFolderDistributed(): Array<Models.Components.Component>; - changeLifecycleState(entity:any, data:any): void; - goToComponent(component:Models.Components.Component):void; - wizardDebugEdit:Function; - notificationIconCallback:Function; - } - - interface CheckboxesFilter { - // Statuses - selectedStatuses:Array<string>; - // distributed - distributed:Array<string>; - } - - export interface IItemMenu { - - } - - export interface IMenuItemProperties { - text: string; - group: string; - state: string; - dist: string; - groupname: string; - states: Array<any>; - } - - export class FoldersMenu { - - private _folders: Array<FoldersItemsMenu> = []; - - constructor(folders: Array<IMenuItemProperties>) { - let self = this; - folders.forEach(function(folder: IMenuItemProperties) { - if (folder.groupname){ - self._folders.push(new FoldersItemsMenuGroup(folder)); - } else { - self._folders.push(new FoldersItemsMenu(folder)); - } - }); - self._folders[0].setSelected(true); - } - - public getFolders = (): Array<FoldersItemsMenu> => { - return this._folders; - }; - - public getCurrentFolder = (): FoldersItemsMenu => { - let menuItem: FoldersItemsMenu = undefined; - this.getFolders().forEach(function(tmpFolder: FoldersItemsMenu) { - if (tmpFolder.isSelected()){ - menuItem = tmpFolder; - } - }); - return menuItem; - }; - - public setSelected = (folder: FoldersItemsMenu):void => { - this.getFolders().forEach(function(tmpFolder: FoldersItemsMenu) { - tmpFolder.setSelected(false); - }); - folder.setSelected(true); - } - - } - - export class FoldersItemsMenu implements IItemMenu { - - public text:string; - public group: string; - public state: string; - public dist: string; - public states: Array<any>; - - private selected: boolean = false; - - constructor(menuProperties: IMenuItemProperties) { - this.text = menuProperties.text; - this.group = menuProperties.group; - this.state = menuProperties.state; - this.states = menuProperties.states; - this.dist = menuProperties.dist; - } - - public isSelected = ():boolean => { - return this.selected; - }; - - public setSelected = (value: boolean):void => { - this.selected = value; - }; - - public isGroup = ():boolean => { - return false; - } - - } - - export class FoldersItemsMenuGroup extends FoldersItemsMenu { - - public groupname:string; - - constructor(menuProperties: IMenuItemProperties) { - super(menuProperties); - this.groupname = menuProperties.groupname; - } - - public isGroup = ():boolean => { - return true; - } - - } - - export class DashboardViewModel { - static '$inject' = [ - '$scope', - '$filter', - 'Sdc.Services.EntityService', - '$http', - 'sdcConfig', - 'sdcMenu', - '$modal', - '$templateCache', - '$state', - '$stateParams', - 'Sdc.Services.UserResourceService', - 'Sdc.Services.SharingService', - 'Sdc.Services.CacheService', - '$q', - 'ComponentFactory', - 'ChangeLifecycleStateHandler', - 'ModalsHandler', - 'MenuHandler' - ]; - - private components: Array<Models.Components.Component>; - - constructor(private $scope:IDashboardViewModelScope, - private $filter:ng.IFilterService, - private entityService:Services.EntityService, - private $http:ng.IHttpService, - private sdcConfig:Models.IAppConfigurtaion, - private sdcMenu:Models.IAppMenu, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private $state:any, - private $stateParams:any, - private userResourceService:Sdc.Services.IUserResourceClass, - private sharingService:Services.SharingService, - private cacheService:Services.CacheService, - private $q:ng.IQService, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private ChangeLifecycleStateHandler: Sdc.Utils.ChangeLifecycleStateHandler, - private ModalsHandler: Sdc.Utils.ModalsHandler, - private MenuHandler: Utils.MenuHandler - ) { - this.initScope(); - this.initFolders(); - this.initEntities(true); - - if (this.$stateParams){ - - if (this.$state.params.folder){ - let self = this; - let folderName = this.$state.params.folder.replaceAll("_"," "); - - this.$scope.folders.getFolders().forEach(function(tmpFolder: FoldersItemsMenu) { - if (tmpFolder.text === folderName){ - self.$scope.setSelectedFolder(tmpFolder); - } - }); - } - - // Show the tutorial if needed when the dashboard page is opened.<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script> - // This is called from the welcome page. - else if (this.$stateParams.show==='tutorial'){ - this.$scope.showTutorial = true; - this.$scope.isFirstTime = true; - } - } - } - - private initFolders = ():void => { - if (this.$scope.user) { - this.$scope.folders = new FoldersMenu(this.$scope.roles[this.$scope.user.role].folder); - } - }; - - private initScope = ():void => { - let self = this; - - this.$scope.version = this.cacheService.get('version'); - this.$scope.sharingService = this.sharingService; - this.$scope.isLoading = false; - this.$scope.sdcConfig = this.sdcConfig; - this.$scope.sdcMenu = this.sdcMenu; - this.$scope.user = this.userResourceService.getLoggedinUser(); - this.$scope.roles = this.sdcMenu.roles; - this.$scope.showTutorial = false; - this.$scope.isFirstTime = false; - - // Open onboarding modal - this.$scope.notificationIconCallback = ():void => { - this.ModalsHandler.openOnboadrdingModal('Import').then(()=>{ - // OK - }, ()=>{ - // ERROR - }); - }; - - // Checkboxes filter init - this.$scope.checkboxesFilter = <CheckboxesFilter>{}; - this.$scope.checkboxesFilter.selectedStatuses = []; - this.$scope.checkboxesFilter.distributed = []; - - let appendTemplateAndControllerForProduct:Function = (modalOptions:ng.ui.bootstrap.IModalSettings, isViewer:boolean):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - if (isViewer) { - modalOptions.template = this.$templateCache.get(viewModelsHtmlBasePath + 'entity-viewer/product-viewer-view.html'); - modalOptions.controller = 'Sdc.ViewModels.ResourceViewerViewModel'; - } else { - modalOptions.template = this.$templateCache.get(viewModelsHtmlBasePath + 'entity-handler/product-form/product-form-view.html'); - modalOptions.controller = 'Sdc.ViewModels.ProductFormViewModel'; - } - - }; - - this.$scope.onImportVf = (file:any):void => { - if(file && file.filename) { - // Check that the file has valid extension. - let fileExtension:string = file.filename.split(".").pop(); - if (this.sdcConfig.csarFileExtension.indexOf(fileExtension.toLowerCase()) !== -1){ - this.$state.go('workspace.general', {type:Utils.Constants.ComponentType.RESOURCE.toLowerCase(), importedFile: file, resourceType: ResourceType.VF}); - }else { - let data:Sdc.ViewModels.IClientMessageModalModel = { - title: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_CSAR_EXTENSIONS_TITLE"), - message: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_CSAR_EXTENSIONS", "{'extensions': '" + this.sdcConfig.csarFileExtension + "'}"), - severity: Utils.Constants.SEVERITY.ERROR - }; - this.ModalsHandler.openClientMessageModal(data); - } - } - }; - - this.$scope.onImportVfc = (file:any):void => { - if(file && file.filename) { - // Check that the file has valid extension. - let fileExtension:string = file.filename.split(".").pop(); - if (this.sdcConfig.toscaFileExtension.indexOf(fileExtension.toLowerCase()) !== -1){ - this.$state.go('workspace.general', {type:Utils.Constants.ComponentType.RESOURCE.toLowerCase(), importedFile: file, resourceType: ResourceType.VFC}); - }else { - let data:Sdc.ViewModels.IClientMessageModalModel = { - title: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_TOSCA_EXTENSIONS_TITLE"), - message: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_TOSCA_EXTENSIONS", "{'extensions': '" + this.sdcConfig.toscaFileExtension + "'}"), - severity: Utils.Constants.SEVERITY.ERROR - }; - this.ModalsHandler.openClientMessageModal(data); - } - } - }; - - this.$scope.openCreateModal = (componentType: string, importedFile:any):void => { - if (importedFile){ - this.initEntities(true); // Return from import - } else { - this.$state.go('workspace.general', {type:componentType.toLowerCase()}); - } - - }; - - this.$scope.entitiesCount = (folderItem: FoldersItemsMenu): any => { - let self = this; - let total: number = 0; - if (folderItem.isGroup()){ - this.$scope.folders.getFolders().forEach(function(tmpFolder: FoldersItemsMenu){ - if (tmpFolder.group && tmpFolder.group===(<FoldersItemsMenuGroup>folderItem).groupname){ - total = total + self._getTotalCounts(tmpFolder, self); - } - }); - } else { - total = total + self._getTotalCounts(folderItem, self); - } - return total; - }; - - this.$scope.getCurrentFolderDistributed = (): Array<any> => { - let self = this; - let states = []; - if (this.$scope.folders) { - let folderItem:FoldersItemsMenu = this.$scope.folders.getCurrentFolder(); - if (folderItem.isGroup()) { - this.$scope.folders.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { - if (tmpFolder.group && tmpFolder.group === (<FoldersItemsMenuGroup>folderItem).groupname) { - self._setStates(tmpFolder, states); - } - }); - } else { - self._setStates(folderItem, states); - } - } - return states; - }; - - this.$scope.setSelectedFolder = (folderItem: FoldersItemsMenu):void => { - this.$scope.folders.setSelected(folderItem); - }; - - this.$scope.goToComponent = (component:Models.Components.Component):void => { - this.$scope.isLoading=true; - this.$state.go('workspace.general', {id: component.uniqueId, type:component.componentType.toLowerCase() }); - }; - - }; - - private _getTotalCounts(tmpFolder, self): number { - let total: number = 0; - if (tmpFolder.dist !== undefined) { - let distributions = tmpFolder.dist.split(','); - distributions.forEach((item:any) => { - total = total + self.getEntitiesByStateDist(tmpFolder.state, item).length; - }); - } - else { - total = total + self.getEntitiesByStateDist(tmpFolder.state, tmpFolder.dist).length; - } - return total; - } - - private _setStates(tmpFolder, states) { - if (tmpFolder.states !== undefined) { - tmpFolder.states.forEach(function (item:any) { - states.push({"state": item.state, "dist": item.dist}); - }); - } else { - states.push({"state": tmpFolder.state, "dist": tmpFolder.dist}); - } - } - - private initEntities = (reload:boolean):void => { - this.$scope.isLoading = reload; - this.entityService.getAllComponents().then( - (components: Array<Models.Components.Component>) => { - this.components = components; - this.$scope.components = components; - this.$scope.isLoading = false; - }); - }; - - private getEntitiesByStateDist = (state: string, dist: string) : Array<Models.Components.Component> => { - let gObj:Array<Models.Components.Component>; - if (this.components && (state || dist)) { - gObj = this.components.filter(function (obj:Models.Components.Component) { - if (dist !== undefined && obj.distributionStatus === dist && obj.lifecycleState === state){ - return true; - } else if (dist === undefined && obj.lifecycleState === state) { - return true; - } - return false; - }); - } else { - gObj = []; - } - return gObj; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view.html b/catalog-ui/app/scripts/view-models/dashboard/dashboard-view.html deleted file mode 100644 index 0aef4e19c6..0000000000 --- a/catalog-ui/app/scripts/view-models/dashboard/dashboard-view.html +++ /dev/null @@ -1,106 +0,0 @@ -<div class="sdc-catalog-container"> - <loader data-display="isLoading"></loader> - - <!-- HEADER --> -<!-- - <ecomp-header menu-data="menuItems" version="{{version}}"></ecomp-header> ---> - - <div class="w-sdc-main-container"> - - <perfect-scrollbar include-padding="true" class="w-sdc-main-right-container"> - - <!-- ADD Component --> - <div ng-if="user.role === 'DESIGNER' || user.role === 'PRODUCT_MANAGER'" class="w-sdc-dashboard-card-new" - data-ng-mouseleave="displayActions = false" - data-ng-mouseover="displayActions = true" - data-ng-init="displayActions = false"> - <div class="w-sdc-dashboard-card-new-content" data-tests-id="AddButtonsArea"> - <div class="w-sdc-dashboard-card-new-content-plus" data-ng-show="!displayActions"></div> - <div class="sdc-dashboard-create-element-container" data-ng-show="displayActions"> - <button data-ng-if="roles[user.role].dashboard.showCreateNewProduct" class="tlv-btn outline blue" data-ng-click="openCreateModal('PRODUCT')">Create Product</button> - <button data-ng-if="roles[user.role].dashboard.showCreateNew" data-tests-id="createResourceButton" class="tlv-btn outline blue" data-ng-click="openCreateModal('RESOURCE')">Add VF</button> - <button data-ng-if="roles[user.role].dashboard.showCreateNew" data-tests-id="createServiceButton" class="tlv-btn outline blue" data-ng-click="openCreateModal('SERVICE')">Add Service</button> - </div> - </div> - </div> - - <!-- Import Component --> - <div ng-if="user.role === 'DESIGNER'" class="w-sdc-dashboard-card-new" - data-ng-mouseleave="displayActions = false" - data-ng-mouseover="displayActions = true" - data-ng-init="displayActions = false"> - <div class="w-sdc-dashboard-card-new-content" data-tests-id="importButtonsArea" > - <div class="w-sdc-dashboard-card-import-content-plus" data-ng-show="!displayActions"></div> - <div class="sdc-dashboard-import-element-container" data-ng-show="displayActions"> - <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue">Import VFC - <file-opener on-file-upload="onImportVfc(file)" data-tests-id="importVFCbutton" extensions="{{sdcConfig.toscaFileExtension}}" data-ng-click="displayActions=false"></file-opener> - </div> - <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue" data-ng-click="notificationIconCallback()">Import VSP</div> - <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue import-dcae">Import DCAE asset - <file-opener on-file-upload="onImportVf(file)" data-tests-id="importVFbutton" extensions="{{sdcConfig.csarFileExtension}}" data-ng-click="displayActions=false"></file-opener> - </div> - </div> - </div> - </div> - - <div - data-ng-class="{'sdc-hide-popover': hidePopover,'resource' : component.isResource(),'service' : component.isService()}" - class="w-sdc-dashboard-card" - data-ng-repeat="component in components | entityFilter:checkboxesFilter | filter:search" - > - <div class="w-sdc-dashboard-card-body" data-tests-id="dashboard-Elements" data-ng-click="goToComponent(component)"> - <!--<div class="w-sdc-dashboard-card-description">{{entity.description}}</div>--> - <div class="w-sdc-dashboard-card-avatar"><span data-tests-id="asset-type" class="{{component.getComponentSubType()}}"></span></div> - <!--<div class="w-sdc-dashboard-card-edit" data-ng-class="component.lifecycleState" data-tests-id="{{component.lifecycleState}}"></div>--> - <div class="w-sdc-dashboard-card-schema-image {{component.iconSprite}} {{component.icon}}" - data-ng-class="{'sprite-resource-icons': component.isResource(), 'sprite-services-icons': component.isService()}" - data-tests-id="{{component.name}}"></div> - <div class="w-sdc-dashboard-card-info-name-container"> - <span class="w-sdc-dashboard-card-info-name" tooltips - tooltip-content="{{component.name | resourceName}}"> {{component.name | resourceName}}</span> - </div> - </div> - <div class="w-sdc-dashboard-card-footer"> - - <div class="w-sdc-dashboard-card-info"> - <div class="w-sdc-dashboard-card-info-lifecycleState"> - <span class="w-sdc-dashboard-card-info-lifecycleState" tooltips - tooltip-content="{{component.getStatus(sdcMenu)}}"> {{component.getStatus(sdcMenu)}}</span> - </div> - <div class="w-sdc-dashboard-card-info-user"data-tests-id="{{component.name}}Version">V {{component.version}}</div> - </div> - <!--<div class="w-sdc-dashboard-card-info-lifecycleState-icon sprite-new {{sdcMenu.LifeCycleStatuses[component.lifecycleState].icon}}"></div>--> - </div> - </div> - - </perfect-scrollbar> - - <div class="w-sdc-left-sidebar"> - <div class="i-sdc-left-sidebar-item " - data-ng-repeat="folder in folders.getFolders()" - data-ng-class="{'category-title': folder.isGroup(), 'selectedLink': folder.isSelected()}" - > - <span data-ng-if="folder.isGroup()">{{folder.text}}</span> - - <sdc-checkbox data-ng-if="!folder.isGroup() && !folder.dist" - elem-id="checkbox-{{folder.text | lowercase | clearWhiteSpaces}}" - sdc-checklist-model="checkboxesFilter.selectedStatuses" - sdc-checklist-value="folder.state" - text="{{folder.text}}"></sdc-checkbox> - - <sdc-checkbox data-ng-if="!folder.isGroup() && folder.dist" - elem-id="checkbox-{{folder.text | lowercase | clearWhiteSpaces}}" - sdc-checklist-model="checkboxesFilter.distributed" - sdc-checklist-value="folder.dist" - text="{{folder.text}}"></sdc-checkbox> - <span class="i-sdc-left-sidebar-item-state-count">{{entitiesCount(folder)}}</span> - </div> - </div> - - </div> - - <top-nav top-lvl-selected-index="0" version="{{version}}" search-bind="search.filterTerm" notification-icon-callback="notificationIconCallback" version="{{version}}"></top-nav> - -</div> -<div data-ui-view=""></div> diff --git a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form-view-model.ts b/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form-view-model.ts deleted file mode 100644 index 092594b0d5..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form-view-model.ts +++ /dev/null @@ -1,354 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - - export interface IEditArtifactModel { - artifactResource: Models.ArtifactModel; - artifactTypes: Array<string>; - artifactFile: any; - } - - export interface IArtifactResourceFormViewModelScope extends ng.IScope { - forms:any; - $$childTail: any; - isNew: boolean; - isLoading: boolean; - validationPattern: RegExp; - urlValidationPattern: RegExp; - labelValidationPattern: RegExp; - integerValidationPattern: RegExp; - commentValidationPattern: RegExp; - artifactType: string; - editArtifactResourceModel: IEditArtifactModel; - defaultHeatTimeout: number; - validExtensions: any; - originalArtifactName: string; - editForm: ng.IFormController; - footerButtons: Array<any>; - modalInstanceArtifact:ng.ui.bootstrap.IModalServiceInstance; - - fileExtensions():string; - save(doNotCloseModal?:boolean): void; - saveAndAnother(): void; - close(): void; - getOptions(): Array<string>; - isDeploymentHeat(): boolean; - onFileChange(): void; - setDefaultTimeout(): void; - openEditEnvParametersModal(artifact:Models.ArtifactModel):void; - getFormTitle():string; - fileUploadRequired():string; - isArtifactOwner():boolean; - } - - export class ArtifactResourceFormViewModel { - - private artifactArr:Array<Models.ArtifactModel>; - - static '$inject' = [ - '$scope', - '$modalInstance', - 'artifact', - 'Sdc.Services.CacheService', - 'ValidationPattern', - 'UrlValidationPattern', - 'LabelValidationPattern', - 'IntegerValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - '$base64', - '$state', - 'ArtifactsUtils', - '$modal', - '$templateCache', - 'component' - ]; - - private formState:Utils.Constants.FormState; - private entityId:string; - - constructor(private $scope:IArtifactResourceFormViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private artifact:Models.ArtifactModel, - private cacheService:Services.CacheService, - private ValidationPattern:RegExp, - private UrlValidationPattern:RegExp, - private LabelValidationPattern:RegExp, - private IntegerValidationPattern : RegExp, - private CommentValidationPattern: RegExp, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private $base64:any, - private $state:any, - private artifactsUtils:Sdc.Utils.ArtifactsUtils, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private component:Models.Components.Component) { - - - this.entityId = this.component.uniqueId; - this.artifactArr = []; - this.formState = angular.isDefined(artifact.artifactLabel) ? Utils.Constants.FormState.UPDATE : Utils.Constants.FormState.CREATE; - this.initScope(); - } - - private initEntity = ():void => { - this.$scope.editArtifactResourceModel.artifactResource = this.artifact; - this.$scope.originalArtifactName = this.artifact.artifactName; - }; - - - private initFooterButtons = ():void =>{ - - this.$scope.footerButtons = [ - {'name': 'Done', 'css': 'blue', 'callback': this.$scope.save} - ]; - if (this.$scope.isNew){ - this.$scope.footerButtons.push( {'name': 'Add Another', 'css': 'grey', 'disabled': !this.$scope.isNew && 'deployment' === this.$scope.artifactType, 'callback': this.$scope.saveAndAnother}); - } - - }; - - - private initArtifactTypes = ():void => { - - let artifactTypes:any = this.cacheService.get('UIConfiguration'); - - if('deployment' === this.$scope.artifactType) { - - this.$scope.validExtensions = ('HEAT_ENV' == this.artifact.artifactType||this.component.selectedInstance)?//to remove the first condition? - artifactTypes.artifacts.deployment.resourceInstanceDeploymentArtifacts - : this.component.isResource() ? artifactTypes.artifacts.deployment.resourceDeploymentArtifacts - : artifactTypes.artifacts.deployment.serviceDeploymentArtifacts; - - if(this.$scope.validExtensions) { - this.$scope.editArtifactResourceModel.artifactTypes = Object.keys(this.$scope.validExtensions); - } - this.$scope.defaultHeatTimeout = artifactTypes.defaultHeatTimeout; - if(this.$scope.isNew) { - let isHeat='HEAT_ENV' == this.artifact.artifactType; - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { - return 'HEAT' == item.substring(0,4)||(!isHeat && item == "VF_MODULES_METADATA") || - _.has(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES, item); - }); - } - - }if (this.$scope.artifactType === 'normal') { - this.$scope.editArtifactResourceModel.artifactTypes = artifactTypes.artifacts.other.map((element:any)=> { - return element.name; - }); - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { - return _.has(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES, item) || - _.has(Utils.Constants.ArtifactType.TOSCA, item); - }) - } - - if(this.component.isResource() && (<Resource>this.component).isCsarComponent()) { - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string) => { - return this.artifactsUtils.isLicenseType(item); - }) - } - - }; - - private initEditArtifactResourceModel = ():void => { - this.$scope.editArtifactResourceModel = { - artifactResource: null, - artifactTypes: null, - artifactFile:{} - }; - - this.initEntity(); - }; - - private initScope = ():void => { - - this.$scope.validationPattern = this.ValidationPattern; - this.$scope.urlValidationPattern = this.UrlValidationPattern; - this.$scope.labelValidationPattern = this.LabelValidationPattern; - this.$scope.integerValidationPattern = this.IntegerValidationPattern; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - this.$scope.isLoading = false; - this.$scope.isNew = (this.formState === Utils.Constants.FormState.CREATE); - this.$scope.artifactType = this.artifactsUtils.getArtifactTypeByState(this.$state.current.name); - this.$scope.modalInstanceArtifact = this.$modalInstance; - - this.initEditArtifactResourceModel(); - this.initArtifactTypes(); - - // In case of edit, show the file name in browse. - if (this.artifact.artifactName!=="" && 'HEAT_ENV'!==this.artifact.artifactType){ - this.$scope.editArtifactResourceModel.artifactFile = {}; - this.$scope.editArtifactResourceModel.artifactFile.filename = this.artifact.artifactName; - } - - //scope methods - this.$scope.isDeploymentHeat = ():boolean => { - return !this.$scope.isNew && this.$scope.artifactType === 'deployment' && - 'HEAT' === this.$scope.editArtifactResourceModel.artifactResource.artifactType.substring(0,4); - }; - this.$scope.onFileChange = ():void => { - if(this.$scope.editArtifactResourceModel.artifactFile && this.$scope.editArtifactResourceModel.artifactFile.filename) { - this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; - } else { - this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.originalArtifactName; - } - }; - this.$scope.setDefaultTimeout = ():void => { - if(this.$scope.isDeploymentHeat() && !this.$scope.editArtifactResourceModel.artifactResource.timeout) { - this.$scope.editArtifactResourceModel.artifactResource.timeout = this.$scope.defaultHeatTimeout; - } - }; - - this.$scope.fileExtensions = ():string => { - let type:string = this.$scope.editArtifactResourceModel.artifactResource.artifactType; - return type && this.$scope.validExtensions && this.$scope.validExtensions[type].acceptedTypes ? - this.$scope.validExtensions[type].acceptedTypes.join(',') : ""; - }; - - this.$scope.save = (doNotCloseModal?:boolean):void => { - this.$scope.isLoading = true; - this.$scope.editArtifactResourceModel.artifactResource.description = this.ValidationUtils.stripAndSanitize(this.$scope.editArtifactResourceModel.artifactResource.description); - - if (!this.$scope.isDeploymentHeat()) { - this.$scope.editArtifactResourceModel.artifactResource.timeout = null; - } - - if (this.$scope.editArtifactResourceModel.artifactFile) { - this.$scope.editArtifactResourceModel.artifactResource.payloadData = this.$scope.editArtifactResourceModel.artifactFile.base64; - this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; - } - - let onFaild = (response):void => { - this.$scope.isLoading = false; - console.info('onFaild', response); - }; - - let onSuccess = (artifactResource:Models.ArtifactModel):void => { - this.$scope.isLoading = false; - this.$scope.originalArtifactName = ""; - - if(this.$scope.isDeploymentHeat()){ - if(artifactResource.heatParameters) { - this.$scope.openEditEnvParametersModal(artifactResource); - } - } - - if (!doNotCloseModal) { - this.$modalInstance.close(); - //this.artifactArr = []; - } else { - this.$scope.editArtifactResourceModel.artifactFile = null; - angular.element("input[type='file']").val(null); // for support chrome when upload the same file - this.artifactsUtils.addAnotherAfterSave(this.$scope); - } - - }; - - if('HEAT_ENV' == this.artifact.artifactType){ - this.component.uploadInstanceEnvFile(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); - }else if(this.$scope.isArtifactOwner()){ - this.component.addOrUpdateInstanceArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); - }else { - this.component.addOrUpdateArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); - } - }; - - this.$scope.isArtifactOwner = ():boolean=> { - return this.component.isService() && !!this.component.selectedInstance; - }; - - this.$scope.saveAndAnother = ():void => { - this.$scope.save(true); - }; - - this.$scope.close = ():void => { - this.$modalInstance.close(); - this.artifactArr = []; - }; - - this.$scope.fileUploadRequired = ():string => { - if (this.$scope.editArtifactResourceModel.artifactFile.filename){ - // This is edit mode - return 'false'; - } else { - return 'true'; - } - }; - - this.$scope.getFormTitle =(): string =>{ - if('HEAT_ENV' == this.artifact.artifactType){ - return 'Update HEAT ENV'; - } - if(this.$scope.isDeploymentHeat()){ - if(!this.$scope.editArtifactResourceModel.artifactResource.artifactChecksum){ - return 'Add HEAT Template'; - } - return 'Update HEAT Template'; - } - if(this.$scope.isNew){ - return 'Add Artifact'; - } - return 'Update Artifact'; - }; - - this.$scope.openEditEnvParametersModal = (artifactResource:Models.ArtifactModel):void => { - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.html'), - controller: 'Sdc.ViewModels.EnvParametersFormViewModel', - size: 'sdc-md', - backdrop: 'static', - resolve: { - artifact: ():Models.ArtifactModel => { - return artifactResource; - }, - component: ():Models.Components.Component => { - return this.component; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - modalInstance - .result - .then(():void => { - }); - }; - - this.$scope.forms = {}; - - this.initFooterButtons(); - - - this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - if(this.$scope.isNew){ - this.$scope.footerButtons[1].disabled = this.$scope.forms.editForm.$invalid; - } - }); - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/forms/attribute-form/attribute-from-view-model.ts b/catalog-ui/app/scripts/view-models/forms/attribute-form/attribute-from-view-model.ts deleted file mode 100644 index d369cfa5d1..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/attribute-form/attribute-from-view-model.ts +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - export interface IEditAttributeModel { - attribute: Models.AttributeModel; - types: Array<string>; - simpleTypes: Array<string>; - } - - interface IAttributeFormViewModelScope extends ng.IScope { - $$childTail: any; - forms:any; - editForm:ng.IFormController; - footerButtons: Array<any>; - isService: boolean; - editAttributeModel: IEditAttributeModel; - modalInstanceAttribute:ng.ui.bootstrap.IModalServiceInstance; - isNew: boolean; - listRegex: Sdc.Utils.IMapRegex; - mapRegex: Sdc.Utils.IMapRegex; - propertyNameValidationPattern: RegExp; - commentValidationPattern: RegExp; - isLoading: boolean; - validationPattern: RegExp; - - save():void; - close(): void; - onTypeChange():void; - onValueChange(): void; - isAttributeValueOwner():boolean; - validateIntRange(value:string):boolean; - validateUniqueKeys(viewValue:string):boolean; - getValidationTranslate(): string; - showSchema(): boolean; - isSchemaEditable(): boolean; - validateName():void; - } - - export class AttributeFormViewModel { - - static '$inject' = [ - '$scope', - '$modalInstance', - 'attribute', - 'ValidationUtils', - 'CommentValidationPattern', - 'PropertyNameValidationPattern', - 'component' - ]; - - private formState: Sdc.Utils.Constants.FormState; - - - constructor(private $scope:IAttributeFormViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private attribute: Models.AttributeModel, - private ValidationUtils:Sdc.Utils.ValidationUtils, - private CommentValidationPattern:RegExp, - private PropertyNameValidationPattern: RegExp, - private component: Models.Components.Component) { - this.formState = angular.isDefined(attribute.name) ? Utils.Constants.FormState.UPDATE : Utils.Constants.FormState.CREATE; - this.initScope(); - } - - private initResource = ():void => { - this.$scope.editAttributeModel.attribute = new Sdc.Models.AttributeModel(this.attribute); - if (this.$scope.editAttributeModel.types.indexOf(this.attribute.type) === -1) {//attribute defaulte type is string too? - this.attribute.type = "string"; - } - }; - - private initEditAttributeModel = ():void => { - this.$scope.editAttributeModel = { - attribute: null, - types: ['integer', 'string', 'float', 'boolean', 'list', 'map'], - simpleTypes: ['integer', 'string', 'float', 'boolean'] - }; - - this.initResource(); - }; - - private initScope = ():void => { - - //scope attributes - this.$scope.forms = {}; - this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - - this.$scope.modalInstanceAttribute = this.$modalInstance; - this.$scope.listRegex = this.ValidationUtils.getPropertyListPatterns(); - this.$scope.mapRegex = this.ValidationUtils.getPropertyMapPatterns(); - - this.$scope.isNew = (this.formState === Utils.Constants.FormState.CREATE); - this.$scope.isLoading = false; - - this.initEditAttributeModel(); - this.setValidationPattern(); - - //scope methods - this.$scope.save = ():void => { - if(!this.$scope.forms.editForm.$invalid){ - let attribute:Models.AttributeModel = this.$scope.editAttributeModel.attribute; - this.$scope.editAttributeModel.attribute.description = this.ValidationUtils.stripAndSanitize(this.$scope.editAttributeModel.attribute.description); - ////if read only - just closes the modal - if (this.$scope.editAttributeModel.attribute.readonly && !this.$scope.isAttributeValueOwner()) { - this.$modalInstance.close(); - return; - } - this.$scope.isLoading = true; - let onAttributeFaild = (response):void => { - console.info('onFaild', response); - this.$scope.isLoading = false; - }; - - let onAttributeSuccess = (attributeFromBE:Models.AttributeModel):void => { - console.info('onAttributeResourceSuccess : ', attributeFromBE); - this.$scope.isLoading = false; - this.$modalInstance.close(); - }; - - //in case we have uniqueId we call update method - if (this.$scope.isAttributeValueOwner()) { - this.component.updateInstanceAttribute(attribute).then(onAttributeSuccess, onAttributeFaild); - } else { - this.component.addOrUpdateAttribute(attribute).then(onAttributeSuccess, onAttributeFaild); - } - } - }; - - this.$scope.close = ():void => { - this.$modalInstance.close(); - }; - - this.$scope.validateName = ():void => { - let existsAttr: Models.AttributeModel = _.find(this.component.attributes, (attribute:Models.AttributeModel) => { - return attribute.name === this.$scope.editAttributeModel.attribute.name; - }); - if(existsAttr){ - this.$scope.forms.editForm["attributeName"].$setValidity('nameExist', false); - }else{ - this.$scope.forms.editForm["attributeName"].$setValidity('nameExist', true); - } - - }; - - this.$scope.onTypeChange = ():void => { - this.$scope.editAttributeModel.attribute.value = ''; - this.$scope.editAttributeModel.attribute.defaultValue = ''; - this.setValidationPattern(); - }; - - this.$scope.isAttributeValueOwner = ():boolean=> { - return this.component.isService() || !!this.component.selectedInstance; - }; - - this.$scope.onValueChange = ():void => { - if (!this.$scope.editAttributeModel.attribute.value) { - if (this.$scope.isAttributeValueOwner()) { - this.$scope.editAttributeModel.attribute.value = this.$scope.editAttributeModel.attribute.defaultValue; - } - } - }; - - - this.$scope.validateUniqueKeys = (viewValue:string) : boolean => { - if(this.$scope.editAttributeModel.attribute.type === 'map') { - return this.ValidationUtils.validateUniqueKeys(viewValue); - } - else { - return true; //always valid if not a map - } - }; - - this.$scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - this.$scope.isSchemaEditable = () :boolean => { - let schemaType=this.$scope.editAttributeModel.attribute.schema.property.type; - return this.$scope.editAttributeModel.simpleTypes.indexOf(schemaType) > -1||!schemaType; - }; - - this.$scope.showSchema = () :boolean => { - return ['list', 'map'].indexOf(this.$scope.editAttributeModel.attribute.type) > -1; - }; - - this.$scope.getValidationTranslate = () : string => { - let result = "ATTRIBUTE_EDIT_PATTERN"; - if (this.$scope.showSchema()) { - - result = "ATTRIBUTE_EDIT_" + this.$scope.editAttributeModel.attribute.type.toUpperCase(); - - if(this.$scope.editAttributeModel.attribute.schema.property.type === Utils.Constants.PROPERTY_TYPES.STRING) { - result += "_STRING"; - }else if(this.$scope.editAttributeModel.attribute.schema.property.type === Utils.Constants.PROPERTY_TYPES.BOOLEAN) { - result += "_BOOLEAN"; - } else { - result += "_GENERIC"; - } - } - - return result; - }; - - // Add the done button at the footer. - this.$scope.footerButtons = [ - {'name': 'Done', 'css':'blue', 'callback': this.$scope.save}, - {'name':'Cancel', 'css':'grey', 'callback': this.$scope.close} - ]; - - this.$scope.$watchCollection("forms.editForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - }); - - } - - - private setValidationPattern = ():void => { - - if(this.$scope.editAttributeModel.attribute.type === 'list') { - this.$scope.validationPattern = this.$scope.listRegex[this.$scope.editAttributeModel.attribute.schema.property.type]; - } - else if(this.$scope.editAttributeModel.attribute.type === 'map') { - this.$scope.validationPattern = this.$scope.mapRegex[this.$scope.editAttributeModel.attribute.schema.property.type]; - } - else{ - this.$scope.validationPattern = this.ValidationUtils.getValidationPattern(this.$scope.editAttributeModel.attribute.type); - } - - }; - - - } -} diff --git a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.html b/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.html deleted file mode 100644 index 69367dc68c..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.html +++ /dev/null @@ -1,39 +0,0 @@ -<sdc-modal modal="envParametersModal" type="classic" class="sdc-env-form-container" buttons="saveButton" header="{{isInstance()?'HEAT Template':'Update Parameters'}}" show-close-button="true"> - <div class="sdc-env-form-container"> - <div class="w-sdc-modal-body"> - <span class="w-sdc-modal-body-content" data-ng-if="!isInstance()" translate="UPDATE_PARAMETERS_TEXT"></span> - <form novalidate class="" name="editForm"> - <perfect-scrollbar class="perfect-scrollbar w-sdc-form w-sdc-env-form-container"> - <div class="i-sdc-form-item" data-ng-repeat="parameter in heatParameters track by $index"> - <div class="left-column-container"> - <ng-form name="editForm"> - <label class="i-sdc-env-form-label" data-ng-class="{required:parameter.defaultValue}" - data-ng-bind="parameter.name +' (' + parameter.type + ')'" tooltips tooltip-content="{{parameter.name +' (' + parameter.type + ')'}}"></label> - <input class="i-sdc-form-input" data-ng-class="{error:(editForm.currentValue.$invalid)}" - data-ng-model-options="{ debounce: 200 }" - data-ng-model="parameter.currentValue" - type="text" - name="currentValue" - data-ng-pattern="getValidationPattern(parameter.type, 'heat')" - data-ng-required="parameter.defaultValue" - data-ng-change="'json'==parameter.type && editForm.currentValue.$setValidity('pattern', validateJson(parameter.currentValue))" - data-ng-blur="(editForm.currentValue.$error.required && (parameter.currentValue=parameter.defaultValue))" - /> - - <div class="input-error" data-ng-show="editForm.currentValue.$invalid"> - <span ng-show="editForm.currentValue.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> - <span ng-show="editForm.currentValue.$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="editForm.currentValue.$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> - </div> - </ng-form> - </div> - <div class="i-sdc-env-form-label-description"> - <label class="i-sdc-env-form-label" data-ng-bind="parameter.description" tooltips tooltip-content="{{parameter.description}}"></label> - </div> - </div> - </perfect-scrollbar> - <div class="env-file-generation-label" data-ng-if="isInstance()" translate="ENV_FILE_GENERATION"></div> - </form> - </div> - </div> -</sdc-modal> diff --git a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.less b/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.less deleted file mode 100644 index c58c94ab22..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.less +++ /dev/null @@ -1,74 +0,0 @@ - -.sdc-env-form-container{ - .w-sdc-modal-body{ - padding: 20px 10px 2px 10px; - } - .w-sdc-modal-body-content{ - .b_6; - display: block; - } - - .env-file-generation-label{ - .p_9; - .bold; - margin-bottom: 20px; - } -} - -.w-sdc-env-form-container { - border-top: 1px solid #cdcdcd; - border-bottom: 1px solid #cdcdcd; - height: 356px; - margin: 35px 0 10px 0; - - .w-sdc-form { - text-align: left; - } - .i-sdc-form-item{ - display: inline-block; - .description{ - margin-bottom: 2px; - vertical-align: baseline; - padding: 32px 0 0 0; - text-transform: capitalize; - .b_1; - } - } - .left-column-container{ - width: 250px; - float: left; - .i-sdc-env-form-label { - overflow: hidden; - max-width: 100%; - text-overflow: ellipsis; - display: inline-block; - white-space: nowrap; - - &.required::before { - color: #f33; - content: '*'; - margin-right: 4px; - } - } - } - .i-sdc-env-form-label-description { - float: right; - - .i-sdc-env-form-label { - .p_9; - // height: 20px; - margin: 30px 0px 0px 30px; - overflow: hidden; - max-width: 245px; - text-overflow: ellipsis; - display: inline-block; - white-space: nowrap; - - &.required::before { - color: #f33; - content: '*'; - margin-right: 4px; - } - } - } -} diff --git a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.ts b/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.ts deleted file mode 100644 index d1bae440cc..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.ts +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - export interface IEnvParametersFormViewModelScope extends ng.IScope { - isLoading: boolean; - type:string; - heatParameters:any; - editForm:ng.IFormController; - artifactResource:Models.ArtifactModel; - saveButton: Array<any>; - envParametersModal: ng.ui.bootstrap.IModalServiceInstance; - - getValidationPattern(type:string):RegExp; - isInstance():boolean; - validateJson(json:string):boolean; - close(): void; - save():void; - } - - export class EnvParametersFormViewModel { - - - static '$inject' = [ - '$scope', - '$state', - '$modalInstance', - 'artifact', - // 'ArtifactsUtils', - 'ValidationUtils', - 'component' - ]; - - - constructor(private $scope:IEnvParametersFormViewModelScope, - private $state:any, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private artifact:Models.ArtifactModel, - // private artifactsUtils:Sdc.Utils.ArtifactsUtils, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private component:Models.Components.Component) { - - - this.initScope(); - } - - private updateInstanceHeat = ():void => { - let success =(responseArtifact:Models.ArtifactModel): void => { - this.$scope.isLoading = false; - this.$modalInstance.close(); - }; - - let error = ():void => { - this.$scope.isLoading = false; - console.info('Failed to load save artifact'); - }; - - this.component.addOrUpdateInstanceArtifact(this.$scope.artifactResource).then(success, error); - - }; - - private initScope = ():void => { - this.$scope.envParametersModal = this.$modalInstance; - this.$scope.artifactResource= this.artifact; - this.$scope.heatParameters = angular.copy(this.artifact.heatParameters); - - this.$scope.getValidationPattern = (validationType:string , parameterType?:string):RegExp => { - return this.ValidationUtils.getValidationPattern(validationType, parameterType); - }; - - this.$scope.validateJson = (json:string):boolean => { - if(!json){ - return true; - } - return this.ValidationUtils.validateJson(json); - }; - - this.$scope.isInstance =(): boolean =>{ - return !!this.component.selectedInstance; - }; - - - this.$scope.save = ():void => { - this.$scope.isLoading = true; - this.artifact.heatParameters = this.$scope.heatParameters; - this.artifact.heatParameters.forEach((parameter:any):void => { - /* if ("" === parameter.currentValue) { - parameter.currentValue = null; - }else */ - if(!parameter.currentValue && parameter.defaultValue) { - parameter.currentValue = parameter.defaultValue; - } - }); - - if(this.$scope.isInstance()){ - this.updateInstanceHeat(); - return; - } - - let success =(responseArtifact:Models.ArtifactModel): void => { - this.$scope.isLoading = false; - this.$modalInstance.close(); - - }; - - let error = ():void => { - this.$scope.isLoading = false; - console.info('Failed to load save artifact'); - }; - - this.component.addOrUpdateArtifact(this.$scope.artifactResource).then(success, error); - }; - - this.$scope.saveButton = [ - {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save} - ]; - - this.$scope.close = ():void => { - //this.artifact.heatParameters.forEach((parameter:any):void => { - // if (!parameter.currentValue && parameter.defaultValue) { - // parameter.currentValue = parameter.defaultValue; - // } - //}); - this.$modalInstance.dismiss(); - }; - - }; - } -} diff --git a/catalog-ui/app/scripts/view-models/forms/property-form/property-form-view-model.ts b/catalog-ui/app/scripts/view-models/forms/property-form/property-form-view-model.ts deleted file mode 100644 index c9732aa9a6..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/property-form/property-form-view-model.ts +++ /dev/null @@ -1,330 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - export interface IEditPropertyModel { - property: Models.PropertyModel; - types: Array<string>; - simpleTypes: Array<string>; - sources: Array<string>; - } - - interface IPropertyFormViewModelScope extends ng.IScope { - forms:any; - editForm:ng.IFormController; - footerButtons: Array<any>; - isNew: boolean; - isLoading: boolean; - isService: boolean; - validationPattern: RegExp; - propertyNameValidationPattern: RegExp; - commentValidationPattern: RegExp; - editPropertyModel: IEditPropertyModel; - modalInstanceProperty:ng.ui.bootstrap.IModalServiceInstance; - currentPropertyIndex:number; - isLastProperty:boolean; - myValue:any; - nonPrimitiveTypes:Array<string>; - dataTypes:Models.DataTypesMap; - isTypeDataType:boolean; - maxLength:number; - - save(doNotCloseModal?:boolean): void; - getValidationPattern(type:string): RegExp; - validateIntRange(value:string):boolean; - close(): void; - onValueChange(): void; - onSchemaTypeChange():void; - onTypeChange(resetSchema:boolean): void; - isPropertyValueOwner():boolean; - showSchema(): boolean; - delete(property:Models.PropertyModel): void; - getPrev(): void; - getNext(): void; - isSimpleType(typeName:string):boolean; - getDefaultValue():any; - } - - export class PropertyFormViewModel { - - static '$inject' = [ - '$scope', - 'Sdc.Services.DataTypesService', - '$modalInstance', - 'property', - 'ValidationPattern', - 'PropertyNameValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - 'component', - '$filter', - 'ModalsHandler', - 'filteredProperties', - '$timeout' - ]; - - private formState: Sdc.Utils.Constants.FormState; - - constructor(private $scope:IPropertyFormViewModelScope, - private DataTypesService:Sdc.Services.DataTypesService, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private property: Models.PropertyModel, - private ValidationPattern:RegExp, - private PropertyNameValidationPattern: RegExp, - private CommentValidationPattern:RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils, - private component: Models.Components.Component, - private $filter:ng.IFilterService, - private ModalsHandler:Utils.ModalsHandler, - private filteredProperties: Array<Models.PropertyModel>, - private $timeout: ng.ITimeoutService) { - - this.formState = angular.isDefined(property.name) ? Utils.Constants.FormState.UPDATE : Utils.Constants.FormState.CREATE; - this.initScope(); - } - - private initResource = ():void => { - this.$scope.editPropertyModel.property = new Sdc.Models.PropertyModel(this.property); - this.$scope.editPropertyModel.property.type = this.property.type? this.property.type: null; - this.setMaxLength(); - // if (this.$scope.editPropertyModel.types.indexOf(this.property.type) === -1 && !this.$scope.isNew) { - // this.property.type = "string"; - // } - }; - - private initEditPropertyModel = ():void => { - this.$scope.editPropertyModel = { - property: null, - types: Utils.Constants.PROPERTY_DATA.TYPES, - simpleTypes: Utils.Constants.PROPERTY_DATA.SIMPLE_TYPES, - sources: Utils.Constants.PROPERTY_DATA.SOURCES - }; - - this.initResource(); - }; - - private initForNotSimpleType = ():void => { - let property = this.$scope.editPropertyModel.property; - this.$scope.isTypeDataType=this.DataTypesService.isDataTypeForPropertyType(this.$scope.editPropertyModel.property,this.$scope.dataTypes); - if(property.type && this.$scope.editPropertyModel.simpleTypes.indexOf(property.type)==-1){ - if(!(property.value||property.defaultValue)) { - switch (property.type) { - case Utils.Constants.PROPERTY_TYPES.MAP: - this.$scope.myValue = {'':null}; - break; - case Utils.Constants.PROPERTY_TYPES.LIST: - this.$scope.myValue = []; - break; - default: - this.$scope.myValue = {}; - } - }else{ - this.$scope.myValue = JSON.parse(property.value||property.defaultValue); - } - } - }; - - private setMaxLength = ():void => { - switch (this.$scope.editPropertyModel.property.type) { - case Utils.Constants.PROPERTY_TYPES.MAP: - case Utils.Constants.PROPERTY_TYPES.LIST: - this.$scope.maxLength = this.$scope.editPropertyModel.property.schema.property.type == Utils.Constants.PROPERTY_TYPES.JSON? - Utils.Constants.PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH: - Utils.Constants.PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; - break; - case Utils.Constants.PROPERTY_TYPES.JSON: - this.$scope.maxLength = Utils.Constants.PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH; - break; - default: - this.$scope.maxLength = Utils.Constants.PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; - } - }; - - - private initScope = ():void => { - - //scope properties - this.$scope.forms = {}; - this.$scope.validationPattern = this.ValidationPattern; - this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - this.$scope.isLoading = false; - this.$scope.isNew = (this.formState === Utils.Constants.FormState.CREATE); - this.$scope.isService = this.component.isService(); - this.$scope.modalInstanceProperty = this.$modalInstance; - this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, i=> i.name == this.property.name ); - this.$scope.isLastProperty= this.$scope.currentPropertyIndex==(this.filteredProperties.length-1); - - this.initEditPropertyModel(); - - this.DataTypesService.getAllDataTypes().then((response:any) => { - this.$scope.dataTypes = response; - delete response['tosca.datatypes.Root']; - this.$scope.nonPrimitiveTypes =_.filter(Object.keys(response),(type:string)=>{ - return this.$scope.editPropertyModel.types.indexOf(type)==-1; - }); - this.initForNotSimpleType(); - }, (err)=> {}); - - - - - - //scope methods - this.$scope.save = (doNotCloseModal?:boolean):void => { - let property:Models.PropertyModel = this.$scope.editPropertyModel.property; - this.$scope.editPropertyModel.property.description = this.ValidationUtils.stripAndSanitize(this.$scope.editPropertyModel.property.description); - ////if read only - just closes the modal - if (this.$scope.editPropertyModel.property.readonly && !this.$scope.isPropertyValueOwner()) { - this.$modalInstance.close(); - return; - } - - this.$scope.isLoading = true; - - let onPropertyFaild = (response):void => { - console.info('onFaild', response); - this.$scope.isLoading = false; - }; - - let onPropertySuccess = (propertyFromBE:Models.PropertyModel):void => { - console.info('onPropertyResourceSuccess : ', propertyFromBE); - this.$scope.isLoading = false; - - if (!doNotCloseModal) { - this.$modalInstance.close(); - } else { - this.$scope.forms.editForm.$setPristine(); - this.$scope.editPropertyModel.property = new Models.PropertyModel(); - } - }; - - //in case we have uniqueId we call update method - if (this.$scope.isPropertyValueOwner()) { - if(!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)){ - let myValueString:string = JSON.stringify(this.$scope.myValue); - property.value = myValueString; - } - this.component.updateInstanceProperty(property).then(onPropertySuccess, onPropertyFaild); - } else { - if(!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)){ - let myValueString:string = JSON.stringify(this.$scope.myValue); - property.defaultValue = myValueString; - }else{ - this.$scope.editPropertyModel.property.defaultValue = this.$scope.editPropertyModel.property.value; - } - this.component.addOrUpdateProperty(property).then(onPropertySuccess, onPropertyFaild); - } - }; - - - this.$scope.isPropertyValueOwner = ():boolean=> { - return this.component.isService() || !!this.component.selectedInstance; - }; - - this.$scope.getPrev = ():void=> { - this.property = this.filteredProperties[--this.$scope.currentPropertyIndex]; - this.initResource(); - this.initForNotSimpleType(); - this.$scope.isLastProperty=false; - }; - - this.$scope.getNext = ():void=> { - this.property = this.filteredProperties[++this.$scope.currentPropertyIndex]; - this.initResource(); - this.initForNotSimpleType(); - this.$scope.isLastProperty= this.$scope.currentPropertyIndex==(this.filteredProperties.length-1); - }; - - this.$scope.isSimpleType = (typeName:string):boolean=>{ - return typeName && this.$scope.editPropertyModel.simpleTypes.indexOf(typeName)!=-1; - }; - - this.$scope.showSchema = () :boolean => { - return [Utils.Constants.PROPERTY_TYPES.LIST, Utils.Constants.PROPERTY_TYPES.MAP].indexOf(this.$scope.editPropertyModel.property.type) > -1; - }; - - this.$scope.getValidationPattern = (type:string):RegExp => { - return this.ValidationUtils.getValidationPattern(type); - }; - - this.$scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - this.$scope.close = ():void => { - this.$modalInstance.close(); - }; - - // put default value when instance value is empty - this.$scope.onValueChange = ():void => { - if (!this.$scope.editPropertyModel.property.value) { - if (this.$scope.isPropertyValueOwner()) { - this.$scope.editPropertyModel.property.value = this.$scope.editPropertyModel.property.defaultValue; - } - } - }; - - // Add the done button at the footer. - this.$scope.footerButtons = [ - {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save }, - {'name': 'Cancel', 'css': 'grey', 'callback':this.$scope.close } - ]; - - this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - }); - - this.$scope.getDefaultValue = ():any => { - return this.$scope.isPropertyValueOwner() ? this.$scope.editPropertyModel.property.defaultValue : null; - }; - - this.$scope.onTypeChange = ():void => { - this.$scope.editPropertyModel.property.value = ''; - this.$scope.editPropertyModel.property.defaultValue = ''; - this.setMaxLength(); - this.initForNotSimpleType(); - }; - - this.$scope.onSchemaTypeChange = ():void => { - if(this.$scope.editPropertyModel.property.type==Utils.Constants.PROPERTY_TYPES.MAP){ - this.$scope.myValue={'':null}; - }else if(this.$scope.editPropertyModel.property.type==Utils.Constants.PROPERTY_TYPES.LIST){ - this.$scope.myValue=[]; - } - this.setMaxLength(); - }; - - this.$scope.delete = (property:Models.PropertyModel):void => { - let onOk = ():void => { - this.component.deleteProperty(property.uniqueId).then( - this.$scope.close - ); - }; - let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts b/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts deleted file mode 100644 index b69bf4a2a6..0000000000 --- a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - interface IResourceInstanceViewModelScope extends ng.IScope { - - componentInstanceModel: Sdc.Models.ComponentsInstances.ComponentInstance; - validationPattern: RegExp; - oldName:string; - isAlreadyPressed:boolean; - footerButtons: Array<any>; - forms:any; - modalInstanceName:ng.ui.bootstrap.IModalServiceInstance; - - save(): void; - close(): void; - } - - export class ResourceInstanceNameViewModel { - - static '$inject' = [ - '$scope', - 'ValidationPattern', - '$modalInstance', - 'ComponentInstanceFactory', - 'component' - ]; - - - constructor(private $scope:IResourceInstanceViewModelScope, - private ValidationPattern:RegExp, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private ComponentInstanceFactory:Utils.ComponentInstanceFactory, - private component:Models.Components.Component) { - - this.initScope(); - } - - - private initScope = ():void => { - this.$scope.forms = {}; - this.$scope.validationPattern = this.ValidationPattern; - this.$scope.componentInstanceModel = Utils.ComponentInstanceFactory.createComponentInstance(this.component.selectedInstance); - this.$scope.oldName = this.component.selectedInstance.name; - this.$scope.modalInstanceName = this.$modalInstance; - - this.$scope.isAlreadyPressed = false; - - - this.$scope.close = ():void => { - this.$modalInstance.dismiss(); - }; - - this.$scope.save = ():void => { - - let onFailed = () => { - this.$scope.isAlreadyPressed = true; - }; - - let onSuccess = (componentInstance:Models.ComponentsInstances.ComponentInstance) => { - this.$modalInstance.close(); - this.$scope.isAlreadyPressed = false; - this.$scope.componentInstanceModel = componentInstance; - //this.component.name = componentInstance.name;//DE219124 - this.component.selectedInstance.name = componentInstance.name; - - }; - - this.$scope.isAlreadyPressed = true; - if (this.$scope.oldName != this.$scope.componentInstanceModel.name) { - this.component.updateComponentInstance(this.$scope.componentInstanceModel).then(onSuccess, onFailed); - } - }; - - this.$scope.footerButtons = [ - {'name': 'OK', 'css': 'blue', 'callback': this.$scope.save, 'disabled': (!this.$scope.componentInstanceModel.name || this.$scope.componentInstanceModel.name === this.$scope.oldName) || this.$scope.isAlreadyPressed}, - {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} - ]; - - this.$scope.$watch("forms.editNameForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editNameForm.$invalid; - }); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts b/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts deleted file mode 100644 index f906593d8a..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IConfirmationModalModel { - title: string; - message: string; - showComment: boolean; - type: Utils.Constants.ModalType; - } - - interface IConfirmationModalViewModelScope { - modalInstanceConfirmation:ng.ui.bootstrap.IModalServiceInstance; - confirmationModalModel: IConfirmationModalModel; - comment: any; - commentValidationPattern:RegExp; - editForm:ng.IFormController; - okButtonColor: string; - hideCancelButton: boolean; - ok(): any; - cancel(): void; - } - - export class ConfirmationModalViewModel { - - static '$inject' = ['$scope', '$modalInstance', 'confirmationModalModel', 'CommentValidationPattern', 'ValidationUtils', '$templateCache', '$modal']; - - constructor(private $scope:IConfirmationModalViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - confirmationModalModel:IConfirmationModalModel, - private CommentValidationPattern: RegExp, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private $templateCache:ng.ITemplateCacheService, - private $modal:ng.ui.bootstrap.IModalService) { - - this.initScope(confirmationModalModel); - } - - private initScope = (confirmationModalModel:IConfirmationModalModel):void => { - let self = this; - this.$scope.hideCancelButton = false; - this.$scope.modalInstanceConfirmation = this.$modalInstance; - this.$scope.confirmationModalModel = confirmationModalModel; - this.$scope.comment = {"text": ''}; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - - this.$scope.ok = ():any => { - self.$modalInstance.close(this.ValidationUtils.stripAndSanitize(self.$scope.comment.text)); - }; - - this.$scope.cancel = ():void => { - console.info('Cancel pressed on: ' + this.$scope.confirmationModalModel.title); - self.$modalInstance.dismiss(); - }; - - // Set the OK button color according to modal type (standard, error, alert) - let _okButtonColor = 'blue'; // Default - switch (confirmationModalModel.type) { - case Sdc.Utils.Constants.ModalType.STANDARD: - _okButtonColor='blue'; - break; - case Sdc.Utils.Constants.ModalType.ERROR: - _okButtonColor='red'; - break; - case Sdc.Utils.Constants.ModalType.ALERT: - this.$scope.hideCancelButton = true; - _okButtonColor='grey'; - break; - default: - _okButtonColor='blue'; - break; - } - this.$scope.okButtonColor = _okButtonColor; - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal-view-model.ts b/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal-view-model.ts deleted file mode 100644 index 6430a955a6..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal-view-model.ts +++ /dev/null @@ -1,117 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IEmailModalModel_Email { - to: string; - subject: string; - message: string; - } - - export interface IEmailModalModel_Data { - component: Models.Components.Component; - stateUrl: string; - } - - export interface IEmailModalModel { - title: string; - email: IEmailModalModel_Email; - data: IEmailModalModel_Data; - } - - interface IEmailModalViewModelScope { - modalInstanceEmail:ng.ui.bootstrap.IModalServiceInstance; - emailModalModel: IEmailModalModel; - submitInProgress:boolean; - commentValidationPattern:RegExp; - isLoading:boolean; - submit(): any; - cancel(): void; - validateField(field:any):boolean; - } - - export class EmailModalViewModel { - - static '$inject' = ['$scope', '$filter', 'sdcConfig', '$modalInstance', 'emailModalModel', 'ValidationUtils', 'CommentValidationPattern']; - - constructor(private $scope:IEmailModalViewModelScope, - private $filter:ng.IFilterService, - private sdcConfig:Models.IAppConfigurtaion, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private emailModalModel:IEmailModalModel, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private CommentValidationPattern: RegExp) { - - this.initScope(emailModalModel); - } - - private initScope = (emailModalModel:IEmailModalModel):void => { - this.$scope.emailModalModel = emailModalModel; - this.$scope.submitInProgress=false; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - this.$scope.modalInstanceEmail = this.$modalInstance; - - this.$scope.submit = ():any => { - - let onSuccess = (component:Models.Components.Component) => { - this.$scope.isLoading = false; - this.$scope.submitInProgress=false; - let link:string = encodeURI(this.sdcConfig.api.baseUrl + "?folder=Ready_For_Testing"); - let outlook:string = this.$filter('translate')("EMAIL_OUTLOOK_MESSAGE", "{'to': '" + emailModalModel.email.to + "','subject': '" + emailModalModel.email.subject + "','message': '" + emailModalModel.email.message + "', 'entityNameAndVersion': '" + emailModalModel.email.subject + "','link': '" + link + "'}"); - if(!this.sdcConfig.openSource) { - window.location.href=outlook; // Open outlook with the email to send - } - this.$modalInstance.close(component); // Close the dialog - }; - - let onError = () => { - this.$scope.isLoading = false; - this.$scope.submitInProgress=false; - this.$modalInstance.close(); // Close the dialog - }; - - // Submit to server - // Prevent from user pressing multiple times on submit. - if (this.$scope.submitInProgress===false) { - this.$scope.isLoading = true; - this.$scope.submitInProgress = true; - let comment:Models.AsdcComment = new Models.AsdcComment(); - comment.userRemarks = emailModalModel.email.message; - emailModalModel.data.component.changeLifecycleState(emailModalModel.data.stateUrl, comment).then(onSuccess, onError); - } - }; - - this.$scope.cancel = ():void => { - this.$modalInstance.dismiss(); - }; - - this.$scope.validateField = (field:any):boolean => { - if (field && field.$dirty && field.$invalid){ - return true; - } - return false; - }; - } - - - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/error-modal/error-403-view.html b/catalog-ui/app/scripts/view-models/modals/error-modal/error-403-view.html deleted file mode 100644 index 185fcce461..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/error-modal/error-403-view.html +++ /dev/null @@ -1,4 +0,0 @@ -<div class="sdc-error-403-container" > - <div class="sdc-error-403-container-title" translate="GENERAL_ERROR_403_TITLE"></div> - <div class="w-sdc-error-403-text w-sdc-form" translate="GENERAL_ERROR_403_DESCRIPTION" translate-values="{{ mailtoJson }}"></div> -</div> diff --git a/catalog-ui/app/scripts/view-models/modals/error-modal/error-view-model.ts b/catalog-ui/app/scripts/view-models/modals/error-modal/error-view-model.ts deleted file mode 100644 index b8b2bfbbe7..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/error-modal/error-view-model.ts +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IErrorViewModelScope{ - mailtoJson: any; - } - - export class ErrorViewModel { - - static '$inject' = ['$scope', 'Sdc.Services.CookieService', '$window', '$filter']; - - constructor($scope:IErrorViewModelScope, cookieService:Services.CookieService, $window, $filter:ng.IFilterService){ - let adminEmail:string = $filter('translate')('ADMIN_EMAIL'); - let subjectPrefix:string = $filter('translate')('EMAIL_SUBJECT_PREFIX'); - let userDetails = cookieService.getFirstName() + ' '+cookieService.getLastName() + ' ('+cookieService.getUserId() + ')'; - let line = adminEmail+'?subject='+$window.encodeURIComponent(subjectPrefix+' '+userDetails); - $scope.mailtoJson = { - "mailto": line - }; - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-base-modal-model.ts b/catalog-ui/app/scripts/view-models/modals/message-modal/message-base-modal-model.ts deleted file mode 100644 index 26df780d25..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-base-modal-model.ts +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IMessageModalModel { - title: string; - message: string; - severity: Utils.Constants.SEVERITY; - } - - export interface IMessageModalViewModelScope extends ng.IScope { - footerButtons: Array<any>; - messageModalModel: IMessageModalModel; - modalInstanceError:ng.ui.bootstrap.IModalServiceInstance; - ok(): void; - } - - export class MessageModalViewModel { - - constructor(private $baseScope:IMessageModalViewModelScope, - private $baseModalInstance:ng.ui.bootstrap.IModalServiceInstance, - private baseMessageModalModel:IMessageModalModel) { - - this.initScope(baseMessageModalModel); - } - - private initScope = (messageModalViewModel:IMessageModalModel):void => { - - this.$baseScope.messageModalModel = messageModalViewModel; - this.$baseScope.modalInstanceError = this.$baseModalInstance; - - this.$baseScope.ok = ():void => { - this.$baseModalInstance.close(); - }; - - this.$baseScope.footerButtons = [ - { - 'name': 'OK', - 'css': 'grey', - 'callback': this.$baseScope.ok - } - ]; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts b/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts deleted file mode 100644 index f7a0dcfabf..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IServerMessageModalModel extends IMessageModalModel { - status: string; - messageId: string; - } - - export interface IServerMessageModalViewModelScope extends IMessageModalViewModelScope { - serverMessageModalModel: IServerMessageModalModel; - } - - export class ServerMessageModalViewModel extends MessageModalViewModel { - - static '$inject' = ['$scope', '$modalInstance', 'serverMessageModalModel']; - - constructor(private $scope:IServerMessageModalViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private serverMessageModalModel:IServerMessageModalModel) { - - super($scope, $modalInstance, serverMessageModalModel); - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts b/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts deleted file mode 100644 index a6e85c4abc..0000000000 --- a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts +++ /dev/null @@ -1,249 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - import ComponentFactory = Sdc.Utils.ComponentFactory; - - interface IOnboardingModalViewModelScope { - modalOnboarding: ng.ui.bootstrap.IModalServiceInstance; - componentsList: Array<Models.Components.IComponent>; - tableHeadersList: Array<any>; - selectedComponent: Models.Components.Component; - componentFromServer: Models.Components.Component; - reverse: boolean; - sortBy: string; - searchBind: string; - okButtonText: string; - isCsarComponentExists: boolean; - user: Models.IUser; - isLoading: boolean; - - doSelectComponent(component: Models.Components.Component): void; - doUpdateCsar(): void; - doImportCsar(): void; - sort(sortBy: string): void; - downloadCsar(packageId: string): void; - } - - export class OnboardingModalViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$state', - 'sdcConfig', - '$modalInstance', - 'Sdc.Services.OnboardingService', - 'okButtonText', - 'currentCsarUUID', - 'Sdc.Services.CacheService', - 'FileUtils', - 'ComponentFactory', - 'ModalsHandler' - ]; - - constructor(private $scope: IOnboardingModalViewModelScope, - private $filter: ng.IFilterService, - private $state: any, - private sdcConfig: Models.IAppConfigurtaion, - private $modalInstance: ng.ui.bootstrap.IModalServiceInstance, - private onBoardingService: Sdc.Services.OnboardingService, - private okButtonText: string, - private currentCsarUUID: string, - private cacheService: Services.CacheService, - private fileUtils: Sdc.Utils.FileUtils, - private componentFactory: Utils.ComponentFactory, - private modalsHandler: Sdc.Utils.ModalsHandler) { - - this.init(); - } - - /** - * Called from controller constructor, this will call onboarding service to get list - * of "mini" components (empty components created from CSAR). - * The list is inserted to componentsList on $scope. - * And then call initScope method. - */ - private init = (): void => { - this.initOnboardingComponentsList(); - }; - - private initScope = (): void => { - - this.initSortedTableScope(); - this.initModalScope(); - this.$scope.sortBy = "name"; // Default sort by - this.$scope.user = this.cacheService.get('user'); - this.$scope.okButtonText = this.okButtonText; - - // Dismiss the modal and pass the "mini" component to workspace general page - this.$scope.doImportCsar = (): void => { - this.$modalInstance.dismiss(); - this.$state.go('workspace.general', { - type: Utils.Constants.ComponentType.RESOURCE.toLowerCase(), - componentCsar: this.$scope.selectedComponent - }); - }; - - this.$scope.doUpdateCsar = (): void => { - // In case user select on update the checkin and submit for testing buttons (in general page) should be disabled. - // to do that we need to pass to workspace.general state parameter to know to disable the buttons. - this.$modalInstance.close(); - // Change the component version to the CSAR version we want to update. - /*(<Resource>this.$scope.componentFromServer).csarVersion = (<Resource>this.$scope.selectedComponent).csarVersion; - let component:Models.Components.Component = this.componentFactory.createComponent(this.$scope.componentFromServer); - this.$state.go('workspace.general', {vspComponent: component, disableButtons: true });*/ - this.cacheService.set(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG, (<Resource>this.$scope.selectedComponent).csarVersion); - this.$state.go('workspace.general', { - id: this.$scope.componentFromServer.uniqueId, - type: this.$scope.componentFromServer.componentType.toLowerCase(), - disableButtons: true - }); - }; - - this.$scope.downloadCsar = (packageId: string): void => { - this.onBoardingService.downloadOnboardingCsar(packageId).then( - (file: any): void => { - if (file) { - this.fileUtils.downloadFile(file, packageId + '.zip'); - } - }, (): void => { - let data: Sdc.ViewModels.IServerMessageModalModel = { - title: 'Download error', - message: "Error downloading file", - severity: Utils.Constants.SEVERITY.ERROR, - messageId: "", - status: "" - }; - this.modalsHandler.openServerMessageModal(data); - } - ); - }; - - // When the user select a row, set the component as selectedComponent - this.$scope.doSelectComponent = (component: Models.Components.Component): void => { - - if (this.$scope.selectedComponent === component) { - // Collapse the item - this.$scope.selectedComponent = undefined; - return; - } - - this.$scope.isLoading = true; - this.$scope.componentFromServer = undefined; - this.$scope.selectedComponent = component; - - let onSuccess = (componentFromServer: Models.Components.Component): void => { - this.$scope.isLoading = false; - if (componentFromServer) { - this.$scope.componentFromServer = componentFromServer; - this.$scope.isCsarComponentExists = true; - } else { - this.$scope.componentFromServer = component; - this.$scope.isCsarComponentExists = false; - } - }; - - let onError = (): void => { - this.$scope.isLoading = false; - this.$scope.componentFromServer = component; - this.$scope.isCsarComponentExists = false; - }; - - this.onBoardingService.getComponentFromCsarUuid((<Resource>component).csarUUID).then(onSuccess, onError); - }; - - }; - - private initSortedTableScope = (): void => { - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Vendor', property: 'vendorName'}, - {title: 'Category', property: 'categories'}, - {title: 'Version', property: 'csarVersion'}, - {title: '#', property: 'importAndUpdate'} - //{title: 'Date', property: 'componentDate'} - ]; - - this.$scope.sort = (sortBy: string): void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - }; - - private initModalScope = (): void => { - // Enable the modal directive to close - this.$scope.modalOnboarding = this.$modalInstance; - }; - - private initOnboardingComponentsList = (): void => { - let onSuccess = (onboardingResponse: Array<Models.Components.IComponent>): void => { - initMaxVersionOfItemsInList(onboardingResponse); - - if (this.currentCsarUUID) { - //this.$scope.componentsList = this.$filter('filter')(this.$scope.componentsList, {csarUUID: this.currentCsarUUID}); - this.$scope.componentsList = this.$filter('filter')(this.$scope.componentsList, - (input): boolean => { - return input.csarUUID === this.currentCsarUUID; - } - ); - } - this.initScope(); - }; - - let onError = (): void => { - console.log("Error getting onboarding list"); - this.initScope(); - }; - - let initMaxVersionOfItemsInList = (onboardingResponse: Array<Models.Components.IComponent>): void => { - // Get only the latest version of each item - this.$scope.componentsList = []; - - // Get all unique items from the list - let uniqueItems = _.uniqBy(onboardingResponse, 'packageId'); - - // Loop on all the items with unique packageId - _.each(uniqueItems, (item: any): void => { - // Find all the items that has same packageId - let ItemsFound: Array<Models.Components.IComponent> = _.filter(onboardingResponse, (inListItem: any): any => { - return inListItem.packageId === item.packageId; - }); - - // Loop on all the items with same packageId and find the max version. - let maxItem: any; - _.each(ItemsFound, (ItemFound: any): void => { - if (!maxItem) { - maxItem = ItemFound; - } else if (maxItem && parseInt(maxItem.csarVersion) < parseInt(ItemFound.csarVersion)) { - maxItem = ItemFound; - } - }); - this.$scope.componentsList.push(maxItem); - }); - }; - - this.onBoardingService.getOnboardingComponents().then(onSuccess, onError); - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor-view-model.ts b/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor-view-model.ts deleted file mode 100644 index c8be2b7361..0000000000 --- a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor-view-model.ts +++ /dev/null @@ -1,148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references.ts"/> -module Sdc.ViewModels { - 'use strict'; - - export class BreadcrumbsMenuItem { - key: string; - displayText: string; - } - - export class BreadcrumbsMenu { - selectedKey: string; - menuItems: Array<BreadcrumbsMenuItem>; - } - - export class BreadcrumbsPath { - selectedKeys: Array<string>; - } - - export class VendorData { - breadcrumbs: BreadcrumbsPath; - } - - export interface IOnboardVendorViewModelScope extends ng.IScope { - vendorData: VendorData; - onVendorEvent: Function; - topNavMenuModel: Array<Utils.MenuItemGroup>; - topNavRootMenu: Utils.MenuItemGroup; - user:Models.IUserProperties; - version:string; - } - - export class OnboardVendorViewModel { - static '$inject' = [ - '$scope', - '$q', - 'Sdc.Services.CacheService' - ]; - - private firstControlledTopNavMenu: Utils.MenuItemGroup; - - constructor( - private $scope: IOnboardVendorViewModelScope, - private $q: ng.IQService, - private cacheService:Services.CacheService - ) { - - this.$scope.vendorData = { - breadcrumbs: { - selectedKeys: [] - } - }; - - this.$scope.version = this.cacheService.get('version'); - - this.$scope.onVendorEvent = (eventName:string, data:any): void => { - switch (eventName) { - case 'breadcrumbsupdated': - this.handleBreadcrumbsUpdate(data); - break; - } - }; - - this.$scope.topNavMenuModel = []; - - this.$scope.user = this.cacheService.get('user'); - } - - updateBreadcrumbsPath = (selectedKeys: Array<string>): ng.IPromise<boolean> => { - let topNavMenuModel = this.$scope.topNavMenuModel; - let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); - if (startIndex === -1) { - startIndex = topNavMenuModel.length; - } - topNavMenuModel.splice(startIndex + selectedKeys.length); - this.$scope.vendorData = { - breadcrumbs: { selectedKeys: selectedKeys } - }; - - return this.$q.when(true); - }; - - handleBreadcrumbsUpdate(breadcrumbsMenus: Array<BreadcrumbsMenu>): void { - let selectedKeys = []; - let topNavMenus = breadcrumbsMenus.map((breadcrumbMenu, breadcrumbIndex) => { - let topNavMenu = new Utils.MenuItemGroup(); - topNavMenu.menuItems = breadcrumbMenu.menuItems.map(menuItem => - new Utils.MenuItem( - menuItem.displayText, - this.updateBreadcrumbsPath, - null, - null, - [selectedKeys.concat([menuItem.key])] - ) - ); - topNavMenu.selectedIndex = _.findIndex( - breadcrumbMenu.menuItems, - menuItem => menuItem.key === breadcrumbMenu.selectedKey - ); - selectedKeys.push(breadcrumbMenu.selectedKey); - return topNavMenu; - }); - - let topNavMenuModel = this.$scope.topNavMenuModel; - let len = topNavMenuModel.length; - let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); - if (startIndex === -1) { - startIndex = len; - } - topNavMenuModel.splice(startIndex, len - startIndex); - topNavMenuModel.push.apply(topNavMenuModel, topNavMenus); - this.firstControlledTopNavMenu = topNavMenus[0]; - - if (startIndex === 1 && this.$scope.topNavRootMenu == null) { - let topNavRootMenu = topNavMenuModel[0]; - let onboardItem = topNavRootMenu.menuItems[topNavRootMenu.selectedIndex]; - let originalCallback = onboardItem.callback; - onboardItem.callback = (...args) => { - let ret = this.updateBreadcrumbsPath([]); - return originalCallback && originalCallback.apply(undefined, args) || ret; - }; - this.$scope.topNavRootMenu = topNavRootMenu; - } - - this.updateBreadcrumbsPath(selectedKeys); - } - } - - -} diff --git a/catalog-ui/app/scripts/view-models/preloading/preloading-view.less b/catalog-ui/app/scripts/view-models/preloading/preloading-view.less deleted file mode 100644 index b02ea54621..0000000000 --- a/catalog-ui/app/scripts/view-models/preloading/preloading-view.less +++ /dev/null @@ -1,107 +0,0 @@ -/* -.sdc-loading-page { - - background-color: @main_color_l; - width: 100%; - height: 100%; - - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - - h1 { - .c_5; - text-align: center; - } - - p { - display: block; - .e_4; - } - - .caption1, .caption2 { - visibility: hidden; - } - - .load-container-wrapper { - position: relative; - - .load-container { - - @background_color: #000000; - - .loader, - .loader:before, - .loader:after { - border-radius: 50%; - } - .loader:before, - .loader:after { - position: absolute; - content: ''; - } - .loader:before { - width: 5.2em; - height: 10.2em; - background: @background_color; - border-radius: 10.2em 0 0 10.2em; - top: -0.1em; - left: -0.1em; - -webkit-transform-origin: 5.2em 5.1em; - transform-origin: 5.2em 5.1em; - -webkit-animation: load2 2s infinite ease 1.5s; - animation: load2 2s infinite ease 1.5s; - } - .loader { - color: #ffffff; - font-size: 11px; - text-indent: -99999em; - margin: 0 auto; - /!*margin: 55px auto;*!/ - position: relative; - width: 10em; - height: 10em; - box-shadow: inset 0 0 0 1em; - -webkit-transform: translateZ(0); - -ms-transform: translateZ(0); - transform: translateZ(0); - } - .loader:after { - width: 5.2em; - height: 10.2em; - background: @background_color; - border-radius: 0 10.2em 10.2em 0; - top: -0.1em; - left: 5.1em; - -webkit-transform-origin: 0px 5.1em; - transform-origin: 0px 5.1em; - -webkit-animation: load2 2s infinite ease; - animation: load2 2s infinite ease; - } - @-webkit-keyframes load2 { - 0% { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - 100% { - -webkit-transform: rotate(360deg); - transform: rotate(360deg); - } - } - @keyframes load2 { - 0% { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - 100% { - -webkit-transform: rotate(360deg); - transform: rotate(360deg); - } - } - } - - } - -} -*/ diff --git a/catalog-ui/app/scripts/view-models/preloading/preloading-view.ts b/catalog-ui/app/scripts/view-models/preloading/preloading-view.ts deleted file mode 100644 index 7127b70e3c..0000000000 --- a/catalog-ui/app/scripts/view-models/preloading/preloading-view.ts +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -module Sdc.ViewModels { - 'use strict'; - - interface IPreLoadingViewScope { - startZoomIn: boolean; - } - - export class PreLoadingViewModel { - - static '$inject' = ['$scope']; - constructor(private $scope:IPreLoadingViewScope){ - this.init($scope); - } - - private init = ($scope:IPreLoadingViewScope):void => { - this.animate($('.caption1'),'fadeInUp',400); - this.animate($('.caption2'),'fadeInUp',800); - }; - - private animate = (element:any, animation:string, when:number):void => { - window.setTimeout(()=>{ - element.addClass("animated " + animation); - element[0].style="visibility: visible;"; - },when); - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/support/support-view-model.ts b/catalog-ui/app/scripts/view-models/support/support-view-model.ts deleted file mode 100644 index 2142cffdda..0000000000 --- a/catalog-ui/app/scripts/view-models/support/support-view-model.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - interface ISupportViewModelScope { - version:string; - } - - export class SupportViewModel{ - - static '$inject' = ['$scope','Sdc.Services.CacheService']; - constructor(private $scope:ISupportViewModelScope, - private cacheService:Services.CacheService){ - this.$scope.version = this.cacheService.get('version'); - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view-model.ts b/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view-model.ts deleted file mode 100644 index bd59199eb4..0000000000 --- a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view-model.ts +++ /dev/null @@ -1,99 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 7/28/2016. - */ -/** - * Created by obarda on 4/4/2016. - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import Module = Sdc.Models.Module; - - export interface IHierarchyScope extends ng.IScope { - component:Models.Components.Component; - selectedIndex: number; - selectedModule:Models.DisplayModule; - singleTab:Models.Tab; - templateUrl:string; - isLoading:boolean; - - onModuleSelected(moduleId:string, selectedIndex: number):void; - onModuleNameChanged(module:Models.DisplayModule):void; - updateHeatName():void; - } - - export class HierarchyViewModel { - - static '$inject' = [ - '$scope' - ]; - - constructor(private $scope:IHierarchyScope) { - this.$scope.component = this.$scope.singleTab.data; - this.$scope.isLoading = false; - this.initScopeMethods(); - } - - private initScopeMethods():void { - - this.$scope.templateUrl = '/app/scripts/view-models/tabs/hierarchy/edit-module-name-popover.html'; - this.$scope.onModuleSelected = (moduleId:string, selectedIndex: number):void => { - - let onSuccess = (module:Models.DisplayModule) => { - console.log("Module Loaded: ", module); - this.$scope.selectedModule = module; - this.$scope.isLoading = false; - }; - - let onFailed = () => { - this.$scope.isLoading = false; - }; - - this.$scope.selectedIndex = selectedIndex; - if( !this.$scope.selectedModule || (this.$scope.selectedModule && this.$scope.selectedModule.uniqueId != moduleId)) { - this.$scope.isLoading = true; - this.$scope.component.getModuleForDisplay(moduleId).then(onSuccess, onFailed); - } - }; - - this.$scope.updateHeatName = () => { - this.$scope.isLoading = true; - - let originalName:string = this.$scope.selectedModule.name; - - let onSuccess = (module:Models.Module) => { - console.log("Module name updated:", module.name); - this.$scope.selectedModule.name = module.name; - this.$scope.isLoading = false; - }; - - let onFailed = () => { - this.$scope.isLoading = false; - this.$scope.selectedModule.name = originalName; - }; - - this.$scope.selectedModule.updateName(); - this.$scope.component.updateGroupMetadata(new Models.DisplayModule(this.$scope.selectedModule)).then(onSuccess, onFailed); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view.html b/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view.html deleted file mode 100644 index 971105c191..0000000000 --- a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy-view.html +++ /dev/null @@ -1,57 +0,0 @@ -<div class="sdc-general-tab hierarchy-tab" ng-class=""> - <loader data-display="isLoading" relative="true" size="medium"></loader> - <div class="sdc-general-tab-title" data-tests-id="tab-header" translate="HIERARCHY_TAB_TITLE"></div> - <div class="sdc-general-tab-sub-title" data-tests-id="tab-sub-header">{{component.name}}</div> - - <div class="resizable-container"> - <div class="resizable-section"> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" - class="general-tab-scrollbar-container"> - - <expand-collapse expanded-selector=".hierarchy-module-member-list.{{$index}}" - class="general-tab-expand-collapse" is-close-on-init="true" - data-tests-id="hierarchy-module-{{$index}}" - data-ng-repeat-start="module in component.groups"> - <div class="expand-collapse-title" data-tests-id="hierarchy-module-{{$index}}-title" ng-class="{'selected': selectedIndex === $index}" data-ng-click="onModuleSelected(module.uniqueId, $index)"> - <div class="expand-collapse-title-icon"></div> - <span class="expand-collapse-title-text" data-ng-bind="module.name" tooltips - tooltip-content="{{module.name}}"></span> - - </div> - </expand-collapse> - - <div data-ng-repeat-end="" class="hierarchy-module-member-list {{$index}}"> - <div ng-repeat="(memberName, value) in ::module.members track by $index"> - <div class="expand-collapse-sub-title" tooltips tooltip-content="{{memberName}}">{{memberName}}</div> - </div> - </div> - </perfect-scrollbar> - </div> - - <div resizable r-directions="['top']" r-flex="true" ng-if="selectedModule" class="resizable-section module-data-container" data-tests-id="selected-module-data"> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" - class="general-tab-scrollbar-container"> - <div class="module-data"> - <div> - <div class="module-name module-text-overflow" data-tests-id="selected-module-name" tooltips tooltip-content="{{selectedModule.name}}">{{selectedModule.name}}</div> - <div class="edit-name-container"> - <edit-name-popover header="Edit Module Name" direction="auto top" module="selectedModule" on-save="updateHeatName()" ng-class="{'disabled': isViewOnly}" class="sdc-edit-icon" data-tests-id="edit-name-popover-icon"></edit-name-popover> - </div> - </div> - <div class="module-text-overflow" data-tests-id="selected-module-group-uuid" tooltips tooltip-content="{{selectedModule.groupUUID}}"> Module ID: {{selectedModule.groupUUID}}</div> - <div class="module-text-overflow" data-tests-id="selected-module-is-base" tooltips tooltip-content="{{selectedModule.invariantUUID}}">Invariant UUID: {{selectedModule.invariantUUID}}</div> - <div data-tests-id="selected-module-version">Version: {{selectedModule.version}}</div> - <div data-tests-id="selected-module-is-base">IsBase: {{selectedModule.isBase}}</div> - - </div> - <div ng-repeat="artifact in selectedModule.artifacts track by $index"> - <div class="artifact-data"> - <div class="artifact-name module-text-overflow" data-tests-id="selected-module-artifact-name" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</div> - <div class="module-text-overflow" tooltips data-tests-id="selected-module-artifact-uuid" tooltip-content="{{artifact.artifactUUID}}"> UUID: {{artifact.artifactUUID}}</div> - <div data-tests-id="selected-module-artifact-version">Version: {{artifact.artifactVersion}}</div> - </div> - </div> - </perfect-scrollbar> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.ts b/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.ts deleted file mode 100644 index 411d3f8d24..0000000000 --- a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.ts +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface ITutorialEndViewModelScope extends ng.IScope {} - - export class TutorialEndViewModel { - - static '$inject' = [ - '$scope' - ]; - constructor( - private $scope:ITutorialEndViewModelScope - ){ - this.init(); - } - - private init = ():void => { - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/welcome/slide0.html b/catalog-ui/app/scripts/view-models/welcome/slide0.html deleted file mode 100644 index 48d37215a4..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide0.html +++ /dev/null @@ -1,50 +0,0 @@ -<div class="slide" id="slide-0" data-ng-controller="Sdc.ViewModels.WelcomeStepsControllerViewModel"> - <div class="asdc-welcome-frame frame-0"> - <div class="asdc-welcome-header"> - <a class="sprite-welcome logo" class="welcome-logo" ui-sref="dashboard"></a> - </div> - - <div class="asdc-welcome-cover"></div> - <div class="asdc-whats-new"> - - <div class="news-items-row"> - <div class="news-item-wrapper bg-1"> - <div class="news-title" translate="WHATS_NEW_1_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_1_BODY"></div> - </div> - <div class="news-item-wrapper bg-2"> - <div class="news-title" translate="WHATS_NEW_2_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_2_BODY"></div> - </div> - <div class="news-item-wrapper bg-3"> - <div class="news-title" translate="WHATS_NEW_3_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_3_BODY"></div> - </div> - <div class="news-item-wrapper bg-4"> - <div class="news-title" translate="WHATS_NEW_4_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_4_BODY"></div> - </div> - </div> - - <div class="news-items-row"> - <div class="news-item-wrapper bg-5"> - <div class="news-title" translate="WHATS_NEW_5_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_5_BODY"></div> - </div> - <div class="news-item-wrapper bg-6"> - <div class="news-title" translate="WHATS_NEW_6_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_6_BODY"></div> - </div> - <div class="news-item-wrapper bg-7"> - <div class="news-title" translate="WHATS_NEW_7_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_7_BODY"></div> - </div> - <div class="news-item-wrapper bg-8"> - <div class="news-title" translate="WHATS_NEW_8_TITLE"></div> - <div class="news-body" translate="WHATS_NEW_8_BODY"></div> - </div> - </div> - - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide1.html b/catalog-ui/app/scripts/view-models/welcome/slide1.html deleted file mode 100644 index 9252026a6b..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide1.html +++ /dev/null @@ -1,34 +0,0 @@ -<div class="slide" id="slide-1" data-ng-controller="Sdc.ViewModels.WelcomeStepsControllerViewModel"> - <div class="asdc-welcome-frame frame-01"> - <div class="asdc-welcome-header"> - <!--<a class="sprite-welcome logo" class="welcome-logo" ui-sref="dashboard"></a>--> - <!--<a class="whats-new" data-ng-click="gotoSlideIndex(0)">What`s New</a>--> - </div> - - <!--<video id="asdc-welcome-video" class="asdc-welcome-video"><!– autoplay loop muted –> - <source ng-src="{{video_mp4}}" type="video/mp4" /> - <source ng-src="{{video_ogg}}" type='video/ogg' /> - </video>--> - - <div class="asdc-welcome-cover"></div> - <div class="asdc-welcome-main"> - - <!--<div class="asdc-welcome-main-title">INNOVATIVE. RAPID. RELIABLE</div> - <div class="asdc-welcome-main-message"> - AT&Ts leading collaborative network solution design platform - </div> - - <div class="asdc-welcome-main-back-btn-ph"> - <a class="asdc-welcome-main-back-btn" ui-sref="dashboard">Home</a> - </div> - - <div class="asdc-welcome-video-icon"> - <div class="asdc-welcome-video-icon-play sprite-welcome play" data-ng-click="onPlayVideo()"></div> - <div class="asdc-welcome-inner-circle"></div> - </div>--> - - <h1>Welcome to SDC</h1> - - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide2.html b/catalog-ui/app/scripts/view-models/welcome/slide2.html deleted file mode 100644 index 4329bf462d..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide2.html +++ /dev/null @@ -1,26 +0,0 @@ -<div class="slide" id="slide-2"> - <div class="asdc-welcome-frame frame-02"> - <div class="asdc-welcome-slide-text-box"> - <div class="asdc-welcome-slide-text-box-title"> - Innovate <br> - network- design <br> - platform <br> - </div> - <div class="asdc-welcome-slide-text-box-content"> - <p> - Adapt swiftly to the constant demands placed on <br> networks by ongoing technological advances. - </p> - <p> - Using ASDC’s innovative network-design platform,<br> quickly and easily create and share software - <br> - components. - </p> - </div> - </div> - <div class="asdc-welcome-slide-image-box"> - <img src="styles/images/welcome/ss-01.png" alt="01" class="asdc-welcome-slide-image"> - </div> - <div class="asdc-welcome-frame-shape"></div> - <div class="asdc-welcome-frame-connection"></div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide3.html b/catalog-ui/app/scripts/view-models/welcome/slide3.html deleted file mode 100644 index dd5448beac..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide3.html +++ /dev/null @@ -1,27 +0,0 @@ -<div class="slide" id="slide-3"> - <div class="asdc-welcome-frame frame-03"> - - <div class="asdc-welcome-slide-text-box"> - <div class="asdc-welcome-slide-text-box-title"> - Enhance <br> - and extend - </div> - <div class="asdc-welcome-slide-text-box-content"> - <p> - Blend, build and arrange resources and services in the <br> designer workspace. - </p> - <p> - Let your creativity lead the way to any number of <br> network solutions. - </p> - <p> - Then simply click on elements to customize and refine <br> their specific properties to match your needs. - </p> - </div> - </div> - <div class="asdc-welcome-slide-image-box"> - <img src="styles/images/welcome/ss-02.png" alt="02" class="asdc-welcome-slide-image"> - </div> - <div class="asdc-welcome-frame-shape"></div> - <div class="asdc-welcome-frame-connection"></div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide4.html b/catalog-ui/app/scripts/view-models/welcome/slide4.html deleted file mode 100644 index 1428ce5375..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide4.html +++ /dev/null @@ -1,29 +0,0 @@ -<div class="slide" id="slide-4"> - <div class="asdc-welcome-frame frame-04"> - <div class="asdc-welcome-slide-text-box"> - <div class="asdc-welcome-slide-text-box-title"> - Share <br> - and Collaborate - </div> - <div class="asdc-welcome-slide-text-box-content"> - <p> - Graphically arranged, the Catalog is an easily <br> searchable collection of resources, services and - <br> products that provides you with a variety of <br> network elements. - </p> - <p> - Benefit from these assets by using them as <br> building blocks to form any number of network - <br> solutions. - </p> - <p> - After being certified for release, share and <br> collaborate with others as your solution is - <br> automatically included in the catalog. - </p> - </div> - </div> - <div class="asdc-welcome-slide-image-box"> - <img src="styles/images/welcome/ss-03.png" alt="03" class="asdc-welcome-slide-image"> - </div> - <div class="asdc-welcome-frame-shape"></div> - <div class="asdc-welcome-frame-connection"></div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide5.html b/catalog-ui/app/scripts/view-models/welcome/slide5.html deleted file mode 100644 index 913573c8fc..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide5.html +++ /dev/null @@ -1,27 +0,0 @@ -<div class="slide" id="slide-5"> - <div class="asdc-welcome-frame frame-05"> - <div class="asdc-welcome-slide-text-box"> - <div class="asdc-welcome-slide-text-box-title"> - Fast, efficient <br> - and reliable - </div> - <div class="asdc-welcome-slide-text-box-content"> - <p> - ASDC is a platform built around a simple error-free - <br>process for resource and service design and distribution. - <br> - <br>An integrated certification process makes ASDC a safe - <br>and reliable environment to experiment, review and test - <br>your work. - <br> - <br>Once approved your solution is ready to be used in - <br>the real-world. - </p> - - </div> - - </div> - <div class="asdc-welcome-frame-shape"></div> - - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/slide6.html b/catalog-ui/app/scripts/view-models/welcome/slide6.html deleted file mode 100644 index 22006f7f82..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/slide6.html +++ /dev/null @@ -1,26 +0,0 @@ -<div class="slide" id="slide-6"> - <div class="asdc-welcome-frame frame-06"> - - <div class="asdc-welcome-cover"></div> - <div class="asdc-welcome-main"> - - <div class="asdc-welcome-main-title">ASDC</div> - <div class="asdc-welcome-main-message"> - jump starting your network solutions. - </div> - <div class="asdc-welcome-main-back-btn-ph"> - <a class="asdc-welcome-main-back-btn" ui-sref="dashboard">Home</a> - </div> - </div> - - <div class="asdc-welcome-footer"> - © 2016 AT&T Intellectual Property.© 2016 AT&T Intellectual Property. link. This link will open a new - window This link will open a new window All rights reserved. - <br/> - AT&T, Globe logo, Mobilizing Your World and DIRECTV are registered trademarks of AT&T Intellectual - Property and/or AT&T affiliated companies. All other marks are the property of their respective owners. - - </div> - - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/welcome-steps-controller.ts b/catalog-ui/app/scripts/view-models/welcome/welcome-steps-controller.ts deleted file mode 100644 index 816afcf2d2..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/welcome-steps-controller.ts +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IWelcomeStepsController { - video_mp4: string; - video_ogg: string; - onPlayVideo: Function; - } - - export class WelcomeStepsControllerViewModel { - - static '$inject' = [ - '$scope', - '$sce', - 'sdcConfig', - '$state', - '$filter' - ]; - - constructor( - private $scope:IWelcomeStepsController, - private $sce:any, - private sdcConfig: Models.IAppConfigurtaion, - private $state:ng.ui.IStateService, - private $filter:ng.IFilterService - ){ - this.init(); - this.initScope(); - } - - private init = ():void => { - - }; - - private initScope = ():void => { - - this.$scope.onPlayVideo = ():void => { - //console.log("onPlayVideo"); - $("#sdc-page-scroller").removeClass("animated fadeIn"); - $("#sdc-page-scroller").addClass("animated fadeOut"); - window.setTimeout(()=>{$("#sdc-page-scroller").css("display","none");},500); - - $("#sdc-welcome-video-wrapper").removeClass("animated fadeOut"); - $("#sdc-welcome-video-wrapper").addClass("animated fadeIn"); - window.setTimeout(()=>{$("#sdc-welcome-video-wrapper").css("display","block");},0); - - let videoElement:any = $("#asdc-welcome-video")[0]; - videoElement.play(); - }; - - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/welcome/welcome-view.html b/catalog-ui/app/scripts/view-models/welcome/welcome-view.html deleted file mode 100644 index ba41e88a4e..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/welcome-view.html +++ /dev/null @@ -1,22 +0,0 @@ -<div class="sdc-welcome-new-page"> - - <!--<div id="sdc-welcome-video-wrapper"> - <div class="asdc-welcome-video-close sprite-welcome close" data-ng-click="onCloseVideoButton()"></div> - <video id="asdc-welcome-video" class="asdc-welcome-video"> - <source ng-src="{{video_mp4}}" type="video/mp4" /> - <source ng-src="{{video_ogg}}" type='video/ogg' /> - </video> - </div>--> - - <div class="os-welcome">Welcome to SDC</div> - - <!--<sdc-page-scroll id="sdc-page-scroller" - start-slide-index="1" - slides-data="slides" - show-nav="true" - show-close-button="true" - close-button-callback="onCloseButton"> - - </sdc-page-scroll> ---> -</div> diff --git a/catalog-ui/app/scripts/view-models/welcome/welcome-view.ts b/catalog-ui/app/scripts/view-models/welcome/welcome-view.ts deleted file mode 100644 index 0a0c923481..0000000000 --- a/catalog-ui/app/scripts/view-models/welcome/welcome-view.ts +++ /dev/null @@ -1,267 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IWelcomeViewMode { - slides:Array<Sdc.Directives.SlideData>; - onCloseButton():void; - onCloseVideoButton():void; - - video_mp4: string; - video_ogg: string; - } - - export class WelcomeViewModel { - - firstLoad:boolean = true; - alreadyAnimated:Array<number> = []; - - static '$inject' = [ - '$scope', - '$sce', - 'sdcConfig', - '$state', - '$filter' - ]; - - constructor( - private $scope:IWelcomeViewMode, - private $sce:any, - private sdcConfig: Models.IAppConfigurtaion, - private $state:ng.ui.IStateService, - private $filter:ng.IFilterService - ){ - /*this.init(); - this.initScope(); - window.setTimeout(():void => { - this.loadImages(():void=> { - window.setTimeout(():void =>{ - $(".sdc-welcome-new-page").addClass("animated fadeIn"); - this.animateGeneral(); - this.animate1(); - },1000); - }); - },0);*/ - } - - private initScope = ():void => { - - this.$scope.onCloseButton = ():void => { - //console.log("onCloseButton"); - this.$state.go("dashboard", {}); - }; - - this.$scope.onCloseVideoButton = ():void => { - //console.log("onCloseVideoButton"); - $("#sdc-page-scroller").removeClass("animated fadeOut"); - $("#sdc-page-scroller").addClass("animated fadeIn"); - window.setTimeout(()=>{$("#sdc-page-scroller").css("display","block");},0); - - $("#sdc-welcome-video-wrapper").removeClass("animated fadeIn"); - $("#sdc-welcome-video-wrapper").addClass("animated fadeOut"); - window.setTimeout(()=>{$("#sdc-welcome-video-wrapper").css("display","none");},500); - - let videoElement:any = $("#asdc-welcome-video")[0]; - videoElement.pause(); - }; - - let url: string = this.sdcConfig.api.welcome_page_video_url; - - this.$scope.video_mp4 = this.$sce.trustAsResourceUrl(url + ".mp4"); - this.$scope.video_ogg = this.$sce.trustAsResourceUrl(url + ".ogg"); - - }; - - private init = ():void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - this.$scope.slides = [ - {"url": viewModelsHtmlBasePath + 'welcome/slide0.html', "id": "slide-0", "index": 0, "callback": () => {this.animate0();}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide1.html', "id": "slide-1", "index": 1, "callback": () => {}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide2.html', "id": "slide-2", "index": 2, "callback": () => {this.animate2();}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide3.html', "id": "slide-3", "index": 3, "callback": () => {this.animate3();}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide4.html', "id": "slide-4", "index": 4, "callback": () => {this.animate4();}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide5.html', "id": "slide-5", "index": 5, "callback": () => {this.animate5();}}, - {"url": viewModelsHtmlBasePath + 'welcome/slide6.html', "id": "slide-6", "index": 6, "callback": () => {this.animate6();}} - ]; - - $('body').keyup((e):void=> { - if (e.keyCode == 27) { // escape key maps to keycode `27` - this.$state.go('dashboard'); - } - }); - }; - - private animateGeneral = ():void => { - //console.log("animateGeneral"); - - /*// Animate the right navigation - if (this.firstLoad===true) { - //TODO: Israel - //TweenLite.from('.page-nav', 2, {x: "100px", delay: 2}); - } - */ - - this.firstLoad = false; - }; - - /*private loadImages = (callback: Function):void => { - let src = $('#slide-1 .asdc-welcome-frame').css('background-image'); - let url = src.match(/\((.*?)\)/)[1].replace(/('|")/g,''); - - let img = new Image(); - img.onload = function() { - callback(); - //alert('image loaded'); - }; - img.src = url; - /!*if (img.complete){ - callback; - }*!/ - };*/ - - private animate = (element:any, animation:string, when:number):void => { - window.setTimeout(()=>{ - element.addClass("animated " + animation); - if (element[0]) { - element[0].style = "visibility: visible;"; - } - },when); - }; - - private hide = (element:any, animation:string, animationToHide:string, when:number):void => { - element.addClass("animated " + animation); - element[0].style="visibility: hidden;"; - }; - - private animate0 = ():void => { - if (this.alreadyAnimated.indexOf(0)!==-1){ - return; - } else { - this.alreadyAnimated.push(0); - } - //console.log("slide 0 - animate"); - this.animate($('#slide-0 .bg-1'),'fadeInDown',500); - this.animate($('#slide-0 .bg-2'),'fadeInDown',1000); - this.animate($('#slide-0 .bg-3'),'fadeInDown',1500); - this.animate($('#slide-0 .bg-4'),'fadeInDown',2000); - - this.animate($('#slide-0 .bg-5'),'fadeInDown',2500); - this.animate($('#slide-0 .bg-6'),'fadeInDown',3000); - this.animate($('#slide-0 .bg-7'),'fadeInDown',3500); - this.animate($('#slide-0 .bg-8'),'fadeInDown',4000); - }; - - private animate1 = ():void => { - if (this.alreadyAnimated.indexOf(1)!==-1){ - return; - } else { - this.alreadyAnimated.push(1); - } - //console.log("slide 1 - animate"); - - this.animate($('#slide-1 .asdc-welcome-main-title'),'fadeInUp',1000); - this.animate($('#slide-1 .asdc-welcome-main-message'),'fadeInUp',2000); - - this.animate($('#slide-1 .asdc-welcome-main-back-btn'),'fadeIn',3000); - - this.animate($('#slide-1 .asdc-welcome-video-icon'),'zoomIn',3000); - this.animate($('#slide-1 .asdc-welcome-inner-circle'),'zoomIn',3000); - - this.animate($('.welcome-nav'),'slideInRight',2000); - }; - - private animate2 = ():void => { - if (this.alreadyAnimated.indexOf(2)!==-1){ - return; - } else { - this.alreadyAnimated.push(2); - } - //console.log("slide 2 - animate"); - this.animate($('#slide-2 .asdc-welcome-frame-shape'),'zoomIn',500); - this.animate($('#slide-2 .asdc-welcome-slide-text-box-content'),'fadeInUp',2000); - this.animate($('#slide-2 .asdc-welcome-slide-text-box-title'),'fadeInUp',1000); - }; - - private animate3 = ():void => { - if (this.alreadyAnimated.indexOf(3)!==-1){ - return; - } else { - this.alreadyAnimated.push(3); - } - //console.log("slide 3 - animate"); - this.animate($('#slide-3 .asdc-welcome-frame-shape'),'zoomIn',500); - this.animate($('#slide-3 .asdc-welcome-slide-text-box-content'),'fadeInUp',2000); - this.animate($('#slide-3 .asdc-welcome-slide-text-box-title'),'fadeInUp',1000); - }; - - private animate4 = ():void => { - if (this.alreadyAnimated.indexOf(4)!==-1){ - return; - } else { - this.alreadyAnimated.push(4); - } - //console.log("slide 4 - animate"); - this.animate($('#slide-4 .asdc-welcome-frame-shape'),'zoomIn',500); - this.animate($('#slide-4 .asdc-welcome-slide-text-box-content'),'fadeInUp',2000); - this.animate($('#slide-4 .asdc-welcome-slide-text-box-title'),'fadeInUp',1000); - }; - - private animate5 = ():void => { - if (this.alreadyAnimated.indexOf(5)!==-1){ - return; - } else { - this.alreadyAnimated.push(5); - } - //console.log("slide 5 - animate"); - this.animate($('#slide-5 .asdc-welcome-frame-shape'),'zoomIn',500); - this.animate($('#slide-5 .asdc-welcome-slide-text-box-content'),'fadeInUp',2000); - this.animate($('#slide-5 .asdc-welcome-slide-text-box-title'),'fadeInUp',1000); - }; - - private animate6 = ():void => { - if (this.alreadyAnimated.indexOf(6)!==-1){ - return; - } else { - this.alreadyAnimated.push(6); - } - //console.log("slide 6 - animate"); - this.animate($('#slide-6 .asdc-welcome-main-message'),'fadeInUp',2000); - this.animate($('#slide-6 .asdc-welcome-main-title'),'fadeInUp',1000); - this.animate($('#slide-6 .asdc-welcome-main-back-btn'),'fadeInUp',3000); - }; - - private animateCss = (element:JQuery, animationName:string):void => { - let animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; - element.addClass('animated ' + animationName).one(animationEnd, function() { - element.removeClass('animated ' + animationName); - }); - }; - - private unAnimateCss = (element:JQuery, animationName:string):void => { - let animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend'; - element.addClass('animated ' + animationName).one(animationEnd, function() { - element.removeClass('animated ' + animationName); - }); - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/ReadMe.txt b/catalog-ui/app/scripts/view-models/wizard/ReadMe.txt deleted file mode 100644 index ca5cfb988a..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/ReadMe.txt +++ /dev/null @@ -1,54 +0,0 @@ -import-asset wizard -======================================================== - -What should be done in each wizard step: ----------------------------------------- - -1. Each step scope should extend IAssetCreationStepScope (this way you can call methods on the wizard scope). - Example: - export interface IGeneralStepScope extends IAssetCreationStepScope { - - } - -2. Each step class should implements IAssetCreationStep - Example: export class GeneralStepViewModel implements IAssetCreationStep { - - } - -3. Add the method: public save = (callback:Function):void => {} - The method should perform the save and call: callback(true); in case of success, or callback(false); in case of error. - Example: - var onSuccess:Function = (resourceProperties:Services.IResourceResource) => { - this.$scope.setAngularResourceOfResource(resourceProperties); - var resourceObj = new Sdc.Models.Resource(resourceProperties); - this.$scope.setEntity(resourceObj); - this.$scope.latestEntityName = (resourceProperties.resourceName); - callback(true); - }; - -4. Add the first line after the constructor: this.$scope.registerChild(this); - This will register the current step reference in the wizard. - -5. Each step can get and set angular $resource of resource from the wizard. - // Will be called from each step to get current entity. - this.$scope.getAngularResourceOfResource = ():Services.IResourceResource => { - return this.resourceProperties; - }; - - // Will be called from each step after save to update the resource. - this.$scope.setAngularResourceOfResource = (resourceProperties:Services.IResourceResource):void => { - this.resourceProperties = resourceProperties; - this.fillAssetNameAndType(); - }; - - Note: after success save, set setAngularResourceOfResource in the wizard (see example in step 3). - -6. The wizard needs to know if the step is valid (to know if to show next button), I used the following to update the wizard: - this.$scope.$watch("editForm.$valid", function(newVal, oldVal){ - this.$scope.setValidState(newVal); - }); - - Note: in case there is no save for the step, and the step is always valid, call: this.$scope.setValidState(true); - - - diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.html b/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.html deleted file mode 100644 index 97817d59f2..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.html +++ /dev/null @@ -1,137 +0,0 @@ -<div class="artifact-deployment-step" data-ng-controller="Sdc.ViewModels.Wizard.ArtifactDeploymentStepViewModel"> - - <div data-tests-id="add-deployment-artifact-button" data-tests-id="addGrey" class="w-sdc-classic-btn gray" data-ng-click="addOrUpdate({})">Add</div> - - <div class="table-container-flex"> - - <div class="table"> - - <div class="head flex-container"> - <div class="table-header head-row hand flex-item" data-ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} - <span data-ng-if="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> - </div> - <div class="table-no-text-header head-row flex-item"></div> - </div> - - <form class="body" name="editForm"> - - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - - <!-- Artifact row --> - <div ng-if="noArtifactsToShow()" class="no-row-text" translate="DEPLOYMENT_ARTIFACT_NO_ARTIFACTS_TO_DISPLAY"></div> - <div data-ng-repeat-start="artifact in artifacts | orderBy:sortBy:reverse track by $index" - class="flex-container data-row" - data-ng-class="{'selected': artifact.selected || undefined==artifact.selected && updateInProgress}" - data-ng-if="artifact.esId"> - - <div class="table-col-general flex-item" data-ng-click="update(artifact)"> - <loader data-display="isLoading"></loader> - <span class="sprite table-arrow" data-tests-id="{{artifact.artifactDisplayName}}" data-ng-class="{'opened': artifact.selected || undefined==artifact.selected && updateInProgress}"></span> - {{artifact.artifactDisplayName}} - </div> - - <div class="table-col-general flex-item" data-tests-id="{{artifact.artifactType}}"> - {{artifact.artifactType}} - </div> - <div class="table-col-general flex-item" data-tests-id="{{artifact.timeout}}"> - {{artifact.timeout? artifact.timeout:''}} - </div> - - <div class="table-btn-col flex-item" sdc-keyboard-events> - <button class="table-edit-btn" data-ng-click="addOrUpdate(artifact)"></button> - <button class="table-delete-btn" data-ng-click="delete(artifact)"> </button> - </div> - </div> - <div data-ng-repeat-end="" data-ng-if="artifact.selected || undefined==artifact.selected && updateInProgress" class="w-sdc-form item-opened"> - <!-- Artifact panel opened --> - - <!-- Description field --> - <div class="w-sdc-form-item" ng-form="descriptionForm" data-ng-class="{error:(descriptionForm.$dirty && descriptionForm.$invalid)}"> - <label class="i-sdc-env-form-label required">Description</label> - <textarea class="i-sdc-form-textarea {{$index}}" - data-ng-maxlength="256" - maxlength="256" - data-ng-required="true" - name="description" - data-ng-model="artifact.description" - data-ng-model-options="{ debounce: 200 }" - data-ng-pattern="getValidationPattern('string')" - data-tests-id="description"> - </textarea> - - <div class="input-error" data-ng-show="descriptionForm.$dirty && descriptionForm.$invalid"> - <span ng-show="descriptionForm.$error.required" translate="ADD_ARTIFACT_ERROR_DESCRIPTION_REQUIRED"></span> - <span ng-show="descriptionForm.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> - <span ng-show="descriptionForm.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - - </div> - - <!-- Parameters in 2 columns --> - <div class="w-sdc-form-columns-wrapper" data-ng-if="artifact.heatParameters"> - <!-- Left column --> - <div class="w-sdc-form-column"> - <div class="i-sdc-form-item" ng-form="parameterForm" data-ng-repeat="parameter in artifact.heatParameters.slice(0, artifact.heatParameters.length%2+artifact.heatParameters.length/2) | orderBy: 'name' track by $index"> - <label class="i-sdc-env-form-label" data-ng-class="{required:parameter.defaultValue}" tooltip-side="top" sdc-smart-tooltip>{{parameter.name +' (' + parameter.type + ')'}}</label> - <span class="parameter-description" tooltips tooltip-side="top" tooltip-content="{{parameter.description}}">?</span> - <input class="i-sdc-form-input" data-ng-class="{error:(parameterForm.currentValue.$invalid)}" - data-ng-model-options="{ debounce: 200 }" - data-ng-model="parameter.currentValue" - type="text" - name="currentValue" - data-ng-pattern="getValidationPattern(parameter.type, 'heat')" - data-ng-required="parameter.defaultValue" - data-ng-change="'json'==parameter.type && parameterForm.currentValue.$setValidity('pattern', validateJson(parameter.currentValue))" - data-ng-blur="!parameterForm.currentValue.$error.pattern && resetValue(parameter)" - /> - - <div class="input-error" data-ng-show="parameterForm.currentValue.$invalid"> - <span ng-show="parameterForm.currentValue.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> - </div> - </div> - </div> - - <!-- Right column --> - <div class="w-sdc-form-column"> - <div class="i-sdc-form-item" ng-form="parameterForm" data-ng-repeat="parameter in artifact.heatParameters.slice(artifact.heatParameters.length%2+artifact.heatParameters.length/2) | orderBy: 'name' track by $index"> - <label class="i-sdc-env-form-label" data-ng-class="{required:parameter.defaultValue}" tooltip-side="top" sdc-smart-tooltip>{{parameter.name +' (' + parameter.type + ')'}}</label> - <span class="parameter-description" tooltips tooltip-side="top" tooltip-content="{{parameter.description}}">?</span> - <input class="i-sdc-form-input" data-ng-class="{error:(parameterForm.currentValue.$invalid)}" - data-ng-model-options="{ debounce: 200 }" - data-ng-model="parameter.currentValue" - type="text" - name="currentValue" - data-ng-pattern="getValidationPattern(parameter.type, 'heat')" - data-ng-required="parameter.defaultValue" - data-ng-change="'json'==parameter.type && parameterForm.currentValue.$setValidity('pattern', validateJson(parameter.currentValue))" - data-ng-blur="!parameterForm.currentValue.$error.pattern && resetValue(parameter)" - /> - - <div class="input-error" data-ng-show="parameterForm.currentValue.$invalid"> - <span ng-show="parameterForm.currentValue.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> - </div> - </div> - </div> - - </div><!-- Close: Parameters in 2 columns --> - </div><!-- Close: Artifact panel opened --> - - <!-- Add artifacts buttons --> - <button class="add-button" data-ng-repeat="artifact in artifacts track by $index" - data-ng-show="!artifact.esId" - data-tests-id="{{artifact.artifactDisplayName}}" - translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_HEAT" - translate-values="{'name': '{{artifact.artifactDisplayName}}'}" - data-ng-click="addOrUpdate(artifact)"></button> - - <!-- Top add button --> - <button class="add-button" translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER" data-ng-click="addOrUpdate({})"></button> - </perfect-scrollbar> - </form> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.less b/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.less deleted file mode 100644 index 043fba3277..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.less +++ /dev/null @@ -1,107 +0,0 @@ -.artifact-deployment-step { - - .table-container-flex .table .body .data-row + div.item-opened { - padding: 10px 40px 10px 30px; - } - - .w-sdc-classic-btn { - float: right; - margin-bottom: 10px; - } - - .table { - height:412px; - margin-bottom: 0; - } - - .parameter-description { - .circle(18px, @color_p); - content: '?'; - line-height: 18px; - vertical-align: middle; - margin-left: 5px; - cursor: default; - display: inline-block; - position: absolute; - top: 16px; - } - - .table-container-flex { - - margin-top: 0px; - - .flex-item:nth-child(1) { - flex-grow: 15; - padding: 5px 4px; - .hand; - span.table-arrow { - margin-right: 7px; - - } - } - - .flex-item:nth-child(2) { - padding: 5px 4px; - flex-grow: 6; - } - - .flex-item:nth-child(3) { - padding: 5px 4px; - flex-grow: 9; - } - - .flex-item:nth-child(4) { - padding: 5px 4px; - flex-grow: 3; - padding-top: 10px; - } - } - .w-sdc-form{ - text-align: left; - - .w-sdc-env-params{ - border-top: 1px solid #cdcdcd; - margin: 25px 0 10px 0; - } - - .i-sdc-form-textarea { - border: 1px solid @color_e; - min-height: 60px; - padding: 10px 13px; - width: 100%; - resize: none; - - &:disabled { - .disabled; - } - } - - .w-sdc-form-item { - &.error { - .i-sdc-form-input, - .i-sdc-form-select, - .i-sdc-form-textarea { - border-color: @color_h; - outline: none; - box-sizing: border-box; - } - } - } - - .i-sdc-env-form-label{ - .p_9; - overflow: hidden; - max-width: 245px; - text-overflow: ellipsis; - display: inline-block; - white-space: nowrap; - margin-top: 14px; - - &.required::before { - color: #f33; - content: '*'; - margin-right: 4px; - } - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.ts b/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.ts deleted file mode 100644 index 80f145b9b1..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.ts +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - import ArtifactModel = Sdc.Models.ArtifactModel; - - interface IArtifactDeploymentStepViewModelScope extends IWizardCreationStepScope { - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - component: Models.Components.Component; - artifacts: Array<Models.ArtifactModel>; - editForm:ng.IFormController; - isLoading:boolean; - artifactDescriptions:any; - updateInProgress:boolean; - - addOrUpdate(artifact:Models.ArtifactModel): void; - update(artifact:Models.ArtifactModel): void; - delete(artifact:Models.ArtifactModel): void; - sort(sortBy:string): void; - noArtifactsToShow():boolean; - getValidationPattern(validationType:string, parameterType?:string):RegExp; - validateJson(json:string):boolean; - resetValue(parameter:any):void; - } - - export class ArtifactDeploymentStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ValidationUtils', - 'ModalsHandler' - ]; - - constructor( - private $scope:IArtifactDeploymentStepViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private validationUtils: Sdc.Utils.ValidationUtils, - private ModalsHandler: Utils.ModalsHandler - ){ - this.$scope.registerChild(this); - this.$scope.setValidState(true); - this.initScope(); - } - - private initDescriptions = ():void =>{ - this.$scope.artifactDescriptions = {}; - _.forEach(this.$scope.component.deploymentArtifacts,(artifact:Models.ArtifactModel):void => { - this.$scope.artifactDescriptions[artifact.artifactLabel] = artifact.description; - }); - }; - - - private setArtifact = (artifact:Models.ArtifactModel):void =>{ - if(artifact.heatParameters) { - artifact.heatParameters.forEach((parameter:any):void => { - if (!parameter.currentValue && parameter.defaultValue) { - parameter.currentValue = parameter.defaultValue; - } else if ("" === parameter.currentValue) { - parameter.currentValue = null; - } - }); - } - if(!artifact.description || !this.$scope.getValidationPattern('string').test(artifact.description)){ - artifact.description = this.$scope.artifactDescriptions[artifact.artifactLabel]; - } - }; - - private updateAll = ():void =>{ - let artifacts:Array<Models.ArtifactModel>= []; - _.forEach(this.$scope.component.deploymentArtifacts,(artifact:Models.ArtifactModel): void => { - if(artifact.selected) { - this.setArtifact(artifact); - artifacts.push(artifact); - } - }); - this.$scope.component.updateMultipleArtifacts(artifacts); - }; - - - - private initScope = (): void => { - let self = this; - this.$scope.isLoading = false; - this.$scope.updateInProgress = false; - this.$scope.component = this.$scope.getComponent(); - this.initDescriptions(); - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - - - this.$scope.tableHeadersList = [ - {title:'Name', property: 'artifactDisplayName'}, - {title:'Type', property: 'artifactType'}, - {title:'Deployment timeout', property: 'timeout'} - ]; - - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - this.$scope.getValidationPattern = (validationType:string, parameterType?:string):RegExp => { - return this.validationUtils.getValidationPattern(validationType, parameterType); - }; - - this.$scope.validateJson = (json:string):boolean => { - if(!json){ - return true; - } - return this.validationUtils.validateJson(json); - }; - - - this.$scope.addOrUpdate = (artifact:Models.ArtifactModel): void => { - artifact.artifactGroupType = 'DEPLOYMENT'; - let artifactCopy = new Models.ArtifactModel(artifact); - this.ModalsHandler.openWizardArtifactModal(artifactCopy, this.$scope.component).then(() => { - this.$scope.artifactDescriptions[artifactCopy.artifactLabel]= artifactCopy.description; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - }) - }; - - this.$scope.noArtifactsToShow = ():boolean =>{ - return !_.some(this.$scope.artifacts, 'esId'); - }; - - this.$scope.resetValue = (parameter:any):void => { - if(!parameter.currentValue && parameter.defaultValue){ - parameter.currentValue = parameter.defaultValue; - } - else if('boolean'==parameter.type){ - parameter.currentValue = parameter.currentValue.toUpperCase(); - } - }; - - - this.$scope.$watch('editForm.$valid', ():void => { - if(this.$scope.editForm) { - this.$scope.setValidState(this.$scope.editForm.$valid); - } - }); - - this.$scope.update = (artifact:Models.ArtifactModel):void =>{ - if(false == this.$scope.isLoading) { - if(artifact.selected) { - this.$scope.isLoading = true; - this.$scope.updateInProgress = true; - let onSuccess = (responseArtifact:Models.ArtifactModel):void => { - this.$scope.artifactDescriptions[responseArtifact.artifactLabel] = responseArtifact.description; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - this.$scope.isLoading = false; - this.$scope.updateInProgress = false; - artifact.selected = !artifact.selected; - }; - - let onFailed = (error:any):void => { - console.log('Delete artifact returned error:', error); - this.$scope.isLoading = false; - this.$scope.updateInProgress = false; - artifact.selected = !artifact.selected; - }; - - this.setArtifact(artifact); - this.$scope.component.addOrUpdateArtifact(artifact).then(onSuccess, onFailed); - } else { - artifact.selected = !artifact.selected; - } - } - }; - - this.$scope.delete = (artifact:Models.ArtifactModel):void => { - let onOk = ():void => { - this.$scope.isLoading = true; - let onSuccess = ():void => { - this.$scope.isLoading = false; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - }; - - let onFailed = (error:any):void => { - this.$scope.isLoading = false; - console.log('Delete artifact returned error:', error); - }; - - this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); - }; - - let title:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); - let message:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - }; - - public save = (callback:Function):void => { - this.updateAll(); - this.$scope.setComponent(this.$scope.component); - callback(true); - }; - - public back = (callback:Function):void => { - this.$scope.setComponent(this.$scope.component); - callback(true); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view-model.ts b/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view-model.ts deleted file mode 100644 index 459729c179..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view-model.ts +++ /dev/null @@ -1,304 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - - export interface IEditArtifactStepModel { - artifactResource: Models.ArtifactModel; - artifactTypes: Array<string>; - artifactsFormList: any; - artifactFile:any; - } - - export interface IArtifactResourceFormStepViewModelScope extends ng.IScope { - editForm:ng.IFormController; - forms:any; - footerButtons: Array<any>; - isNew: boolean; - isPlaceHolderArtifact:boolean; - isLoading: boolean; - validationPattern: RegExp; - urlValidationPattern: RegExp; - labelValidationPattern: RegExp; - integerValidationPattern: RegExp; - commentValidationPattern: RegExp; - artifactType: string; - artifactGroupType:string; - editArtifactResourceModel: IEditArtifactStepModel; - defaultHeatTimeout: number; - validExtensions: any; - originalArtifactName: string; - modalInstanceArtifact:ng.ui.bootstrap.IModalServiceInstance; - selectedArtifact:string; - - fileExtensions():string; - save(): void; - close(): void; - changeArtifact(selectedArtifact:string):void; - getOptions(): Array<string>; - removeInputLabel(): void; - fileUploadRequired():string; - isDeploymentHeat():boolean; - setDefaultTimeout():void; - getFormTitle():string; - } - - export class ArtifactResourceFormStepViewModel { - - static '$inject' = [ - '$scope', - '$modalInstance', - 'artifact', - 'component', - 'Sdc.Services.CacheService', - 'ValidationPattern', - 'UrlValidationPattern', - 'LabelValidationPattern', - 'IntegerValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - 'ArtifactsUtils', - '$state', - '$modal', - '$templateCache' - ]; - - private formState:Utils.Constants.FormState; - private entityId:string; - - constructor(private $scope:IArtifactResourceFormStepViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private artifact:Models.ArtifactModel, - private component:Models.Components.Component, - private cacheService:Services.CacheService, - private ValidationPattern:RegExp, - private UrlValidationPattern:RegExp, - private LabelValidationPattern:RegExp, - private IntegerValidationPattern:RegExp, - private CommentValidationPattern:RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils, - private ArtifactsUtils:Sdc.Utils.ArtifactsUtils, - private $state:any, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService) { - - - this.entityId = this.component.uniqueId; - this.formState = angular.isDefined(artifact.artifactLabel) ? Utils.Constants.FormState.UPDATE : Utils.Constants.FormState.CREATE; - - this.initScope(); - this.initEditArtifactResourceModel(); - this.initComponent(); - this.initArtifactTypes(); - } - - private initEditArtifactResourceModel = ():void => { - this.$scope.editArtifactResourceModel = { - artifactResource: null, - artifactTypes: null, - artifactsFormList: {}, - artifactFile: {} - } - }; - - private initComponent = ():void => { - this.$scope.editArtifactResourceModel.artifactResource = this.artifact; - this.$scope.originalArtifactName = this.artifact.artifactName; - let artifacts:any = Utils.Constants.ArtifactGroupType.INFORMATION === this.artifact.artifactGroupType? - this.component.artifacts : this.component.deploymentArtifacts; - this.$scope.editArtifactResourceModel.artifactsFormList = _.pick(artifacts, (artifact:Models.ArtifactModel)=> { - return artifact.artifactLabel && !artifact.esId; - }); - this.$scope.editArtifactResourceModel.artifactFile.filename= this.artifact.artifactName?this.artifact.artifactName:''; - - if(this.artifact.artifactLabel){//this is edit mode - this.$scope.editArtifactResourceModel.artifactsFormList[this.artifact.artifactLabel]= this.artifact; - this.$scope.selectedArtifact = this.artifact.artifactDisplayName; - } - }; - - private initArtifactTypes = ():void => { - let artifactTypes:any = this.cacheService.get('UIConfiguration'); - - if (Utils.Constants.ArtifactGroupType.INFORMATION === this.artifact.artifactGroupType) { - this.$scope.editArtifactResourceModel.artifactTypes = artifactTypes.artifacts.other.map((element:any)=> { - return element.name; - }); - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { - return _.has(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES, item) || - _.has(Utils.Constants.ArtifactType.TOSCA, item); - }) - }else if(Utils.Constants.ArtifactGroupType.DEPLOYMENT === this.artifact.artifactGroupType) { - - this.$scope.validExtensions = artifactTypes.artifacts.deployment.resourceDeploymentArtifacts; - if(this.$scope.validExtensions) { - this.$scope.editArtifactResourceModel.artifactTypes = Object.keys(this.$scope.validExtensions); - } - this.$scope.defaultHeatTimeout = artifactTypes.defaultHeatTimeout; - - if(!this.$scope.isPlaceHolderArtifact) { - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { - return Utils.Constants.ArtifactType.HEAT == item.substring(0,4) || - _.has(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES, item); - }) - } - - if(this.component.isResource() && (<Resource>this.component).isCsarComponent()) { - _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string) => { - return this.ArtifactsUtils.isLicenseType(item); - }) - } - } - }; - - private initScope = ():void => { - - this.$scope.modalInstanceArtifact = this.$modalInstance; - this.$scope.validationPattern = this.ValidationPattern; - this.$scope.urlValidationPattern = this.UrlValidationPattern; - this.$scope.labelValidationPattern = this.LabelValidationPattern; - this.$scope.integerValidationPattern = this.IntegerValidationPattern; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - this.$scope.isLoading = false; - this.$scope.isPlaceHolderArtifact = true; - this.$scope.isNew = (this.formState === Utils.Constants.FormState.CREATE); - this.$scope.artifactGroupType = this.artifact.artifactGroupType; - this.$scope.selectedArtifact = '?'; - - this.$scope.fileExtensions = ():string => { - let type:string = this.$scope.editArtifactResourceModel.artifactResource.artifactType; - return type && this.$scope.validExtensions && this.$scope.validExtensions[type].acceptedTypes ? - this.$scope.validExtensions[type].acceptedTypes.join(',') : ""; - }; - - this.$scope.removeInputLabel = ():void => { - this.$scope.isPlaceHolderArtifact = true; - }; - - this.$scope.fileUploadRequired = ():string => { - if (this.$scope.isNew===false){ - return 'false'; // This is edit mode - } else { - return 'true'; - } - }; - - this.$scope.isDeploymentHeat = ():boolean =>{ - return Utils.Constants.ArtifactGroupType.DEPLOYMENT === this.artifact.artifactGroupType - && this.$scope.editArtifactResourceModel.artifactResource - && this.$scope.editArtifactResourceModel.artifactResource.artifactType - && Utils.Constants.ArtifactType.HEAT === this.$scope.editArtifactResourceModel.artifactResource.artifactType.substring(0,4); - }; - - this.$scope.getFormTitle =(): string =>{ - let title:string = this.artifact.esId? 'Update':'Add'; - if (Utils.Constants.ArtifactGroupType.DEPLOYMENT === this.artifact.artifactGroupType) { - title += ' Deployment'; - } - title += ' Artifact'; - return title; - }; - - this.$scope.setDefaultTimeout = ():void => { - if(!this.$scope.editArtifactResourceModel.artifactResource.timeout) { - this.$scope.editArtifactResourceModel.artifactResource.timeout = this.$scope.defaultHeatTimeout; - } - }; - - this.$scope.changeArtifact = (selectedArtifact:string):void => { - let tempArtifact:Models.ArtifactModel = this.$scope.editArtifactResourceModel.artifactResource; - this.$scope.editArtifactResourceModel.artifactResource = null; - - if (selectedArtifact && selectedArtifact != '' && selectedArtifact != '?') { - let artifactResource = <Models.ArtifactModel>_.find(this.$scope.editArtifactResourceModel.artifactsFormList,{'artifactDisplayName':selectedArtifact}); - this.$scope.editArtifactResourceModel.artifactResource = new Sdc.Models.ArtifactModel(artifactResource); - this.$scope.originalArtifactName = this.$scope.editArtifactResourceModel.artifactResource.artifactName; - this.$scope.isPlaceHolderArtifact = true; - if(this.$scope.isDeploymentHeat()){ - this.$scope.setDefaultTimeout(); - } - } else if (selectedArtifact === "") { - //this.$scope.editArtifactResourceModel.artifactFile = {}; - this.$scope.editArtifactResourceModel.artifactResource = <Models.ArtifactModel>{}; - this.$scope.editArtifactResourceModel.artifactResource.artifactGroupType = this.$scope.artifactGroupType; - this.$scope.isPlaceHolderArtifact = false; - } - - if (_.size(this.$scope.editArtifactResourceModel.artifactFile) && this.$scope.editArtifactResourceModel.artifactResource) { - this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; - } - if(tempArtifact && tempArtifact.description != ''){ - this.$scope.editArtifactResourceModel.artifactResource.description = tempArtifact.description; - } - - this.initArtifactTypes(); - this.$scope.isNew = true; - - }; - - - this.$scope.save = ():void => { - this.$scope.isLoading = true; - this.$scope.editArtifactResourceModel.artifactResource.description = - this.ValidationUtils.stripAndSanitize(this.$scope.editArtifactResourceModel.artifactResource.description); - - if (this.$scope.editArtifactResourceModel.artifactFile) { - this.$scope.editArtifactResourceModel.artifactResource.payloadData = this.$scope.editArtifactResourceModel.artifactFile.base64; - this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; - } - - let onFailed = (response) => { - this.$scope.isLoading = false; - console.info('onFaild', response); - this.$scope.editArtifactResourceModel.artifactResource.esId = undefined; - }; - - let onSuccess = () => { - this.$scope.isLoading = false; - this.$scope.originalArtifactName = ""; - this.$modalInstance.close(); - - }; - - this.component.addOrUpdateArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFailed); - }; - - - this.$scope.close = ():void => { - this.$modalInstance.dismiss(); - }; - - //new form layout for import asset - this.$scope.forms = {}; - this.$scope.footerButtons = [ - {'name': this.artifact.esId ? 'Update' : 'Add', 'css': 'blue', 'callback': this.$scope.save}, - {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} - ]; - - this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - }); - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view.html b/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view.html deleted file mode 100644 index 2643b99c20..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step-view.html +++ /dev/null @@ -1,147 +0,0 @@ -<sdc-modal modal="modalInstanceArtifact" type="classic" class="sdc-add-artifact" buttons="footerButtons" header="{{getFormTitle()}}" show-close-button="true"> - - <loader data-display="isLoading"></loader> - - <form novalidate class="w-sdc-form two-columns" name="forms.editForm"> - - <!--------------------- ARTIFACT FILE --------------------> - <div class="i-sdc-form-item"> - <label class="required">Upload File</label> - <file-upload id="fileUploadElement" - form-element="forms.editForm" - element-required="{{fileUploadRequired()}}" - element-name="myArtifactFile" - file-model="editArtifactResourceModel.artifactFile" - extensions="{{fileExtensions()}}" - data-ng-class="{'error': forms.editForm.myArtifactFile.$dirty && forms.editForm.myArtifactFile.$invalid}"></file-upload> - - <div class="input-error-file-upload" data-ng-show="forms.editForm.myArtifactFile.$dirty && forms.editForm.myArtifactFile.$invalid"> - <span ng-show="forms.editForm.myArtifactFile.$error.required && !forms.editForm.myArtifactFile.$error.emptyFile" translate="ADD_ARTIFACT_ERROR_FILE_REQUIRED"></span> - <span ng-show="forms.editForm.myArtifactFile.$error.maxsize" translate="VALIDATION_ERROR_MAX_FILE_SIZE"></span> - <span ng-if="'DEPLOYMENT' === artifactGroupType" ng-show="forms.editForm.myArtifactFile.$error.filetype" translate="ADD_ARTIFACT_ERROR_VALID_EXTENSIONS" translate-values="{'extensions': '{{fileExtensions()}}'}"></span> - <span ng-show="forms.editForm.myArtifactFile.$error.emptyFile" translate="VALIDATION_ERROR_EMPTY_FILE"></span> - </div> - </div> - <!--------------------- ARTIFACT FILE --------------------> - - <div class="w-sdc-form-columns-wrapper"> - <div class="w-sdc-form-column"> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.placeHolder.$dirty && forms.editForm.placeHolder.$invalid)}" data-ng-show="isPlaceHolderArtifact"> - <label class="i-sdc-form-label required">Artifact</label> - <select class="i-sdc-form-select" - name="placeHolder" - data-ng-disabled="!isNew" - data-ng-model="selectedArtifact" - data-ng-change="changeArtifact(selectedArtifact)" - data-tests-id="selectArtifact"> - <option disabled value="?">Select Artifact</option> - <option data-ng-repeat="(key,value) in editArtifactResourceModel.artifactsFormList">{{value.artifactDisplayName}}</option> - <option value="">Create New Artifact</option> - - </select> - - <div class="input-error" data-ng-show="forms.editForm.placeHolder.$dirty && forms.editForm.placeHolder.$invalid"> - <span ng-show="forms.editForm.placeHolder.$error.required" translate="ADD_ARTIFACT_ERROR_TYPE_REQUIRED"></span> - </div> - </div> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.artifactLabel.$dirty && forms.editForm.artifactLabel.$invalid)}" data-ng-show="!isPlaceHolderArtifact"> - <label class="i-sdc-form-label required">Artifact Label</label> - <input class="i-sdc-form-input" - data-ng-maxlength="25" - data-ng-model="editArtifactResourceModel.artifactResource.artifactLabel" - type="text" - name="artifactLabel" - data-required - data-ng-model-options="{ debounce: 200 }" - data-ng-pattern="labelValidationPattern" - maxlength="25" - data-ng-disabled="!isNew || editArtifactResourceModel.artifactResource.mandatory" - data-tests-id="artifactLabel" - autofocus/> - <span class="w-sdc-icon-cancel" data-ng-click="selectedArtifact='?'; removeInputLabel()"></span> - - <div class="input-error" data-ng-show="forms.editForm.artifactLabel.$dirty && forms.editForm.artifactLabel.$invalid"> - <span ng-show="forms.editForm.artifactLabel.$error.required" translate="ADD_ARTIFACT_ERROR_LABEL_REQUIRED"></span> - <span ng-show="forms.editForm.artifactLabel.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '25' }"></span> - <span ng-show="forms.editForm.artifactLabel.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.timeout.$dirty && forms.editForm.timeout.$invalid)}" - data-ng-if="isDeploymentHeat()"> - <label class="i-sdc-form-label">Deployment Timeout (minutes)</label> - <input class="i-sdc-form-input" - data-ng-maxlength="25" - data-ng-model="editArtifactResourceModel.artifactResource.timeout" - type="number" - name="timeout" - min="1" - max="2147483647" - data-ng-model-options="{ debounce: 200 }" - data-ng-pattern="integerValidationPattern" - data-ng-init="setDefaultTimeout()" - data-ng-change="setDefaultTimeout()" - maxlength="25" - data-tests-id="timeout"/> - - <div class="input-error" data-ng-show="forms.editForm.timeout.$dirty && forms.editForm.timeout.$invalid"> - <span ng-show="forms.editForm.timeout.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '25' }"></span> - <span ng-show="forms.editForm.timeout.$error.pattern" translate="ADD_ARTIFACT_ERROR_TIMEOUT_PATTERN"></span> - <span ng-show="forms.editForm.timeout.$error.min" translate="ADD_ARTIFACT_ERROR_TIMEOUT_MIN"></span> - </div> - </div> - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}"> - <label class="i-sdc-form-label required">Type</label> - <select class="i-sdc-form-select" - data-required - name="type" - data-ng-disabled="!isNew || editArtifactResourceModel.artifactResource.mandatory || '?'==selectedArtifact" - data-ng-model="editArtifactResourceModel.artifactResource.artifactType" - data-ng-options="type as type for type in editArtifactResourceModel.artifactTypes track by type | uppercase" - data-tests-id="artifacttype"> - <option value="">Choose Type</option> - </select> - - <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid"> - <span ng-show="forms.editForm.type.$error.required" translate="ADD_ARTIFACT_ERROR_TYPE_REQUIRED"></span> - </div> - - </div> - </div> - - <div class="w-sdc-form-column"> - - <div class="i-sdc-form-item" - data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}"> - <label class="i-sdc-form-label required">Description</label> - <textarea class="i-sdc-form-textarea" - data-ng-maxlength="256" - maxlength="256" - data-required - name="description" - data-ng-model="editArtifactResourceModel.artifactResource.description" - data-ng-model-options="{ debounce: 200 }" - data-ng-pattern="commentValidationPattern" - data-tests-id="description" - > - </textarea> - - <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid"> - <span ng-show="forms.editForm.description.$error.required" translate="ADD_ARTIFACT_ERROR_DESCRIPTION_REQUIRED"></span> - <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> - <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - - </div> - </div> - </div> - - <span class="w-sdc-form-note" data-ng-show="forms.editForm.$invalid && false" translate="LABEL_ALL_FIELDS_ARE_MANDATORY"></span> - - </form> - -</sdc-modal> - - diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step.less b/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step.less deleted file mode 100644 index a189c12d62..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-form-step/artifact-form-step.less +++ /dev/null @@ -1,45 +0,0 @@ -.sdc-add-artifact { - - .w-sdc-form-note { - .h_9; - display: block; - position: relative; - top: 13px; - } - - .w-sdc-form { - - .i-sdc-form-textarea{ - min-height: 95px; - } - - .i-sdc-form-item.upload input[type="file"] { - display: none - } - - .w-sdc-icon-cancel { - position: absolute; - right: 7px; - top: 33px; - .sprite; - .sprite.small-x-btn-black; - .hand; - } - } - - .artifact-info { - text-align: left; - color: rgb(140, 140, 140); - font-size: 13px; - margin-top: -40px; - margin-bottom: 5px; - width: 600px; - min-height: initial; - - span { - color: #666666; - padding-left: 4px; - } - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html b/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html deleted file mode 100644 index ea4566561c..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html +++ /dev/null @@ -1,48 +0,0 @@ -<div class="artifact-step" data-ng-controller="Sdc.ViewModels.Wizard.ArtifactInformationStepViewModel"> - <div data-tests-id="add-information-artifact-button" data-tests-id="addGrey" class="w-sdc-classic-btn gray" data-ng-click="addOrUpdate({})" type="button">Add </div> - <div class="table-container-flex"> - <div class="table"> - <div class="head flex-container"> - <div class="table-header head-row hand flex-item" ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} - <span data-ng-show="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> - </div> - <div class="table-no-text-header head-row flex-item"></div> - </div> - <div class="body"> - <perfect-scrollbar suppress-scroll-x="true" scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - <div data-ng-if="showNoArtifactMessage()" class="no-row-text"> - There are no information artifacts to display - </div> - <div data-ng-repeat-start="artifact in artifacts| orderBy:sortBy:reverse track by $index" - class="flex-container data-row" - data-ng-class="{'selected': artifact.selected}" - data-ng-if="artifact.esId"> - - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected"> - <span class="sprite table-arrow" data-ng-class="{'opened': artifact.selected}" data-tests-id="{{artifact.artifactDisplayName}}"></span> - {{artifact.artifactDisplayName}} - </div> - - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="{{artifact.artifactType}}"> - {{artifact.artifactType}} - </div> - - <div class="table-btn-col flex-item" sdc-keyboard-events> - <button class="table-edit-btn" data-ng-click="addOrUpdate(artifact)"></button> - <button class="table-delete-btn" data-ng-click="delete(artifact)"> </button> - </div> - </div> - <div data-ng-repeat-end="" data-ng-if="artifact.selected" class="item-opened" data-ng-bind="artifact.description"></div> - <button class="add-button" data-ng-repeat="artifact in artifacts track by $index" - data-ng-show="!artifact.esId" - data-tests-id="{{artifact.artifactDisplayName}}" - translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_HEAT" - translate-values="{'name': '{{artifact.artifactDisplayName}}'}" - data-ng-click="addOrUpdate(artifact)"></button> - <button class="add-button" translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER" - data-ng-click="addOrUpdate({})"></button> - </perfect-scrollbar> - </div> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.less b/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.less deleted file mode 100644 index b0600ca483..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.less +++ /dev/null @@ -1,50 +0,0 @@ -.artifact-step { - - .w-sdc-classic-btn { - float: right; - margin-bottom: 10px; - } - - .table{ - height: 412px; - margin-bottom: 0; - } - - .table-container-flex { - margin-top: 0px; - - .item-opened{ - word-wrap: break-word; - } - - - .flex-item:nth-child(1) { - padding: 5px 4px; - flex-grow: 15; - .hand; - span.table-arrow { - margin-right: 7px; - } - } - - .flex-item:nth-child(2) { - padding: 5px 4px; - flex-grow: 6; - } - - .flex-item:nth-child(3) { - padding: 5px 4px; - flex-grow: 3; - padding-top: 10px; - } - - .flex-item:nth-child(4) { - padding: 5px 4px; - flex-grow: 1; - } - - } - -} - - diff --git a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.ts b/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.ts deleted file mode 100644 index f6e25a53a3..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.ts +++ /dev/null @@ -1,168 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - import ArtifactModel = Sdc.Models.ArtifactModel; - - export interface IArtifactInformationStepScope extends IWizardCreationScope { - artifacts: Array<Models.ArtifactModel>; - tableHeadersList: Array<any>; - artifactType: string; - isResourceInstance:boolean; - downloadFile:Models.IFileDownload; - isLoading:boolean; - sortBy:string; - reverse:boolean; - component:Models.Components.Component; - - getTitle(): string; - addOrUpdate(artifact:Models.ArtifactModel): void; - delete(artifact:Models.ArtifactModel): void; - download(artifact:Models.ArtifactModel): void; - clickArtifactName(artifact:any):void; - openEditEnvParametersModal(artifactResource: Models.ArtifactModel):void; - sort(sortBy:string): void; - showNoArtifactMessage():boolean; - } - - export class ArtifactInformationStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'Sdc.Services.SharingService', - '$state', - 'sdcConfig', - 'ModalsHandler' - ]; - - constructor(private $scope:IArtifactInformationStepScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private sharingService:Sdc.Services.SharingService, - private $state:any, - private sdcConfig:Models.IAppConfigurtaion, - private ModalsHandler: Utils.ModalsHandler) { - this.$scope.registerChild(this); - this.$scope.setValidState(true); - this.initScope(); - } - - - private getMappedObjects():any { - return { - normal: this.$scope.component.artifacts - }; - } - - private initScope = ():void => { - let self = this; - this.$scope.isLoading = false; - this.$scope.sortBy = 'artifactDisplayName'; - this.$scope.reverse = false; - - this.$scope.artifactType = 'normal'; - this.$scope.getTitle = ():string => { - return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts'; - - }; - - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'artifactDisplayName'}, - {title: 'Type', property: 'artifactType'} - ]; - - - this.$scope.component = this.$scope.getComponent(); - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - - - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - - this.$scope.addOrUpdate = (artifact:Models.ArtifactModel):void => { - artifact.artifactGroupType = 'INFORMATIONAL'; - this.ModalsHandler.openWizardArtifactModal(artifact, this.$scope.getComponent()).then(() => { - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - }); - }; - - this.$scope.showNoArtifactMessage = ():boolean => { - let artifacts:any = []; - artifacts = _.filter(this.$scope.artifacts, (artifact:Models.ArtifactModel)=> { - return artifact.esId; - }); - - if (artifacts.length === 0) { - return true; - } - return false; - } - - this.$scope.delete = (artifact:Models.ArtifactModel):void => { - - let onOk = ():void => { - this.$scope.isLoading = true; - let onSuccess = ():void => { - this.$scope.isLoading = false; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - }; - - let onFailed = (error:any):void => { - console.log('Delete artifact returned error:', error); - this.$scope.isLoading = false; - }; - - this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); - }; - - let title:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - - this.$scope.clickArtifactName = (artifact:any) => { - if ('deployment' !== this.$scope.artifactType || 'HEAT' !== artifact.artifactType || !artifact.esId) { - this.$scope.addOrUpdate(artifact); - } - - }; - - } - - public save = (callback:Function):void => { - this.$scope.setComponent(this.$scope.component); - callback(true); - } - - public back = (callback:Function):void => { - callback(true); - } - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.html b/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.html deleted file mode 100644 index db975caf47..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.html +++ /dev/null @@ -1,270 +0,0 @@ -<div include-padding="true" class="sdc-wizard-general-step"> - <div ng-controller="Sdc.ViewModels.Wizard.GeneralStepViewModel"> - <form novalidate class="w-sdc-form" name="editForm"> - <div class="w-sdc-form-section-container"> - - <!--------------------- IMPORT TOSCA FILE --------------------> - <file-upload id="fileUploadElement" - ng-if="!isCreate" - element-name="fileElement" - element-disabled="{{!isNew}}" - form-element="editForm" - file-model="model.tosca" - extensions="{{toscaFileExtensions}}" - data-ng-class="{'error': !editForm.fileElement.$valid || !model.tosca.filename}"></file-upload> - - <div class="input-error-file-upload" data-ng-show="!isCreate && (!editForm.fileElement.$valid || !model.tosca.filename)"> - <!-- editForm.fileElement.$error.required <== Can not use this, because the browse is done from outside for the first time --> - <span ng-show="!model.tosca.filename && !editForm.fileElement.$error.emptyFile" translate="NEW_SERVICE_RESOURCE_ERROR_TOSCA_FILE_REQUIRED"></span><!-- Required --> - <span ng-show="editForm.fileElement.$error.emptyFile" translate="VALIDATION_ERROR_EMPTY_FILE"></span> - <span ng-show="editForm.fileElement.$error.filetype" translate="NEW_SERVICE_RESOURCE_ERROR_VALID_TOSCA_EXTENSIONS" translate-values="{'extensions': '{{toscaFileExtensions}}' }"></span> - </div> - <!--------------------- IMPORT TOSCA FILE --------------------> - - <div class="w-sdc-form-columns-wrapper"> - - <div class="w-sdc-form-column"> - - <!--------------------- NAME --------------------> - <div class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.componentName)}"> - <label class="i-sdc-form-label required">Name</label> - <input class="i-sdc-form-input" - name="componentName" - data-ng-init="isNew && validateName(true)" - data-ng-change="validateName()" - data-ng-maxlength="{{component.isProduct()?'25':'50'}}" - maxlength="{{component.isProduct()?'25':'50'}}" - data-ng-minlength="{{component.isProduct()?'4':'0'}}" - minlength="{{component.isProduct()?'4':'0'}}" - data-ng-model="model.name" - type="text" - data-required - data-ng-model-options="{ debounce: 500 }" - data-ng-pattern="validation.validationPattern" - data-ng-disabled="model.isAlreadyCertified" - data-tests-id="name" - autofocus - /> - - <div class="input-error" data-ng-show="validateField(editForm.componentName)"> - <span ng-show="editForm.componentName.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_RESOURCE_NAME_REQUIRED"></span> - <span ng-show="editForm.componentName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> - <span ng-show="editForm.componentName.$error.minlength" translate="VALIDATION_ERROR_MIN_LENGTH" translate-values="{'min': '4' }"></span> - <span ng-show="editForm.componentName.$error.nameExist" translate="NEW_SERVICE_RESOURCE_ERROR_NAME_EXISTS"></span> - <span ng-show="editForm.componentName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - <!--------------------- NAME --------------------> - - <!--------------------- FULL NAME --------------------> - <div ng-if="component.isProduct()" class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.fullName)}"> - <label class="i-sdc-form-label required">Full Name</label> - <input class="i-sdc-form-input" - name="fullName" - data-ng-change="validateName()" - data-ng-maxlength="100" - maxlength="100" - data-ng-minlength="4" - minlength="4" - data-ng-model="model.fullName" - type="text" - data-required - data-ng-model-options="{ debounce: 500 }" - data-ng-pattern="validation.validationPattern" - data-tests-id="fullName" - autofocus - /> - - <div class="input-error" data-ng-show="validateField(editForm.fullName)"> - <span ng-show="editForm.fullName.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_RESOURCE_NAME_REQUIRED"></span> - <span ng-show="editForm.fullName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> - <span ng-show="editForm.fullName.$error.minlength" translate="VALIDATION_ERROR_MIN_LENGTH" translate-values="{'min': '4' }"></span> - <span ng-show="editForm.fullName.$error.nameExist" translate="NEW_SERVICE_RESOURCE_ERROR_NAME_EXISTS"></span> - <span ng-show="editForm.fullName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - <!--------------------- NAME --------------------> - - <!--------------------- DESCRIPTION --------------------> - <div class="i-sdc-form-item" - data-ng-class="{'error': validateField(editForm.description)}"> - <label class="i-sdc-form-label required">Description</label> - <textarea class="i-sdc-form-textarea description" - name="description" - data-ng-maxlength="1024" - data-required - data-ng-model="model.description" - data-ng-model-options="{ debounce: 500 }" - data-ng-pattern="validation.commentValidationPattern" - maxlength="1024" - data-tests-id="description"></textarea> - <!-- placeholder="Description here..." --> - - <div class="input-error" data-ng-show="validateField(editForm.description)"> - <span ng-show="editForm.description.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_RESOURCE_DESCRIPTION_REQUIRED"></span> - <span ng-show="editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '1024' }"></span> - <span ng-show="editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - <!--------------------- DESCRIPTION --------------------> - - <!--------------------- CATEGORIES --------------------> - <div class="i-sdc-form-item" - data-ng-class="{'error': validateField(editForm.category)}" - data-ng-if="categories && categories.length && !component.isProduct()"> - <label class="i-sdc-form-label required">Category</label> - <select class="i-sdc-form-select" - data-required - name="category" - data-ng-change="setIconToDefault()" - data-ng-disabled="model.isAlreadyCertified" - data-ng-model="model.category" - data-tests-id="selectGeneralCategory" - > - <option value="">Select category</option> - <optgroup ng-if="component.isResource()" data-ng-repeat="mainCategory in categories | orderBy:['name']" label="{{mainCategory.name}}" data-tests-id="{{mainCategory.name}}"> - <option data-ng-repeat="subCategory in mainCategory.subcategories track by $index" - data-ng-selected="model.category===calculateUnique(mainCategory.name,subCategory.name)" - data-tests-id="{{subCategory.name}}" - value="{{calculateUnique(mainCategory.name,subCategory.name)}}">{{subCategory.name}} - - </option> - </optgroup> - <option ng-if="component.isService()" data-ng-repeat="mainCategory in categories | orderBy:['name']" - data-ng-selected="model.category===mainCategory.name" - value="{{mainCategory.name}}" - data-tests-id="{{mainCategory.name}}">{{mainCategory.name}}</option> - </select> - - <div class="input-error" data-ng-show="validateField(editForm.category)"> - <span ng-show="editForm.category.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_CATEGORY_REQUIRED"></span> - </div> - </div> - <!--------------------- CATEGORIES --------------------> - - <!--------------------- VENDOR NAME --------------------> - <div ng-if="component.isResource()" class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.vendorName)}"> - <label class="i-sdc-form-label required">Vendor</label> - <input class="i-sdc-form-input" type="text" - data-ng-model="model.vendorName" - data-ng-model-options="{ debounce: 500 }" - data-ng-maxlength="25" - data-required - ng-click="oldValue = model.vendorName" - name="vendorName" - data-ng-change="onVendorNameChange(oldValue)" - data-ng-pattern="validation.vendorValidationPattern" - maxlength="25" - data-ng-disabled="model.isAlreadyCertified" - data-tests-id="vendorName" - /> - - <div class="input-error" data-ng-show="validateField(editForm.vendorName)"> - <span ng-show="editForm.vendorName.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_VENDOR_NAME_REQUIRED"></span> - <span ng-show="editForm.vendorName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '25' }"></span> - <span ng-show="editForm.vendorName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - - </div> - - <!--------------------- VENDOR NAME --------------------> - - <!--------------------- VENDOR RELEASE --------------------> - <div ng-if="component.isResource()" - class="i-sdc-form-item" - data-ng-class="{'error': validateField(editForm.vendorRelease)}"> - <label class="i-sdc-form-label required">Vendor Release</label> - <input class="i-sdc-form-input" type="text" - data-ng-model="model.vendorRelease" - data-ng-model-options="{ debounce: 500 }" - data-ng-maxlength="25" - data-required - name="vendorRelease" - data-ng-pattern="validation.vendorValidationPattern" - maxlength="25" - data-tests-id="vendorRelease" - /> - - <div class="input-error" data-ng-show="validateField(editForm.vendorRelease)"> - <span ng-show="editForm.vendorRelease.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_VENDOR_RELEASE_REQUIRED"></span> - <span ng-show="editForm.vendorRelease.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '128' }"></span> - <span ng-show="editForm.vendorRelease.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - <!--------------------- VENDOR RELEASE --------------------> - - - - </div><!-- Close w-sdc-form-column --> - - <div class="w-sdc-form-column"> - - <!--------------------- RESOURCE TAGS --------------------> - <div class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.tags)}"> - <label class="i-sdc-form-label">Tags</label> - - <sdc-tags form-element="editForm" element-name="tags" max-tags="20" class="i-sdc-form-item-tags" tags="model.tags" pattern="validation.tagValidationPattern" special-tag="model.name"></sdc-tags> - - <div class="input-error" data-ng-show="validateField(editForm.tags)"> - <span ng-show="editForm.tags.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - <!--------------------- RESOURCE TAGS --------------------> - - <!--------------------- CONTACT ID --------------------> - <div class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.contactId)}"> - <label class="i-sdc-form-label required" translate="GENERAL_LABEL_CONTACT_ID"></label> - <input class="i-sdc-form-input disabled" type="text" - data-ng-model="model.userId" - data-required - name="contactId" - data-ng-pattern="validation.contactIdValidationPattern" - data-ng-model-options="{ debounce: 500 }" - data-tests-id="userId" - maxlength="50" - /> - - <div class="input-error" data-ng-show="validateField(editForm.contactId)"> - <span ng-show="editForm.contactId.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_CONTACT_REQUIRED"></span> - <span ng-show="editForm.contactId.$error.pattern" translate="NEW_SERVICE_RESOURCE_ERROR_CONTACT_NOT_VALID"></span> - </div> - </div> - <!--------------------- CONTACT ID --------------------> - - <!--------------------- PROJECT CODE --------------------> - <div class="i-sdc-form-item" data-ng-if="!component.isResource()" - data-ng-class="{'error': validateField(editForm.projectCode)}"> - <label class="i-sdc-form-label required" translate="GENERAL_LABEL_PROJECT_CODE"></label> - <input class="i-sdc-form-input" type="text" - data-ng-model="model.projectCode" - data-ng-model-options="{ debounce: 500 }" - data-ng-maxlength="128" - data-required - name="projectCode" - data-ng-pattern="validation.projectCodeValidationPattern" - maxlength="50" - data-tests-id="projectCode" - /> - - <div class="input-error" data-ng-show="validateField(editForm.projectCode)"> - <span ng-show="editForm.projectCode.$error.required" translate="NEW_SERVICE_RESOURCE_ERROR_PROJECT_CODE_REQUIRED"></span> - <span ng-show="editForm.projectCode.$error.pattern" translate="NEW_SERVICE_RESOURCE_ERROR_PROJECT_CODE_NOT_VALID"></span> - </div> - </div> - <!--------------------- VENDOR RELEASE --------------------> - - - </div><!-- Close w-sdc-form-column --> - - </div><!-- Close w-sdc-form-column --> - - <div class="w-sdc-form-messages-wrapper"> - <span class="w-sdc-form-messages-msg" data-ng-show="isSaved"><span class="w-sdc-form-messages-msg-v"></span>Your resource has been saved</span> - </div> - - </div><!-- Close w-sdc-form-section-container --> - - </form> - - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.less b/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.less deleted file mode 100644 index 700997a423..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.less +++ /dev/null @@ -1,34 +0,0 @@ -.sdc-wizard-general-step { - - .w-sdc-form { - padding: 0; - - .w-sdc-form-section-container { - text-align: center; - } - - .i-sdc-form-item { - &.upload { - margin-top: 0; - width: auto; - padding: 10px; - } - } - - .template-desc { - border: 1px dashed @border_color_f; - height: 130px; - overflow: hidden; - padding: 10px 6px 6px 6px; - margin-top: 10px; - } - - .sdc-tag .tag { - max-width: 225px; - } - - } - -} - - diff --git a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.ts b/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.ts deleted file mode 100644 index 74c681e433..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/general-step/general-step.ts +++ /dev/null @@ -1,381 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - import ISubCategory = Sdc.Models.ISubCategory; - import IMainCategory = Sdc.Models.IMainCategory; - 'use strict'; - - /* - * TODO: The template (derived from is not necessary here). - * Need to delete it from all remarks. - * */ - - export class UIModel { - tosca:Sdc.Directives.FileUploadModel; - name:string; - description:string; - vendorName:string; - vendorRelease:string; - category:string; - tags:Array<string>; - userId:string; - icon:string; - projectCode:string; - fullName:string; - isAlreadyCertified:boolean; - } - - export class Validation { - validationPattern: RegExp; - contactIdValidationPattern: RegExp; - tagValidationPattern: RegExp; - vendorValidationPattern: RegExp; - commentValidationPattern: RegExp; - projectCodeValidationPattern: RegExp; - } - - export interface IGeneralStepScope extends IWizardCreationStepScope { - model:UIModel; - validation:Validation; - editForm:ng.IFormController; - component: Models.Components.Component; - categories: Array<IMainCategory>; - latestComponentName:string; - latestCategoryId: string; - latestVendorName: string; - isNew:boolean; - toscaFileExtensions:any; - isCreate:boolean; - - onToscaFileChange():void - validateField(field:any):boolean; - validateName(isInit:boolean): void; - calculateUnique(mainCategory:string, subCategory:string):string; // Build unique string from main and sub category - calculatedTagsMaxLength():number; - setIconToDefault():void; - onVendorNameChange(oldVendorName: string): void; - } - - export class GeneralStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - 'Sdc.Services.CacheService', - 'ValidationPattern', - 'ContactIdValidationPattern', - 'TagValidationPattern', - 'VendorValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - 'sdcConfig', - 'ComponentFactory', - 'ProjectCodeValidationPattern' - ]; - - constructor(private $scope:IGeneralStepScope, - private cacheService:Services.CacheService, - private ValidationPattern:RegExp, - private ContactIdValidationPattern:RegExp, - private TagValidationPattern:RegExp, - private VendorValidationPattern:RegExp, - private CommentValidationPattern: RegExp, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private sdcConfig:Models.IAppConfigurtaion, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private ProjectCodeValidationPattern:RegExp - ) { - - this.$scope.registerChild(this); - this.initScopeValidation(); - this.initScopeMethods(); - this.initScope(); - this.$scope.isCreate = this.$scope.data.importFile === undefined; - } - - private initScopeValidation = (): void => { - this.$scope.validation = new Validation(); - this.$scope.validation.validationPattern = this.ValidationPattern; - this.$scope.validation.contactIdValidationPattern = this.ContactIdValidationPattern; - this.$scope.validation.tagValidationPattern = this.TagValidationPattern; - this.$scope.validation.vendorValidationPattern = this.VendorValidationPattern; - this.$scope.validation.commentValidationPattern = this.CommentValidationPattern; - this.$scope.validation.projectCodeValidationPattern = this.ProjectCodeValidationPattern; - }; - - private initScope = ():void => { - - // Init UIModel - this.$scope.model = new UIModel(); - - // Init categories - if(this.$scope.data.componentType === Utils.Constants.ComponentType.RESOURCE){ - this.$scope.categories = this.cacheService.get('resourceCategories'); - } - if (this.$scope.data.componentType === Utils.Constants.ComponentType.SERVICE) { - this.$scope.categories = this.cacheService.get('serviceCategories'); - } - - this.$scope.model.category=''; - - //init file extenstions - this.$scope.toscaFileExtensions = this.sdcConfig.toscaFileExtension; - - // Init Tosca import file - if (this.$scope.data.importFile) { - this.$scope.model.tosca = this.$scope.data.importFile; - } - - // Case insert or update - this.$scope.component = this.$scope.getComponent(); - if ( this.$scope.component!==undefined){ - // Update mode - - //this.$scope.latestCategoryId = this.$scope.component[0].uniqueId; - //this.$scope.latestVendorName = this.$scope.component.vendorName; - this.$scope.latestComponentName = this.$scope.component.name; - this.$scope.isNew=false; - this.resource2ModelUi(this.$scope.component); - } else { - // Create mode - this.$scope.isNew=true; - this.$scope.model.tags=[]; // Init tags - this.$scope.model.userId = this.cacheService.get("user").userId; // Fill user ID from logged in user - this.$scope.model.icon = Utils.Constants.DEFAULT_ICON; // Set the default icon - this.$scope.component = this.ComponentFactory.createEmptyComponent(this.$scope.data.componentType); - } - }; - - private initScopeMethods = ():void => { - - this.$scope.validateField = (field:any):boolean => { - if (field && field.$dirty && field.$invalid){ - return true; - } - return false; - }; - - this.$scope.validateName = (isInit:boolean):void => { - if (isInit===undefined){isInit=false;} - - let name = this.$scope.model.name; - if (!name || name===""){ - if (this.$scope.editForm - && this.$scope.editForm["componentName"] - && this.$scope.editForm["componentName"].$error){ - - // Clear the error name already exists - this.$scope.editForm["componentName"].$setValidity('nameExist', true); - } - - return; - } - let subtype:string = Utils.Constants.ComponentType.RESOURCE == this.$scope.data.componentType? - this.$scope.data.importFile? 'VFC':'VF' : undefined; - - let onFailed = (response) => { - //console.info('onFaild', response); - //this.$scope.isLoading = false; - }; - - let onSuccess = (validation:Models.IValidate) => { - this.$scope.editForm["componentName"].$setValidity('nameExist', validation.isValid); - }; - - if (isInit){ - // When page is init after update - if (this.$scope.model.name !== this.$scope.latestComponentName){ - if(!this.$scope.component.isProduct()) {//TODO remove when backend is ready - this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); - } - } - } else { - // Validating on change (has debounce) - if (this.$scope.editForm - && this.$scope.editForm["componentName"] - && this.$scope.editForm["componentName"].$error - && !this.$scope.editForm["componentName"].$error.pattern - && this.$scope.model.name !== this.$scope.latestComponentName - ) { - if(!this.$scope.component.isProduct()) { //TODO remove when backend is ready - this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); - } - } else if (this.$scope.model.name === this.$scope.latestComponentName) { - // Clear the error - this.$scope.editForm["componentName"].$setValidity('nameExist', true); - } - } - }; - - this.$scope.calculateUnique = (mainCategory:string, subCategory:string):string => { - let uniqueId: string = mainCategory; - if(subCategory) { - uniqueId += "_#_" + subCategory; // Set the select category combobox to show the selected category. - } - return uniqueId; - }; - - // Notify the parent if this step valid or not. - this.$scope.$watch("editForm.$valid", (newVal, oldVal) => { - //console.log("editForm validation: " + newVal); - this.$scope.setValidState(newVal); - }); - - this.$scope.setIconToDefault = ():void => { - this.$scope.model.icon = Utils.Constants.DEFAULT_ICON; - }; - - this.$scope.onVendorNameChange = (oldVendorName: string):void => { - if(this.$scope.component.icon === oldVendorName) { - this.$scope.setIconToDefault(); - } - }; - }; - - public save = (callback:Function):void => { - this.modelUi2Resource(); - - let onFailed = (response) => { - callback(false); - }; - - let onSuccess = (component:Models.Components.Component) => { - this.$scope.component = component; - this.$scope.setComponent(this.$scope.component); - this.$scope.latestComponentName = (component.name); - callback(true); - }; - - try { - //Send the form with attached tosca file. - if (this.$scope.isNew===true) { - this.ComponentFactory.createComponentOnServer(this.$scope.component).then(onSuccess, onFailed); - } else { - this.$scope.component.updateComponent().then(onSuccess, onFailed); - } - }catch(e){ - //console.log("ERROR: Error in updating/creating component: " + e); - callback(false); - } - - }; - - public back = (callback:Function):void => { - callback(true); - } - - // Fill the resource properties object with data from UIModel - private modelUi2Resource = ():void => { - - this.$scope.component.name = this.$scope.model.name; - this.$scope.component.description = this.ValidationUtils.stripAndSanitize(this.$scope.model.description); - this.$scope.component.vendorName = this.$scope.model.vendorName; - this.$scope.component.vendorRelease = this.$scope.model.vendorRelease; - this.$scope.component.tags = angular.copy(this.$scope.model.tags); - this.$scope.component.tags.push(this.$scope.model.name); - this.$scope.component.contactId = this.$scope.model.userId; - this.$scope.component.icon = this.$scope.model.icon; - - if(this.$scope.component.isResource()) { - (<Models.Components.Resource>this.$scope.component).resourceType = "VF"; - - // Handle the tosca file - if (this.$scope.model.tosca && this.$scope.isNew) { - (<Models.Components.Resource>this.$scope.component).payloadData = this.$scope.model.tosca.base64; - (<Models.Components.Resource>this.$scope.component).payloadName = this.$scope.model.tosca.filename; - } - - this.$scope.component.categories = this.convertCategoryStringToOneArray(); - } - - if(this.$scope.component.isProduct()) { - this.$scope.component.projectCode = this.$scope.model.projectCode; - // Handle the tosca file - this.$scope.component.categories = undefined; - (<Models.Components.Product>this.$scope.component).contacts = new Array<string>(); - (<Models.Components.Product>this.$scope.component).contacts.push(this.$scope.component.contactId); - (<Models.Components.Product>this.$scope.component).fullName = this.$scope.model.fullName; - } - - if(this.$scope.component.isService()) { - this.$scope.component.projectCode = this.$scope.model.projectCode; - this.$scope.component.categories = this.convertCategoryStringToOneArray(); - } - }; - - // Fill the UIModel from data from resource properties - private resource2ModelUi = (component: Models.Components.Component):void => { - this.$scope.model.name = component.name; - this.$scope.model.description = component.description; - this.$scope.model.vendorName = component.vendorName; - this.$scope.model.vendorRelease = component.vendorRelease; - this.$scope.model.tags = _.reject(component.tags, (item)=>{return item===component.name}); - this.$scope.model.userId = component.contactId; - this.$scope.model.icon = component.icon; - this.$scope.model.projectCode = component.projectCode; - this.$scope.model.isAlreadyCertified = component.isAlreadyCertified(); - - if(!this.$scope.component.isProduct()) { - this.$scope.model.category = this.convertCategoryOneArrayToString(component.categories); - } - - if(component.isProduct()) { - this.$scope.model.fullName = (<Models.Components.Product>component).fullName; - - } - - }; - - // Convert category string MainCategory_#_SubCategory to Array with one item (like the server except) - private convertCategoryStringToOneArray = ():Array<Models.IMainCategory> => { - let tmp = this.$scope.model.category.split("_#_"); - let mainCategory = tmp[0]; - let subCategory = tmp[1]; - - // Find the selected category and add the relevant sub category. - let selectedMainCategory:IMainCategory = <Models.IMainCategory>_.find(this.$scope.categories, function (item) { - return item["name"] === mainCategory - }); - let mainCategoryClone = jQuery.extend(true, {}, selectedMainCategory); - if(subCategory) { - mainCategoryClone['subcategories'] = [{ - "name": subCategory - }]; - } - let tmpSelected = <Models.IMainCategory> mainCategoryClone; - - let result:Array<Models.IMainCategory> = []; - result.push(tmpSelected); - - return result; - }; - - private convertCategoryOneArrayToString = (categories:Array<Models.IMainCategory>):string => { - let mainCategory:string = categories[0].name; - let subCategory:string = ''; - if(categories[0].subcategories) { - subCategory = categories[0].subcategories[0].name; - } - return this.$scope.calculateUnique(mainCategory, subCategory); - }; - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.html b/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.html deleted file mode 100644 index 7fc3e9224f..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.html +++ /dev/null @@ -1,40 +0,0 @@ -<div class="hierarchy-step" data-ng-controller="Sdc.ViewModels.Wizard.HierarchyStepViewModel"> - <div class="dropdown-container" clicked-outside="{onClickedOutside: 'clickOutside()', clickedOutsideEnable: 'true'}" > - <input placeholder="Add Group" data-ng-click="onInputTextClicked()" class="dropdown-input-text" data-ng-model="search.filterTerms" data-ng-model-options="{debounce: 200}"/> - <div data-ng-class="{'show': showDropDown}" class="dropdown-content" > - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="false" class="scrollbar-container"> - <div ng-repeat="category in categoriesOptions track by $index"> - <div ng-repeat="subcategory in category.subcategories track by $index"> - <div class="dropdown-option" ng-show="!category.filteredGroup || category.filteredGroup.length > 0"> - <div class="category-container"> - <div class="category">{{category.name}}</div> - <div class="subcategory">{{subcategory.name}}</div> - </div> - <div class="groupings-container"> - <div ng-init="group.filterTerms = group.name + ' ' + category.name + ' ' + subcategory.name" - ng-repeat="group in (category.filteredGroup = (subcategory.groupings | filter:search )) track by $index"> - <div class="group" data-ng-disabled="group.isDisabled" data-ng-class="{'disabled-group': group.isDisabled}" ng-click="onGroupSelected(category, subcategory, group)"> - <span >{{group.name}}</span> - </div> - </div> - </div> - </div> - </div> - </div> - </perfect-scrollbar> - </div> - </div> - <div class="hierarchy-groups-container"> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - <div ng-if="!product.categories.length || product.categories.length === 0" class="no-groups-text" translate="NEW_PRODUCT_NO_CATEGORIES_TO_DISPLAY"></div> - <div ng-repeat="category in product.categories track by $index"> - <div ng-repeat="subcategory in category.subcategories track by $index"> - <div class="group-tag" ng-repeat="group in subcategory.groupings track by $index" - data-ng-init="tooltip = '<b>' + category.name + '</b><br />' + subcategory.name"> - <sdc-tag data-on-delete="deleteGroup(uniqueId)" data-tag-data="{tag: group.name, tooltip: tooltip, id: group.uniqueId }"></sdc-tag> - </div> - </div> - </div> - </perfect-scrollbar> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.less b/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.less deleted file mode 100644 index 74786c127a..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.less +++ /dev/null @@ -1,125 +0,0 @@ -.hierarchy-step { - margin-top: 35px; - - .scrollbar-container{ - max-height:400px; - .perfect-scrollbar; - } - - .dropdown-container { - position: relative; - display: inline-block; - width: 100%; - - &:after{ - top: 47%; - right: 1%; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; - border-color: rgba(0, 0, 0, 0); - border-top-color: black; - border-width: 4px; - margin-left: -4px; - } - - .dropdown-input-text { - width: 100%; - padding: 4px 10px; - } - - .dropdown-content { - .perfect-scrollbar; - border: 1px solid #d8d8d8; - display: none; - position: absolute; - overflow: hidden; - width: 100%; - .bg_c; - max-height: 400px; - z-index: 999999; - - .dropdown-option { - border-bottom: 1px solid #d8d8d8; - display: inline-block; - width: 100%; - } - - .category-container{ - width: 250px; - float: left; - padding-left: 5px; - - .category { - .bold; - padding: 3px 3px 2px 3px; - &:after{ - .sprite; - .arrow-left; - content: ''; - margin-left: 5px; - transform: rotate(180deg); - } - } - .subcategory { - padding-left: 3px; - } - } - - .groupings-container{ - display: inline-block; - width: 424px; - border-left: 1px solid #d8d8d8; - min-height: 55px; - .group{ - padding: 3px 3px 3px 10px; - &:hover{ - .hand; - .bg_n; - } - &.disabled-group { - opacity: 0.5; - &:hover{ - cursor: auto; - .bg_c; - } - } - } - } - - .seperator { - height: 1px; - width: 100%; - .bg_j; - margin: 5px 0px; - } - } - .show { - display: block; - } - } - - .hierarchy-groups-container{ - .b_9; - width: 100%; - border: 1px solid #d8d8d8; - height: 425px; - padding: 15px; - text-align: center; - - .no-group-text{ - text-align: center; - margin-top:25px; - a { - cursor: pointer; - } - } - .group-tag{ - display: inline-block; - float: left; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.ts b/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.ts deleted file mode 100644 index a974c0af81..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.ts +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export interface IHierarchyStepScope extends IWizardCreationScope { - - categoriesOptions: Array<Models.IMainCategory>; - product:Models.Components.Product; - isLoading:boolean; - showDropDown:boolean; - - onInputTextClicked():void; - onGroupSelected(category: Models.IMainCategory, subcategory: Models.ISubCategory, group: Models.IGroup):void; - clickOutside():void; - deleteGroup(uniqueId:string):void; - } - - export class HierarchyStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - 'Sdc.Services.CacheService', - 'ComponentFactory' - ]; - - constructor(private $scope:IHierarchyStepScope, - private cacheService:Sdc.Services.CacheService, - private ComponentFactory: Sdc.Utils.ComponentFactory) { - - this.$scope.registerChild(this); - this.$scope.setValidState(true); - this.$scope.product = <Models.Components.Product>this.$scope.getComponent(); - this.initScope(); - } - - private initCategories = () => { - this.$scope.categoriesOptions = angular.copy(this.cacheService.get('productCategories')); - let selectedGroup:Array<Models.IGroup> = []; - _.forEach(this.$scope.product.categories, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - selectedGroup = selectedGroup.concat(subcategory.groupings); - }); - }); - _.forEach(this.$scope.categoriesOptions, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - _.forEach(subcategory.groupings, (group:Models.ISubCategory) => { - let componentGroup:Models.IGroup = _.find(selectedGroup, (componentGroupObj) => { - return componentGroupObj.uniqueId == group.uniqueId; - }); - if(componentGroup){ - group.isDisabled = true; - } - }); - }); - }); - }; - - private setFormValidation = ():void => { - if(!this.$scope.product.categories || this.$scope.product.categories.length === 0){ - this.$scope.setValidState(false); - } - else{ - this.$scope.setValidState(true); - } - - }; - - private initScope = ():void => { - this.$scope.isLoading= false; - this.$scope.showDropDown =false; - this.initCategories(); - this.setFormValidation(); - - this.$scope.onGroupSelected = (category: Models.IMainCategory, subcategory: Models.ISubCategory, group: Models.IGroup):void => { - this.$scope.showDropDown = false; - this.$scope.product.addGroup(category, subcategory, group); - group.isDisabled = true; - this.setFormValidation(); - }; - - this.$scope.onInputTextClicked = ():void => {//just edit the component in place, no pop up nor server update ? - this.$scope.showDropDown = !this.$scope.showDropDown; - }; - - this.$scope.clickOutside = (): any => { - this.$scope.showDropDown = false; - }; - - this.$scope.deleteGroup = (uniqueId:string) : void => { - //delete group from component - this.$scope.product.deleteGroup(uniqueId); - this.setFormValidation(); - //enabled group - _.forEach(this.$scope.categoriesOptions, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - let groupObj:Models.IGroup = _.find (subcategory.groupings, (group) => { - return group.uniqueId === uniqueId; - }); - if(groupObj){ - groupObj.isDisabled = false; - } - }); - }); - } - }; - - public save = (callback:Function):void => { - let onFailed = (response) => { - callback(false); - }; - - let onSuccess = (component: Models.Components.Component) => { - this.$scope.product = <Models.Components.Product> this.ComponentFactory.createComponent(component); - this.$scope.setComponent(this.$scope.product); - callback(true); - }; - - try { - this.$scope.product.updateComponent().then(onSuccess, onFailed); - }catch(e){ - //console.log("ERROR: Error in updating/creating component: " + e); - callback(false); - } - }; - - public back = (callback:Function):void => { - this.save(callback); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.html b/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.html deleted file mode 100644 index 2ae386283c..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.html +++ /dev/null @@ -1,26 +0,0 @@ -<div class="icons-step" data-ng-controller="Sdc.ViewModels.Wizard.IconsStepViewModel"> - - <form novalidate class="w-sdc-form" name="iconForm"> - <label class="i-sdc-form-label icons-label required">Icons</label> - <div class="selected-icon-container"> - <div class="i-sdc-form-item-suggested-icon medium selected-icon {{iconSprite}} {{component.icon}}" - ng-model="component.icon" - tooltips tooltip-content='{{component.icon | translate}}' - > - </div> - </div> - - <label class="i-sdc-form-label icons-label required">Select one of the icons below for the asset</label> - <div class="i-sdc-form-item suggested-icons-container"> - <div class ="suggested-icon-wrapper" ng-class="component.icon==='{{iconSrc}}' ? 'selected' : '' " data-ng-repeat="iconSrc in icons track by $index"> - <div class="i-sdc-form-item-suggested-icon medium {{iconSprite}} {{iconSrc}}" data-ng-class="component.isAlreadyCertified()? 'disable':'hand'" - ng-model="component.icon" - data-tests-id="{{iconSrc}} iconBox" - data-ng-click="!component.isAlreadyCertified() && setComponentIcon(iconSrc)" - tooltips tooltip-content='{{iconSrc | translate}}' - > - </div> - </div> - </div> - </form> -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.less b/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.less deleted file mode 100644 index c03c949962..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.less +++ /dev/null @@ -1,55 +0,0 @@ -.icons-step { - - .w-sdc-form { - padding-top: 0px; - padding-bottom: 0px; - .selected-icon-container { - text-align: left; - border: 1px solid #cfcfcf; - clear: both; - margin-bottom: 15px; - padding-left: 3px; - padding-bottom: 3px; - .selected-icon { - margin: 8px 5px 0px 6px; - } - } - - .suggested-icons-container { - text-align: left; - border: 1px solid #cfcfcf; - clear: both; - padding-left: 3px; - height: 340px; - margin-bottom: 0px; - - .suggested-icon-wrapper { - margin: 8px 5px 0px 6px; - display: inline-block; - - &.selected { - border: 1px solid @color_p; - border-radius: 25px; - box-shadow: 0 0 2px #888; - display: inline-block; - line-height: 0px; - padding: 2px; - } - - } - .suggested-icon { - // margin: 8px 5px 0px 6px; - display: inline-block; - &.disable{ - opacity: 0.4; - } - } - - - } - - .icons-label { - float: left; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.ts b/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.ts deleted file mode 100644 index 4dc5e377fa..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/icons-step/icons-step.ts +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export interface IIconsStepScope extends IWizardCreationStepScope{ - icons : Array<string>; - component: Models.Components.Component; - iconSprite: string; - setComponentIcon(iconSrc:string): void; - } - - export class IconsStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - 'Sdc.Services.AvailableIconsService', - 'ComponentFactory' - ]; - - constructor(private $scope:IIconsStepScope, - private availableIconsService:Services.AvailableIconsService, - private ComponentFactory: Sdc.Utils.ComponentFactory) { - - this.$scope.registerChild(this); - this.$scope.component = this.$scope.getComponent(); - this.$scope.iconSprite = this.$scope.component.iconSprite; - this.initScope(); - this.initIcons(); - - if(this.$scope.component.isResource()) { - this.initVendor(); - } - // In case there is one icons select it. - if( this.$scope.icons.length == 1 && !this.$scope.component.isAlreadyCertified()){ - this.$scope.setComponentIcon(this.$scope.icons[0]); - } - } - - private initIcons = ():void => { - - // For subcategories that where created by admin, there is no icons - this.$scope.icons = new Array<string>(); - if (this.$scope.component.categories && this.$scope.component.categories.length > 0) { - - _.forEach(this.$scope.component.categories, (category:Models.IMainCategory):void => { - if (category.icons) { - this.$scope.icons = this.$scope.icons.concat(category.icons); - } - if (category.subcategories) { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory):void => { - if (subcategory.icons) { - this.$scope.icons = this.$scope.icons.concat(subcategory.icons); - } - }); - } - }); - } - - if (this.$scope.component.isResource()) { - let resourceType:string = this.$scope.component.getComponentSubType(); - if (resourceType === 'VL') { - this.$scope.icons = ['vl']; - } - if (resourceType === 'CP') { - this.$scope.icons = ['cp']; - } - } - - if (this.$scope.icons.length === 0) { - this.$scope.icons = this.availableIconsService.getIcons(this.$scope.component.componentType); - } - - }; - - private initVendor = ():void => { - let vendors:Array<string> = this.availableIconsService.getIcons(this.$scope.component.componentType).slice(5, 19); - let vendorName = this.$scope.component.vendorName.toLowerCase(); - if ('at&t' === vendorName){ - vendorName = 'att'; - } - if ('nokia' === vendorName){ - vendorName = 'nokiasiemens'; - } - - let vendor:string = _.find(vendors, (vendor:string)=>{ - return vendor.replace(/[_]/g, '').toLowerCase() === vendorName; - }); - - if(vendor && this.$scope.icons.indexOf(vendor)===-1) { - this.$scope.icons.push(vendor); - } - }; - - private initScope():void { - this.$scope.icons = []; - - if(this.$scope.component.icon === Utils.Constants.DEFAULT_ICON){ - this.$scope.setValidState(false); - } - - this.$scope.setComponentIcon = (iconSrc:string):void => { - this.$scope.component.icon = iconSrc; - this.$scope.setValidState(true); - } - } - - save(callback:Function):void { - let onFailed = () => { - callback(false); - }; - - let onSuccess = (component:Models.Components.Component) => { - this.$scope.component = component; - this.$scope.setComponent(this.$scope.component); - callback(true); - }; - - try { - this.$scope.component.updateComponent().then(onSuccess, onFailed); - }catch(e){ - callback(false); - } - } - - public back = (callback:Function):void => { - this.save(callback); - } - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.html b/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.html deleted file mode 100644 index 4429451871..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.html +++ /dev/null @@ -1,57 +0,0 @@ -<div class="properties-step" data-ng-controller="Sdc.ViewModels.Wizard.PropertiesStepViewModel"> - - <div class="w-sdc-classic-btn gray" data-tests-id="addGrey" data-ng-click="addOrUpdateProperty()">Add</div> - - <div class="table-container-flex"> - - <div class="table"> - <div class="head flex-container"> - <div class="table-header head-row hand flex-item" data-ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} - <span data-ng-if="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> - </div> - <div class="table-no-text-header head-row flex-item"></div> - <!--div class="table-no-text-header head-row flex-item"></div--> - </div> - - <div class="body"> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - <div data-ng-if="component.properties.length === 0 " class="no-row-text"> - There are no properties to display <br> - click <a data-ng-click="addOrUpdateProperty()">here</a> to add one - </div> - <div data-ng-repeat-start="property in component.properties | orderBy:sortBy:reverse track by $index" - class="flex-container data-row" data-ng-class="{'selected': property.selected}" - data-ng-click="property.selected = !property.selected"> - - <div class="table-col-general flex-item text"> - <span class="sprite table-arrow" data-ng-class="{'opened': property.selected}"></span> - <span data-tests-id="{{property.name}}" tooltips tooltip-content="{{property.name}}">{{property.name}}</span> - - </div> - - <div class="table-col-general flex-item text" data-tests-id="{{property.type}}" data-ng-bind="property.type"></div> - - <div class="table-col-general flex-item text"> - <span tooltips tooltip-content="{{property.defaultValue}}" data-tests-id="{{property.defaultValue}}" data-ng-bind="property.defaultValue"></span> - </div> - - <div class="table-btn-col flex-item"> - <button class="table-edit-btn" data-ng-show="property.parentUniqueId==component.uniqueId" - data-ng-click="addOrUpdateProperty(property); $event.stopPropagation();"> </button> - <button class="table-delete-btn" data-ng-show="property.parentUniqueId==component.uniqueId" - data-ng-click="delete(property); $event.stopPropagation();"> </button> - </div> - - <!--div class="table-btn-col flex-item"> - - </div--> - </div> - <div data-ng-repeat-end="" data-ng-if="property.selected && property.description" class="item-opened" data-ng-bind="property.description"> - </div> - </perfect-scrollbar> - </div> - - </div> - </div> - -</div> diff --git a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.less b/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.less deleted file mode 100644 index 0d7dad8dc2..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.less +++ /dev/null @@ -1,55 +0,0 @@ -.properties-step { - - .w-sdc-classic-btn { - float: right; - margin-bottom: 10px; - } - - .table{ - height: 412px; - margin-bottom: 0; - } - - .table-container-flex { - margin-top: 0px; - - .text{ - overflow: hidden; - text-overflow: ellipsis; - display: inline-block; - white-space: nowrap; - padding: 5px 4px; - - } - - .flex-item:nth-child(1) { - flex-grow: 15; - - .hand; - span.table-arrow { - margin-right: 7px; - } - } - - .flex-item:nth-child(2) { - flex-grow: 6; - } - - .flex-item:nth-child(3) { - flex-grow: 9; - } - - .flex-item:nth-child(4) { - flex-grow: 3; - //padding-top: 10px; - padding: 10px 4px; - - } - - .flex-item:nth-child(5) { - flex-grow: 1; - } - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.ts b/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.ts deleted file mode 100644 index 08dfb5e153..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/properties-step/properties-step.ts +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - interface IPropertiesStepViewModelScope extends IWizardCreationStepScope { - component: Models.Components.Component; - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - - addOrUpdateProperty(): void; - delete(property: Models.PropertyModel): void; - sort(sortBy:string): void; - } - - export class PropertiesStepViewModel implements IWizardCreationStep { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ModalsHandler' - ]; - - - constructor( - private $scope:IPropertiesStepViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private ModalsHandler: Utils.ModalsHandler - ){ - - this.$scope.registerChild(this); - this.$scope.setValidState(true); - this.initScope(); - } - - public save = (callback:Function):void => { - this.$scope.setComponent(this.$scope.component); - callback(true); - }; - - public back = (callback:Function):void => { - this.$scope.setComponent(this.$scope.component); - callback(true); - } - - - private openEditPropertyModal = (property: Models.PropertyModel): void => { - let viewModelsHtmlBasePath: string = '/app/scripts/view-models/'; - - let modalOptions: ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath+'wizard/property-form/property-form.html'), - controller: 'Sdc.ViewModels.Wizard.PropertyFormViewModel', - size: 'sdc-md', - backdrop: 'static', - keyboard: false, - resolve: { - property: (): Models.PropertyModel => { - return property; - }, - component: (): Models.Components.Component => { - return <Models.Components.Component> this.$scope.getComponent(); - } - } - }; - this.$modal.open(modalOptions); - }; - - private initScope = (): void => { - - let self = this; - this.$scope.component = this.$scope.getComponent(); - this.$scope.sortBy = 'name'; - this.$scope.reverse = false; - - this.$scope.tableHeadersList = [ - {title:'Name', property: 'name'}, - {title:'Type', property: 'type'}, - {title:'Default Value', property: 'defaultValue'} - ]; - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - this.$scope.addOrUpdateProperty = (property?: Models.PropertyModel): void => { - this.openEditPropertyModal(property ? property : new Models.PropertyModel()); - }; - - this.$scope.delete = (property: Models.PropertyModel): void => { - - let onOk = (): void => { - this.$scope.component.deleteProperty(property.uniqueId); - }; - let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model-tests.ts b/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model-tests.ts deleted file mode 100644 index 3f390841ca..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model-tests.ts +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -describe("property form View Model ", () => { - - let $controllerMock:ng.IControllerService; - let $qMock:ng.IQService; - let $httpBackendMock:ng.IHttpBackendService; - let $scopeMock:Sdc.ViewModels.Wizard.IPropertyFormViewModelScope; - let $stateMock:ng.ui.IStateService; - let $stateParams:any; - let component = { - "uniqueId": "ece818e0-fd59-477a-baf6-e27461a7ce23", - "uuid": "8db823c2-6a9c-4636-8676-f5e713270dd7", - "contactId": "uf2345", - "category": "Network Layer 2-3/Router", - "creationDate": 1447235352429, - "description": "u", - "highestVersion": true, - "icon": "network", - "lastUpdateDate": 1447235370064, - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "name": "u", - "version": "0.1", - "type": 1, - "tags": [ - "u" - ], - "vendorName": "u", - "vendorRelease": "u", - "systemName": "U", - "$$hashKey": "object:34" - }; - - - beforeEach(angular.mock.module('sdcApp')); - - beforeEach(angular.mock.inject((_$controller_:ng.IControllerService, - _$httpBackend_:ng.IHttpBackendService, - _$rootScope_, - _$q_:ng.IQService, - _$state_:ng.ui.IStateService, - _$stateParams_:any) => { - - $controllerMock = _$controller_; - $httpBackendMock = _$httpBackend_ - $scopeMock = _$rootScope_.$new(); - $qMock = _$q_; - $stateMock = _$state_; - $stateParams = _$stateParams_; - - - //handle all http request thet not relevant to the tests - $httpBackendMock.expectGET(/.*languages\/en_US.json.*/).respond(200, JSON.stringify({})); - // $httpBackendMock.expectGET(/.*resources\/certified\/abstract.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*rest\/version.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*configuration\/ui.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*user\/authorize.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/services.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/resources.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET(/.*categories\/products.*/).respond(200, JSON.stringify({})); - $httpBackendMock.expectGET('http://feHost:8181/sdc1/feProxy/rest/version').respond(200, JSON.stringify({})); - - /** - * Mock the service - * @type {any} - */ - //getAllEntitiesDefered = $qMock.defer(); - //getAllEntitiesDefered.resolve(getAllEntitiesResponseMock); - //entityServiceMock = jasmine.createSpyObj('entityServiceMock', ['getAllComponents']); - //entityServiceMock.getAllComponents.and.returnValue(getAllEntitiesDefered.promise); - - // $stateParams['show'] = ''; - - /** - * Need to inject into the controller only the objects that we want to MOCK - * those that we need to change theirs behaviors - */ - $controllerMock(Sdc.ViewModels.Wizard.PropertyFormViewModel, { - '$scope': $scopeMock, - 'property': new Sdc.Models.PropertyModel(), - 'component': component, - }); - - })); - - describe("when Controller 'PropertyFormViewModel' created", () => { - - it('should have a regexp per each type', () => { - $scopeMock.$apply(); - expect(Object.keys($scopeMock.listRegex).length).toBe($scopeMock.editPropertyModel["simpleTypes"].length); - }); - - it('should have equal regexps for map and list', () => { - $scopeMock.$apply(); - expect(Object.keys($scopeMock.listRegex).length).toBe(Object.keys($scopeMock.mapRegex).length); - }); - - }); - - /*describe("when Controller 'DashboardViewModel' created", () => { - - it('should generate all entities', () => { - $scopeMock.$apply(); - expect($scopeMock.components.length).toBe(getAllEntitiesResponseMock.length); - }); - - - it('should show tutorial page ', () => { - $stateParams.show = 'tutorial'; - - $controllerMock(Sdc.ViewModels.DashboardViewModel, { - '$scope': $scopeMock, - '$stateParams': $stateParams, - 'Sdc.Services.EntityService': entityServiceMock, - //to complete injects - }); - - $scopeMock.$apply(); - expect($scopeMock.isFirstTime).toBeTruthy(); - expect($scopeMock.showTutorial).toBeTruthy(); - }); - - }); - - - describe("when function 'entitiesCount' invoked", () => { - - beforeEach(() => { - $controllerMock(Sdc.ViewModels.DashboardViewModel, { - '$scope': $scopeMock, - 'Sdc.Services.EntityService': entityServiceMock, - }); - $scopeMock.$apply(); - }); - - it('should return entities count per folder', () => { - - }); - - - });*/ -}); diff --git a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model.ts b/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model.ts deleted file mode 100644 index 5cb0ef1ddd..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form-view-model.ts +++ /dev/null @@ -1,250 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> - -module Sdc.ViewModels.Wizard { - 'use strict'; - - export interface IEditPropertyModel{ - property: Models.PropertyModel; - types: Array<string>; - simpleTypes: Array<string>; - sources: Array<string>; - } - - export interface IPropertyFormViewModelScope extends ng.IScope{ - - $$childTail: any; - editForm:ng.IFormController; - forms:any; - footerButtons: Array<any>; - isNew: boolean; - isLoading: boolean; - validationPattern: RegExp; - propertyNameValidationPattern: RegExp; - integerValidationPattern: RegExp; - floatValidationPattern: RegExp; - commentValidationPattern: RegExp; - listRegex: Sdc.Utils.IMapRegex; - mapRegex: Sdc.Utils.IMapRegex; - editPropertyModel: IEditPropertyModel; - modalInstanceProperty: ng.ui.bootstrap.IModalServiceInstance; - save(doNotCloseModal?: boolean): void; - saveAndAnother(): void; - getValidation(): RegExp; - validateIntRange(value:string):boolean; - close(): void; - onValueChange(): void; - onTypeChange(resetSchema:boolean): void; - showSchema(): boolean; - getValidationTranslate():string; - validateUniqueKeys(viewValue:string):boolean; - } - - export class PropertyFormViewModel{ - - private originalValue: string; - - static '$inject' = [ - '$scope', - '$modalInstance', - 'property', - 'ValidationPattern', - 'PropertyNameValidationPattern', - 'IntegerNoLeadingZeroValidationPattern', - 'FloatValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - 'component' - ]; - - private formState: Utils.Constants.FormState; - private entityId: string; - private resourceInstanceUniqueId: string; - private readonly: boolean; - - constructor( - private $scope:IPropertyFormViewModelScope, - private $modalInstance: ng.ui.bootstrap.IModalServiceInstance, - private property : Models.PropertyModel, - private ValidationPattern : RegExp, - private PropertyNameValidationPattern: RegExp, - private IntegerNoLeadingZeroValidationPattern : RegExp, - private FloatValidationPattern : RegExp, - private CommentValidationPattern: RegExp, - private ValidationUtils: Sdc.Utils.ValidationUtils, - private component:Models.Components.Component - ){ - this.entityId = this.component.uniqueId; - this.formState = angular.isDefined(property.name) ? Utils.Constants.FormState.UPDATE : Utils.Constants.FormState.CREATE; - this.initScope(); - } - - - private initResource = (): void => { - this.$scope.editPropertyModel.property = new Sdc.Models.PropertyModel(this.property); - this.originalValue = this.property.defaultValue; - if(this.$scope.editPropertyModel.types.indexOf(this.property.type) === -1 && !this.$scope.isNew){ - this.property.type = "string"; - } - }; - - private initEditPropertyModel = (): void => { - this.$scope.editPropertyModel = { - property: null, - types: ['integer', 'string', 'float', 'boolean', 'list', 'map'], - simpleTypes: ['integer', 'string', 'float', 'boolean'], - sources: ['A&AI', 'Order', 'Runtime'] - }; - - this.initResource(); - }; - - private initScope = (): void => { - - this.$scope.modalInstanceProperty = this.$modalInstance; - //scope properties - this.$scope.validationPattern = this.ValidationPattern; - this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; - this.$scope.integerValidationPattern = this.IntegerNoLeadingZeroValidationPattern; - this.$scope.floatValidationPattern = this.FloatValidationPattern; - this.$scope.commentValidationPattern = this.CommentValidationPattern; - - //map & list validation patterns - this.$scope.listRegex = this.ValidationUtils.getPropertyListPatterns(); - this.$scope.mapRegex = this.ValidationUtils.getPropertyMapPatterns(); - - this.$scope.isLoading = false; - this.$scope.isNew = (this.formState === Utils.Constants.FormState.CREATE); - this.initEditPropertyModel(); - - //scope methods - this.$scope.save = (): void => { - this.$scope.editPropertyModel.property.description = this.ValidationUtils.stripAndSanitize(this.$scope.editPropertyModel.property.description); - this.$scope.isLoading = true; - - let onFailed = (response) => { - console.info('onFaild',response); - this.$scope.isLoading = false; - this.$scope.editPropertyModel.property.readonly = this.readonly; - this.$scope.editPropertyModel.property.resourceInstanceUniqueId = this.resourceInstanceUniqueId; - }; - - let onSuccess = (property: Models.PropertyModel): void => { - console.info('property added : ',property); - this.$scope.isLoading = false; - property.resourceInstanceUniqueId = this.resourceInstanceUniqueId; - property.readonly = (property.parentUniqueId !== this.component.uniqueId) /*|| this.component.isService()*/; - - this.$modalInstance.close(); - }; - - this.resourceInstanceUniqueId = this.$scope.editPropertyModel.property.resourceInstanceUniqueId; - this.readonly = this.$scope.editPropertyModel.property.readonly; - this.$scope.editPropertyModel.property.defaultValue = this.$scope.editPropertyModel.property.defaultValue ? this.$scope.editPropertyModel.property.defaultValue:null; - - this.component.addOrUpdateProperty(this.$scope.editPropertyModel.property).then(onSuccess, onFailed); - }; - - this.$scope.saveAndAnother = (): void => { - this.$scope.save(); - }; - - this.$scope.showSchema = () :boolean => { - return ['list', 'map'].indexOf(this.$scope.editPropertyModel.property.type) > -1; - }; - - this.$scope.getValidationTranslate = () : string => { - let result = "PROPERTY_EDIT_PATTERN"; - if (this.$scope.showSchema()) { - - result = "PROPERTY_EDIT_" + this.$scope.editPropertyModel.property.type.toUpperCase(); - - if(this.$scope.editPropertyModel.property.schema.property.type === 'string') { - result += "_STRING"; - } else { - result += "_GENERIC"; - } - } - - return result; - }; - - this.$scope.getValidation = () : RegExp => { - let type = this.$scope.editPropertyModel.property.type; - switch (type){ - case 'integer': - return this.$scope.integerValidationPattern; - case 'float': - return this.$scope.floatValidationPattern; - case 'list': - return this.$scope.listRegex[this.$scope.editPropertyModel.property.schema.property.type]; - case 'map': - return this.$scope.mapRegex[this.$scope.editPropertyModel.property.schema.property.type]; - default : - return null; - } - }; - - this.$scope.validateUniqueKeys = (viewValue:string) : boolean => { - if(this.$scope.editPropertyModel.property.type === 'map') { - return this.ValidationUtils.validateUniqueKeys(viewValue); - } - else { - return true; //always valid if not a map - } - }; - - this.$scope.validateIntRange = (value:string):boolean => { - return !value || this.ValidationUtils.validateIntRange(value); - }; - - this.$scope.close = (): void => { - this.$modalInstance.close(); - }; - - this.$scope.onValueChange = (): void => { - if(!this.$scope.editPropertyModel.property.defaultValue && this.$scope.editPropertyModel.property.required) { - this.$scope.editPropertyModel.property.defaultValue = this.originalValue; - } - }; - - this.$scope.onTypeChange = (resetSchema:boolean): void => { - this.$scope.editPropertyModel.property.defaultValue = ''; - if (resetSchema) { - this.$scope.editPropertyModel.property.schema.property.type = ''; - } - }; - - //new form layout for import asset - this.$scope.forms = {}; - this.$scope.footerButtons = [ - {'name': this.$scope.isNew ? 'Add' : 'Update', 'css':'blue', 'callback': this.$scope.save}, - {'name':'Cancel', 'css':'grey', 'callback': this.$scope.close} - ]; - - this.$scope.$watch('forms.editForm.$invalid', () => { - this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; - }); - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.html b/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.html deleted file mode 100644 index be237112a4..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.html +++ /dev/null @@ -1,133 +0,0 @@ -<sdc-modal modal="modalInstanceProperty" type="classic" class="sdc-add-property" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true"> - - <form novalidate class="w-sdc-form two-columns" name="forms.editForm" > - - <div class="w-sdc-form-columns-wrapper"> - - <div class="w-sdc-form-column"> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid)}"> - <label class="i-sdc-form-label" ng-class="{'required': !isService}">Name</label> - <input class="i-sdc-form-input" - data-ng-maxlength="50" - data-ng-disabled="!isNew || editPropertyModel.property.readonly" - maxlength="50" - data-ng-model="editPropertyModel.property.name" - type="text" - name="propertyName" - data-ng-pattern="propertyNameValidationPattern" - data-required - data-ng-model-options="{ debounce: 200 }" - data-tests-id="propertyName" - autofocus /> - - <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid"> - <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span> - <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '128' }"></span> - <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - </div> - - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid)}" - data-ng-if="showSchema()"> - <label class="i-sdc-form-label required">Entry Schema</label> - <select class="i-sdc-form-select" - data-required - name="schemaType" - data-tests-id="schemaType" - data-ng-change="onTypeChange(false)" - data-ng-model="editPropertyModel.property.schema.property.type" - data-ng-options="type for type in editPropertyModel.simpleTypes"> - <option value="">Choose Schema Type</option> - </select> - - <div class="input-error" data-ng-show="forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid"> - <span ng-show="forms.editForm.schemaType.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Entry schema' }"></span> - </div> - </div> - - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> - <label class="i-sdc-form-label">Default Value</label> - <input class="i-sdc-form-input" - ng-if="!(editPropertyModel.property.type == 'boolean')" - data-ng-maxlength="100" - data-ng-disableddddddd="editPropertyModel.property.readonly && !isService && !isPropertyValueOwner()" - maxlength="100" - data-ng-model="editPropertyModel.property.defaultValue" - type="text" - name="value" - data-custom-validation="" data-validation-func="validateUniqueKeys" - data-ng-pattern="getValidation()" - data-ng-model-options="{ debounce: 200 }" - data-ng-change="!forms.editForm.value.$error.pattern && ('integer'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editPropertyModel.property.defaultValue)) || onValueChange())" - data-tests-id="defaultValue" - autofocus /> - <select class="i-sdc-form-select" - ng-if="editPropertyModel.property.type == 'boolean'" - data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner()" - name="value" - data-ng-change="onValueChange()" - data-ng-model="editPropertyModel.property.defaultValue"> - <option value=""></option> - <option value="true">true</option> - <option value="false">false</option> - </select> - - <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid"> - <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property' }"></span> - <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '100' }"></span> - <span ng-show="forms.editForm.value.$error.pattern" translate="{{getValidationTranslate()}}"></span> - <span ng-show="forms.editForm.value.$error.customValidation" translate="PROPERTY_EDIT_MAP_UNIQUE_KEYS"></span> - </div> - </div> - - </div> - - <div class="w-sdc-form-column"> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}"> - <label class="i-sdc-form-label" ng-class="{'required': !isService}">Type</label> - <select class="i-sdc-form-select" - data-required - data-ng-disableddddddd="editPropertyModel.property.readonly" - data-tests-id="propertyType" - name="type" - data-ng-change="onTypeChange(true)" - data-ng-model="editPropertyModel.property.type" - data-ng-options="type for type in editPropertyModel.types"> - <option value="">Choose Type</option> - </select> - - <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid"> - <span ng-show="forms.editForm.type.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Type' }"></span> - </div> - </div> - - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}"> - <label class="i-sdc-form-label">Description</label> - <textarea class="i-sdc-form-textarea" - data-ng-maxlength="256" - data-ng-disableddddddd="editPropertyModel.property.readonly" - maxlength="256" - data-ng-pattern="commentValidationPattern" - name="description" - data-ng-model="editPropertyModel.property.description" - data-ng-model-options="{ debounce: 200 }" - data-tests-id="description" - ></textarea> - - <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid"> - <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> - <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="forms.editForm.description.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Description' }"></span> - </div> - </div> - - </div> - - </div> - </form> - -</sdc-modal> diff --git a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.less b/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.less deleted file mode 100644 index 52b8564fdb..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/property-form/property-form.less +++ /dev/null @@ -1,7 +0,0 @@ -.sdc-add-property{ - - .w-sdc-form { - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.html b/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.html deleted file mode 100644 index afa9307265..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.html +++ /dev/null @@ -1,12 +0,0 @@ -<loader data-display="isLoading"></loader> -<div class="sdc-wizard-name-type-label" data-ng-if="assetName!==undefined"><span class="sprite sprite-green-tick animated flash"></span><span class="name">{{assetName}}</span> | <span class="type">{{assetType}}</span></div> -<sdc-modal modal="modalInstance" type="classic" get-close-modal-response="getComponent" buttons="footerButtons" class="sdc-wizard" header="{{modalTitle}}" show-close-button="true"> - <div class="sdc-wizard-wrapper"> - <div class="sdc-wizard-left-content"> - <sdc-wizard-step steps="directiveSteps" control="assetCreationControl" class="wizard-steps-line"></sdc-wizard-step> - </div> - <div class="sdc-wizard-right-content"> - <ng-include src="templateUrl" class="sdc-wizard-right-include"></ng-include> - </div> - </div> -</sdc-modal> diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.less b/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.less deleted file mode 100644 index 591186789b..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.less +++ /dev/null @@ -1,60 +0,0 @@ -.sdc-wizard-wrapper { - display: flex; - padding: 80px 0; - height: 620px; - // So input validation error will be shown outside the modal (long messages). - // overflow: hidden; - - .sdc-wizard-left-content { - width: 400px; - white-space: nowrap; - - .wizard-steps-line { - padding: 0 80px 0 0; - display: block; - } - - } - - .sdc-wizard-right-content { - margin-right: 200px; - /* background-color: #fafafa; */ - height: 100%; - width: 100%; - .perfect-scrollbar; - overflow: visible; - //.animation-duration(2s); - - .sdc-wizard-right-include { - - } - } - -} - -.sprite-green-tick.animated { - .animation-duration(3s); -} - -.sdc-wizard-name-type-label { - position: absolute; - top: 64px; - right: 40px; - - span { - .b_7; - &.name {.bold;} - &.sprite-green-tick { - position: absolute; - left: -22px; - top: 5px; - } - } - -} - -.w-wizard-footer { - button.cancel { - margin-right: 120px; - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.ts b/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.ts deleted file mode 100644 index 365d3aedf6..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-creation-base.ts +++ /dev/null @@ -1,399 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export class StepNames { - static general = "General"; - static icon = "Icon"; - static deploymentArtifact = "Deployment Artifact"; - static informationArtifact = "Information Artifact"; - static properties = "Properties"; - static hierarchy = "Hierarchy"; - } - - class FooterButtons { - static cancel = "Cancel"; - static back = "Back"; - static next = "Next"; - static finish = "Finish"; - } - - export class WizardCreationTypes { - static importAsset = "importAsset"; - static create = "create"; - static edit = "edit"; - } - - export class _CreationStep { - name:string; - url:string; - } - - export class CurrentStep { - assetCreationStep:_CreationStep; - reference:IWizardCreationStep; - index:number; - valid: boolean; - } - - export interface IWizardCreationStep { - save(callback:Function):void; - back(callback:Function):void; - } - - export interface IWizardCreationStepScope extends ng.IScope { - data:any; - getComponent():Sdc.Models.Components.Component; - setComponent(component: Sdc.Models.Components.Component):void; - registerChild(child:IWizardCreationStep):void; // Called from the step - setValidState(valid:boolean):void; // Called from the step - } - - export interface IWizardCreationScope extends ng.IScope { - isLoading: boolean; - data:any; // data passed from dashboard (opener), need it on the scope, because general step will use this (extends the scope) - directiveSteps: Array<Sdc.Directives.IWizardStep>; // Steps for the directive, on the scope (on the scope because need to pass to directive via HTML) - templateUrl: string; // On the scope because need to pass to <ng-include> via HTML - footerButtons: Array<Sdc.Directives.ISdcModalButton>; // Wizard footer buttons (on the scope because need to pass to directive via HTML) - assetCreationControl:any; // Link to wizard directive functions. - modalInstance:ng.ui.bootstrap.IModalServiceInstance; // Reference to the modal, so we can close it (on the scope because need to pass to directive via HTML) - assetName:string; - assetType:string; - modalTitle:string; - getComponent():Sdc.Models.Components.Component; - setComponent(component: Sdc.Models.Components.Component):void; - registerChild(child:IWizardCreationStep):void; // Called from the step - setValidState(valid:boolean):void; // Called from the step - } - - export class WizardCreationBaseViewModel { - - component: Sdc.Models.Components.Component; - protected assetCreationSteps: Array<_CreationStep>; // Contains URL and name so we can replace them - currentStep:CurrentStep; - protected type:string; - - constructor(protected $scope:IWizardCreationScope, - protected data:any, - protected ComponentFactory: Utils.ComponentFactory, - protected $modalInstance: ng.ui.bootstrap.IModalServiceInstance - ) { - - this.$scope.data = data; - this.currentStep = new CurrentStep(); - this.currentStep.valid=false; - this.$scope.modalInstance = this.$modalInstance; - this.initScope(); - this.noBackspaceNav(); - - // In case the modal was opened with filled resource (edit mode). - if (data.component){ - this.$scope.setComponent(data.component); - data.componentType = this.$scope.getComponent().componentType; - window.setTimeout(()=>{ - this.safeApply(this.setCurrentStepByIndex(0, false)); - },100); - } else { - // Default step to start with - window.setTimeout(()=>{ - this.safeApply(this.setCurrentStepByIndex(0, false)); - },100); - } - - } - - private safeApply = (fn:any) => { - let phase = this.$scope.$root.$$phase; - if (phase == '$apply' || phase == '$digest') { - if (fn && (typeof(fn) === 'function')) { - fn(); - } - } else { - this.$scope.$apply(fn); - } - }; - - private initScope = ():void => { - - // Control to call functions on wizard step directive - this.$scope.assetCreationControl = {}; - - // Footer buttons definitions for the modal directive. - this.$scope.footerButtons = [ - {"name":FooterButtons.cancel, "css":'white cancel',"callback": ()=>{this.btnCancelClicked();}}, - {"name":FooterButtons.back, "disabled":true, "css":'white back',"callback": ()=>{this.btnBackClicked();}}, - {"name":FooterButtons.next, "disabled":true, "css":'blue next',"callback": ()=>{this.btnNextClicked();}}, - {"name":FooterButtons.finish, "disabled":true, "css":'white finish',"callback": ()=>{this.btnFinishedClicked();}} - ]; - - // Will be called from step constructor to register him. - // So the current step will be the reference. - this.$scope.registerChild=(child:IWizardCreationStep):void => { - this.currentStep.reference=child; - }; - - // Will be called from each step to notify if the step is valid - // The wizard will set the "Next", "Finish" buttons accordingly. - this.$scope.setValidState = (valid:boolean):void => { - this.currentStep.valid=valid; - let currentDirectiveStep:Sdc.Directives.IWizardStep = this.$scope.directiveSteps[this.currentStep.index]; - this.$scope.assetCreationControl.setStepValidity(currentDirectiveStep, valid); - this.footerButtonsStateMachine(); - this.wizardButtonsIconsStateMachine(); - }; - - /** - * Will be called from each step to get current entity. - * This will return copy of the entity (not reference), because I do not want that the step will change entity parameters. - * If the step need to update the entity it can call setComponent function. - * @returns {Sdc.Models.IEntity} - */ - this.$scope.getComponent = ():Sdc.Models.Components.Component => { - return this.component; - }; - - // Will be called from each step after save to update the resource. - this.$scope.setComponent = (component:Sdc.Models.Components.Component):void => { - this.component = component; - }; - - }; - - protected setCurrentStepByName = (stepName:string):boolean => { - let stepIndex:number = this.getStepIndex(stepName); - return this.setCurrentStepByIndex(stepIndex); - }; - - // Set the current step, change the URL in ng-include. - protected setCurrentStepByIndex = (index:number, doSave:boolean=true):boolean => { - let result:boolean = false; - if (this.currentStep.index!==index) { // Check that not pressing on same step, also the first time currentStepIndex=undefined - if (doSave===true) { - this.callStepSave(() => { - // This section will be executed only if success save. - - // Set current step in the left wizard directive = valid - let currentDirectiveStep:Sdc.Directives.IWizardStep = this.$scope.directiveSteps[this.currentStep.index]; - this.$scope.assetCreationControl.setStepValidity(currentDirectiveStep, true); - - // Move to next step - let step:_CreationStep = this.assetCreationSteps[index]; - this.currentStep.index = index; - this.currentStep.assetCreationStep = step; - this.$scope.templateUrl = step.url; - - // Update the next/back buttons and steps buttons. - this.footerButtonsStateMachine(); - this.wizardButtonsIconsStateMachine(); - - // Can not perform step click without enabling the step - this.$scope.directiveSteps[index].enabled = true; // Need to set the step enabled, before clicking it. - this.$scope.assetCreationControl.stepClicked(step.name); - - // After saving the asset name and type will be shown in the top right of the screen. - this.fillAssetNameAndType(); - - result=true; - }); - } else { - // For the first time - let step:_CreationStep = this.assetCreationSteps[index]; - this.currentStep.index = index; - this.currentStep.assetCreationStep=step; - this.$scope.templateUrl = step.url; - this.$scope.directiveSteps[index].enabled = true; // Need to set the step enabled, before clicking it. - this.$scope.assetCreationControl.stepClicked(step.name); - result=true; - } - - //this.updateFooterButtonsStates(); - - } else { - result=true; - } - return result; - }; - - // Save the current step - private callStepSave = (successCallback:Function):void => { - this.$scope.isLoading = true; - this.currentStep.reference.save((result:boolean)=>{ - this.$scope.isLoading = false; - if (result===true){ - successCallback(); - } else { - // Set the next and finish button enabled. - //this.updateFooterButtonsStates(true); - } - }); - }; - - // Save the current step - private callStepBack = (successCallback:Function):void => { - this.$scope.isLoading = true; - this.currentStep.reference.back((result:boolean)=>{ - this.$scope.isLoading = false; - if (result===true){ - successCallback(); - } else { - // Set the next and finish button enabled. - //this.updateFooterButtonsStates(true); - } - }); - }; - - private getStepIndex = (stepName:string):number => { - let index:number=-1; - let tmp = _.find(this.assetCreationSteps, function (item, indx) { - index = indx; - return item.name === stepName; - }); - return index; - }; - - private btnNextClicked = ():void => { - if (this.hasNext()===true) { - let tmp = this.currentStep.index+1; - this.setCurrentStepByIndex(tmp); - } - }; - - private btnBackClicked = ():void => { - if (this.hasBack()===true) { - this.callStepBack(() => { - let tmp = this.currentStep.index-1; - this.setCurrentStepByIndex(tmp, false); - }); - } - }; - - private btnCancelClicked = ():void => { - this.$modalInstance.dismiss(this.$scope.getComponent()); - }; - - private btnFinishedClicked = ():void => { - this.callStepSave(() => { - this.$modalInstance.close(this.$scope.getComponent()); - }); - }; - - // Check if we can move next - private hasNext = ():boolean => { - if (this.assetCreationSteps.length-1>this.currentStep.index){ - return true; - } else { - return false; - } - }; - - // Check if we can move back - private hasBack = ():boolean => { - if (this.currentStep.index===0){ - return false; - } else { - return true; - } - }; - - private fillAssetNameAndType=():void => { - this.$scope.assetName = this.$scope.getComponent().name; - this.$scope.assetType = this.$scope.getComponent().getComponentSubType(); - - }; - - protected enableAllWizardSteps=():void => { - this.$scope.directiveSteps.forEach((step:Sdc.Directives.IWizardStep) => { - step.enabled=true; - }); - }; - - protected disableAllWizardSteps=():void => { - this.$scope.directiveSteps.forEach((step:Sdc.Directives.IWizardStep) => { - step.enabled=false; - }); - }; - - private footerButtonsStateMachine = ():void => { - //console.log("footerButtonsStateMachine, current step validity: " + this.currentStep.valid); - let stepIndex:number = this.currentStep.index; - let cancelButton = this.$scope.footerButtons[0]; - let backButton = this.$scope.footerButtons[1]; - let nextButton = this.$scope.footerButtons[2]; - let finishButton = this.$scope.footerButtons[3]; - - // NEXT button - // Disable next button if it is the last step, and if not check the validity of the step. - if (this.hasNext()){ - nextButton.disabled = !this.currentStep.valid; - } else { - nextButton.disabled = true; - } - - // BACK button - backButton.disabled = !this.hasBack(); - - // FINISH button - // If step 2 is valid show the finish button. - if (stepIndex>=1 && this.currentStep.valid===true) { - finishButton.disabled = false; - } - if (this.currentStep.valid===false){ - finishButton.disabled = true; - } - - // EDIT - if (this.type===WizardCreationTypes.edit && this.currentStep.valid===true){ - finishButton.disabled = false; - } - - }; - - - - private wizardButtonsIconsStateMachine = ():void => { - - // Enable or disable wizard directive next step, in case the current step form is valid or not. - let stepIndex:number = this.currentStep.index; - if (this.$scope.directiveSteps[stepIndex + 1]) { - this.$scope.directiveSteps[stepIndex + 1].enabled = this.currentStep.valid; - } - - // In case step 1 and 2 are valid, we can open all other steps. - if (this.$scope.directiveSteps[0].valid===true && this.$scope.directiveSteps[1].valid===true){ - // Enable all wizard directive steps - this.enableAllWizardSteps(); - } else if (this.currentStep.valid===false) { - // Disable all steps - this.disableAllWizardSteps(); - } - }; - - private noBackspaceNav:Function = ():void => { - this.$scope.$on('$locationChangeStart', (event, newUrl, oldUrl):void =>{ - event.preventDefault(); - }) - }; - - - } - -} diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-state/create-wizard.ts b/catalog-ui/app/scripts/view-models/wizard/wizard-state/create-wizard.ts deleted file mode 100644 index 9490cddfdb..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-state/create-wizard.ts +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 3/15/2016. - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export class CreateWizardViewModel extends WizardCreationBaseViewModel { - - static '$inject' = [ - '$scope', - 'data', - 'ComponentFactory', - '$modalInstance' - ]; - - constructor(public $scope:IWizardCreationScope, - public data:any, - public ComponentFactory: Sdc.Utils.ComponentFactory, - public $modalInstance: ng.ui.bootstrap.IModalServiceInstance) { - - super($scope, data, ComponentFactory, $modalInstance); - this.type = WizardCreationTypes.create; - this.init(); - this.initCreateAssetScope(); - } - - private init = ():void => { - - switch (this.data.componentType){ - case Utils.Constants.ComponentType.RESOURCE: { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'}, - {"name": StepNames.deploymentArtifact, "url": '/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.html'}, - {"name": StepNames.informationArtifact, "url": '/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html'}, - {"name": StepNames.properties, "url": '/app/scripts/view-models/wizard/properties-step/properties-step.html'} - ]; - } - break; - - case Utils.Constants.ComponentType.SERVICE: { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'} - ]; - } - break; - - case Utils.Constants.ComponentType.PRODUCT: { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.hierarchy, "url": '/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'} - ]; - } - break; - } - }; - - private initCreateAssetScope = ():void => { - switch (this.data.componentType){ - case Utils.Constants.ComponentType.RESOURCE: { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}}, - {"name": StepNames.deploymentArtifact, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.deploymentArtifact);}}, - {"name": StepNames.informationArtifact, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.informationArtifact);}}, - {"name": StepNames.properties, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.properties);}} - ]; - this.$scope.modalTitle = "Create VF"; - break; - } - case Utils.Constants.ComponentType.SERVICE: { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}}, - - ]; - this.$scope.modalTitle = "Create Service"; - break; - } - case Utils.Constants.ComponentType.PRODUCT: { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.hierarchy, "enabled":false, "callback": ()=> {return this.setCurrentStepByName(StepNames.hierarchy);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}} - ]; - this.$scope.modalTitle = "Create Product"; - break; - } - } - } - } -} diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-state/edit-wizard.ts b/catalog-ui/app/scripts/view-models/wizard/wizard-state/edit-wizard.ts deleted file mode 100644 index 353c487e0a..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-state/edit-wizard.ts +++ /dev/null @@ -1,164 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export class EditWizardViewModel extends WizardCreationBaseViewModel { - - static '$inject' = [ - '$scope', - 'data', - 'ComponentFactory', - '$modalInstance' - ]; - - constructor(public $scope:IWizardCreationScope, - public data:any, - public ComponentFactory: Sdc.Utils.ComponentFactory, - public $modalInstance: ng.ui.bootstrap.IModalServiceInstance) { - - super($scope, data, ComponentFactory, $modalInstance); - this.type = WizardCreationTypes.edit; - this.init(); - this.initCreateAssetScope(); - - // Enable all wizard directive steps - this.enableAllWizardSteps(); - } - - private init = ():void => { - switch (this.data.component.componentType){ - case Utils.Constants.ComponentType.RESOURCE: { - if(this.data.component.isComplex()) { - this.assetCreationSteps = [ - { - "name": StepNames.general, - "url": '/app/scripts/view-models/wizard/general-step/general-step.html' - }, - { - "name": StepNames.icon, - "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html' - }, - { - "name": StepNames.deploymentArtifact, - "url": '/app/scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.html' - }, - { - "name": StepNames.informationArtifact, - "url": '/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html' - }, - { - "name": StepNames.properties, - "url": '/app/scripts/view-models/wizard/properties-step/properties-step.html' - } - ]; - }else{ - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'}, - {"name": StepNames.informationArtifact, "url": '/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html'}, - {"name": StepNames.properties, "url": '/app/scripts/view-models/wizard/properties-step/properties-step.html'} - ]; - } - break; - } - case Utils.Constants.ComponentType.SERVICE: { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'} - ]; - break; - } - case Utils.Constants.ComponentType.PRODUCT: { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.hierarchy, "url": '/app/scripts/view-models/wizard/hierarchy-step/hierarchy-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'} - ]; - break; - } - } - }; - - private initCreateAssetScope = ():void => { - switch (this.data.component.componentType){ - case Utils.Constants.ComponentType.RESOURCE: { - if(this.data.component.isComplex()) { - this.$scope.directiveSteps = [ - { - "name": StepNames.general, "enabled": true, "callback": ()=> { - return this.setCurrentStepByName(StepNames.general); - } - }, - { - "name": StepNames.icon, "enabled": false, "callback": ()=> { - return this.setCurrentStepByName(StepNames.icon); - } - }, - { - "name": StepNames.deploymentArtifact, "enabled": false, "callback": ()=> { - return this.setCurrentStepByName(StepNames.deploymentArtifact); - } - }, - { - "name": StepNames.informationArtifact, "enabled": false, "callback": ()=> { - return this.setCurrentStepByName(StepNames.informationArtifact); - } - }, - { - "name": StepNames.properties, "enabled": false, "callback": ()=> { - return this.setCurrentStepByName(StepNames.properties); - } - } - ]; - }else{ - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}}, - {"name": StepNames.informationArtifact, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.informationArtifact);}}, - {"name": StepNames.properties, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.properties);}} - ]; - } - this.$scope.modalTitle = "Edit " + this.data.component.resourceType; - break; - } - case Utils.Constants.ComponentType.SERVICE: { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}} - ]; - this.$scope.modalTitle = "Edit Service"; - break; - } - case Utils.Constants.ComponentType.PRODUCT: { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.hierarchy, "enabled":false, "callback": ()=> {return this.setCurrentStepByName(StepNames.hierarchy);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}} - ]; - this.$scope.modalTitle = "Edit Product"; - break; - } - } - } - } -} - diff --git a/catalog-ui/app/scripts/view-models/wizard/wizard-state/import-wizard.ts b/catalog-ui/app/scripts/view-models/wizard/wizard-state/import-wizard.ts deleted file mode 100644 index 5fe1bf7e59..0000000000 --- a/catalog-ui/app/scripts/view-models/wizard/wizard-state/import-wizard.ts +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../references"/> -module Sdc.ViewModels.Wizard { - 'use strict'; - - export class ImportWizardViewModel extends WizardCreationBaseViewModel { - - static '$inject' = [ - '$scope', - 'data', - 'ComponentFactory', - '$modalInstance' - ]; - - constructor(public $scope:IWizardCreationScope, - public data:any, - public ComponentFactory: Sdc.Utils.ComponentFactory, - public $modalInstance: ng.ui.bootstrap.IModalServiceInstance) { - - super($scope, data, ComponentFactory, $modalInstance ); - this.type = WizardCreationTypes.importAsset; - this.init(); - this.initImportAssetScope(); - } - - private init = ():void => { - this.assetCreationSteps = [ - {"name": StepNames.general, "url": '/app/scripts/view-models/wizard/general-step/general-step.html'}, - {"name": StepNames.icon, "url": '/app/scripts/view-models/wizard/icons-step/icons-step.html'}, - {"name": StepNames.informationArtifact, "url": '/app/scripts/view-models/wizard/artifact-information-step/artifact-information-step.html'}, - {"name": StepNames.properties, "url": '/app/scripts/view-models/wizard/properties-step/properties-step.html'} - ]; - }; - - private initImportAssetScope = ():void => { - this.$scope.directiveSteps = [ - {"name": StepNames.general, "enabled": true, "callback": ()=> {return this.setCurrentStepByName(StepNames.general);}}, - {"name": StepNames.icon, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.icon);}}, - {"name": StepNames.informationArtifact, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.informationArtifact);}}, - {"name": StepNames.properties, "enabled": false, "callback": ()=> {return this.setCurrentStepByName(StepNames.properties);}} - ]; - - this.$scope.modalTitle = "Import Asset"; - }; - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.ts deleted file mode 100644 index 665d0c0ef6..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.ts +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IActivityLogViewModelScope extends IWorkspaceViewModelScope { - activityDateArray: Array<any>; //this is in order to sort the dates - activityLog: Array<Models.Activity>; - preVersion:string; - - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - searchBind:string; - - getActivityLog(uniqueId:string):void; - onVersionChanged(version:any) : void; - parseAction(action:string):string; - sort(sortBy:string): void; - } - - export class ActivityLogViewModel { - - static '$inject' = [ - '$scope', - '$state', - 'Sdc.Services.ActivityLogService' - ]; - - constructor(private $scope:IActivityLogViewModelScope, - private $state:ng.ui.IStateService, - private activityLogService:Services.ActivityLogService - ) { - - this.initScope(); - this.$scope.setValidState(true); - this.initSortedTableScope(); - this.$scope.updateSelectedMenuItem(); - - // Set default sorting - this.$scope.sortBy = 'logDate'; - } - - private initScope():void { - - this.$scope.preVersion = this.$scope.component.version; - - this.$scope.onVersionChanged = (version:any):void => { - if (version.versionNumber != this.$scope.component.version) { - this.$scope.isLoading = true; - this.$scope.getActivityLog(version.versionId); - } - }; - - this.$scope.getActivityLog = (uniqueId:any):void => { - - let onError = (response) => { - this.$scope.isLoading = false; - console.info('onFaild', response); - - }; - - let onSuccess = (response:Array<Models.Activity>) => { - this.$scope.activityLog = _.sortBy(response, function(o) { return o.TIMESTAMP; }); //response; // - this.$scope.isLoading = false; - }; - - this.$scope.isLoading = true; - if (this.$scope.component.isResource()) { - this.activityLogService.getActivityLogService('resources', uniqueId).then(onSuccess, onError); - } - if (this.$scope.component.isService()) { - this.activityLogService.getActivityLogService('services', uniqueId).then(onSuccess, onError); - } - - }; - - if (!this.$scope.activityLog || this.$scope.preVersion != this.$scope.component.version) { - this.$scope.getActivityLog(this.$scope.component.uniqueId); - } - - this.$scope.parseAction = (action:string) => { - return action ? action.split(/(?=[A-Z])/).join(' ') : ''; - }; - - } - - private initSortedTableScope = ():void => { - this.$scope.tableHeadersList = [ - {title: 'Date', property: 'logDate'}, - {title: 'Action', property: 'logAction'}, - {title: 'Comment', property: 'logComment'}, - {title: 'Username', property: 'logUsername'}, - {title: 'Status', property: 'logStatus'} - ]; - - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes-view-model.ts deleted file mode 100644 index 469da6a2e1..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes-view-model.ts +++ /dev/null @@ -1,107 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IAttributesViewModelScope extends IWorkspaceViewModelScope { - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - - addOrUpdateAttribute(attribute?:Models.AttributeModel): void; - delete(attribute:Models.AttributeModel): void; - sort(sortBy:string): void; - } - - export class AttributesViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ModalsHandler' - ]; - - - constructor(private $scope:IAttributesViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private ModalsHandler:Utils.ModalsHandler) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - - private openEditAttributeModal = (attribute:Models.AttributeModel):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/attribute-form/attribute-form-view.html'), - controller: 'Sdc.ViewModels.AttributeFormViewModel', - size: 'sdc-md', - backdrop: 'static', - keyboard: false, - resolve: { - attribute: ():Models.AttributeModel => { - return attribute; - }, - component: ():Models.Components.Component => { - return <Models.Components.Component> this.$scope.component; - } - } - }; - this.$modal.open(modalOptions); - }; - - private initScope = ():void => { - - //let self = this; - this.$scope.sortBy = 'name'; - this.$scope.reverse = false; - this.$scope.setValidState(true); - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Type', property: 'type'}, - {title: 'Default Value', property: 'defaultValue'} - ]; - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - this.$scope.addOrUpdateAttribute = (attribute?:Models.AttributeModel):void => { - this.openEditAttributeModal(attribute ? attribute : new Models.AttributeModel()); - }; - - this.$scope.delete = (attribute:Models.AttributeModel):void => { - - let onOk = ():void => { - this.$scope.component.deleteAttribute(attribute.uniqueId); - }; - let title:string = this.$filter('translate')("ATTRIBUTE_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("ATTRIBUTE_VIEW_DELETE_MODAL_TEXT", "{'name': '" + attribute.name + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition-view-model.ts deleted file mode 100644 index f8eeaf7f64..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition-view-model.ts +++ /dev/null @@ -1,232 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface ICompositionViewModelScope extends IWorkspaceViewModelScope { - - currentComponent: Models.Components.Component; - selectedComponent: Models.Components.Component; - isLoading: boolean; - graphApi:any; - sharingService:Sdc.Services.SharingService; - sdcMenu:Models.IAppMenu; - version:string; - isViewOnly:boolean; - isLoadingRightPanel:boolean; - setComponent(component: Models.Components.Component); - isComponentInstanceSelected():boolean; - updateSelectedComponent(): void - openUpdateModal(); - deleteSelectedComponentInstance():void; - onBackgroundClick():void; - setSelectedInstance(componentInstance: Models.ComponentsInstances.ComponentInstance): void; - printScreen():void; - - cacheComponentsInstancesFullData: Models.Components.Component; - } - - export class CompositionViewModel { - - static '$inject' = [ - '$scope', - '$log', - 'sdcMenu', - 'MenuHandler', - '$modal', - '$templateCache', - '$state', - 'Sdc.Services.SharingService', - '$filter', - 'Sdc.Services.CacheService', - 'ComponentFactory', - 'ChangeLifecycleStateHandler', - 'LeftPaletteLoaderService', - 'ModalsHandler', - 'EventListenerService' - ]; - - constructor(private $scope:ICompositionViewModelScope, - private $log: ng.ILogService, - private sdcMenu:Models.IAppMenu, - private MenuHandler: Utils.MenuHandler, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private $state:ng.ui.IStateService, - private sharingService:Services.SharingService, - private $filter:ng.IFilterService, - private cacheService:Services.CacheService, - private ComponentFactory: Utils.ComponentFactory, - private ChangeLifecycleStateHandler: Sdc.Utils.ChangeLifecycleStateHandler, - private LeftPaletteLoaderService: Services.Components.LeftPaletteLoaderService, - private ModalsHandler: Sdc.Utils.ModalsHandler, - private eventListenerService:Services.EventListenerService) { - - this.$scope.setValidState(true); - this.initScope(); - this.$scope.updateSelectedMenuItem(); - this.registerGraphEvents(this.$scope); - } - private cacheComponentsInstancesFullData: Array<Models.Components.Component>; - - private initComponent = ():void => { - - this.$scope.currentComponent = this.$scope.component; - this.$scope.selectedComponent = this.$scope.currentComponent; - this.updateUuidMap(); - this.$scope.isViewOnly = this.$scope.isViewMode(); - }; - private registerGraphEvents = (scope:ICompositionViewModelScope):void => { - - this.eventListenerService.registerObserverCallback(Utils.Constants.GRAPH_EVENTS.ON_NODE_SELECTED, scope.setSelectedInstance); - this.eventListenerService.registerObserverCallback(Utils.Constants.GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, scope.onBackgroundClick); - - } - private openUpdateComponentInstanceNameModal = ():void => { - - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/resource-instance-name-form/resource-instance-name-view.html'), - controller: 'Sdc.ViewModels.ResourceInstanceNameViewModel', - size: 'sdc-sm', - backdrop: 'static', - resolve: { - component: ():Models.Components.Component => { - return this.$scope.currentComponent; - - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - modalInstance.result.then(():void => { - this.eventListenerService.notifyObservers(Utils.Constants.GRAPH_EVENTS.ON_COMPONENT_INSTANCE_NAME_CHANGED, this.$scope.currentComponent.selectedInstance); - //this.$scope.graphApi.updateNodeName(this.$scope.currentComponent.selectedInstance); - }); - }; - - private removeSelectedComponentInstance = ():void => { - this.eventListenerService.notifyObservers(Utils.Constants.GRAPH_EVENTS.ON_DELETE_MULTIPLE_COMPONENTS); - }; - - private updateUuidMap = ():void => { - /** - * In case user press F5, the page is refreshed and this.sharingService.currentEntity will be undefined, - * but after loadService or loadResource this.sharingService.currentEntity will be defined. - * Need to update the uuidMap with the new resource or service. - */ - this.sharingService.addUuidValue(this.$scope.currentComponent.uniqueId,this.$scope.currentComponent.uuid); - }; - - private initScope = ():void => { - - this.$scope.sharingService = this.sharingService; - this.$scope.sdcMenu = this.sdcMenu; - this.$scope.isLoading = false; - this.$scope.isLoadingRightPanel = false; - this.$scope.graphApi = {}; - this.$scope.version = this.cacheService.get('version'); - this.initComponent(); - - this.cacheComponentsInstancesFullData = new Array<Models.Components.Component>(); - - this.$scope.isComponentInstanceSelected = ():boolean => { - return this.$scope.currentComponent && this.$scope.currentComponent.selectedInstance != undefined && this.$scope.currentComponent.selectedInstance != null; - }; - - this.$scope.updateSelectedComponent = (): void => { - if(this.$scope.currentComponent.selectedInstance){ - - let componentParent = _.find(this.cacheComponentsInstancesFullData, (component) => { - return component.uniqueId === this.$scope.currentComponent.selectedInstance.componentUid; - }); - if(componentParent) { - this.$scope.selectedComponent = componentParent; - } - else { - try { - let onSuccess = (component:Models.Components.Component) => { - this.$scope.isLoadingRightPanel = false; - this.$scope.selectedComponent = component; - this.cacheComponentsInstancesFullData.push(component); - }; - let onError = (component:Models.Components.Component) => { - console.log("Error updating selected component"); - this.$scope.isLoadingRightPanel = false; - }; - this.ComponentFactory.getComponentFromServer(this.$scope.currentComponent.selectedInstance.originType, this.$scope.currentComponent.selectedInstance.componentUid).then(onSuccess, onError); - } catch(e){ - console.log("Error updating selected component", e); - this.$scope.isLoadingRightPanel = false; - } - } - } - else { - this.$scope.selectedComponent = this.$scope.currentComponent; - } - }; - - this.$scope.setSelectedInstance = (selectedComponent:Models.ComponentsInstances.ComponentInstance):void => { - - this.$log.debug('composition-view-model::onNodeSelected:: with id: '+ selectedComponent.uniqueId); - this.$scope.currentComponent.setSelectedInstance(selectedComponent); - this.$scope.updateSelectedComponent(); - - if (this.$state.current.name === 'workspace.composition.api') { - this.$state.go('workspace.composition.details'); - } - if (this.$state.current.name === 'workspace.composition.relations' && this.$scope.currentComponent.isProduct()) { - this.$state.go('workspace.composition.details'); - } - }; - - this.$scope.onBackgroundClick = ():void => { - this.$scope.currentComponent.selectedInstance = null; - this.$scope.selectedComponent = this.$scope.currentComponent; - - if (this.$state.current.name === 'workspace.composition.api') { - this.$state.go('workspace.composition.details'); - } - }; - - this.$scope.openUpdateModal = ():void => { - this.openUpdateComponentInstanceNameModal(); - }; - - this.$scope.deleteSelectedComponentInstance = ():void => { - let state = "deleteInstance"; - let onOk = ():void => { - this.removeSelectedComponentInstance(); - //this.$scope.graphApi.deleteSelectedNodes(); - }; - let title:string = this.$scope.sdcMenu.alertMessages[state].title; - let message:string = this.$scope.sdcMenu.alertMessages[state].message.format([this.$scope.currentComponent.selectedInstance.name]); - this.ModalsHandler.openAlertModal(title, message).then(onOk); - }; - - this.$scope.setComponent = (component: Models.Components.Product):void => { - this.$scope.currentComponent = component; - } - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts deleted file mode 100644 index 5bb5d2cbbd..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts +++ /dev/null @@ -1,255 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - - export interface IArtifactsViewModelScope extends ICompositionViewModelScope { - artifacts: Array<Models.ArtifactModel>; - artifactType: string; - downloadFile:Models.IFileDownload; - isLoading:boolean; - - getTitle(): string; - addOrUpdate(artifact:Models.ArtifactModel): void; - delete(artifact:Models.ArtifactModel): void; - download(artifact:Models.ArtifactModel): void; - openEditEnvParametersModal(artifact:Models.ArtifactModel):void; - getEnvArtifact(heatArtifact:Models.ArtifactModel):any; - getEnvArtifactName(artifact:Models.ArtifactModel):string; - isLicenseArtifact(artifact:Models.ArtifactModel):boolean; - isVFiArtifact(artifact:Models.ArtifactModel):boolean; - } - - export class ResourceArtifactsViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - '$state', - 'sdcConfig', - 'ArtifactsUtils', - 'ModalsHandler', - 'Sdc.Services.CacheService' - ]; - - constructor(private $scope:IArtifactsViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private $state:any, - private sdcConfig:Models.IAppConfigurtaion, - private artifactsUtils:Sdc.Utils.ArtifactsUtils, - private ModalsHandler: Utils.ModalsHandler, - private cacheService:Services.CacheService) { - - this.initScope(); - } - - - private initArtifactArr = (artifactType:string):void => { - let artifacts:Array<Models.ArtifactModel> = []; - - if (this.$scope.selectedComponent) { - if ('interface' == artifactType) { - let interfaces = this.$scope.selectedComponent.interfaces; - if (interfaces && interfaces.standard && interfaces.standard.operations) { - - angular.forEach(interfaces.standard.operations, (operation:any, interfaceName:string):void => { - let item:Sdc.Models.ArtifactModel = <Sdc.Models.ArtifactModel>{}; - if (operation.implementation) { - item = <Sdc.Models.ArtifactModel> operation.implementation; - } - item.artifactDisplayName = interfaceName; - item.artifactLabel = interfaceName; - item.mandatory = false; - artifacts.push(item); - }); - } - }else { - //init normal artifacts, deployment or api artifacts - let artifactsObj:Models.ArtifactGroupModel; - switch (artifactType) { - case "api": - artifactsObj = (<Models.Components.Service>this.$scope.selectedComponent).serviceApiArtifacts; - break; - case "deployment": - if (!this.$scope.isComponentInstanceSelected()) { - artifactsObj = this.$scope.selectedComponent.deploymentArtifacts; - } else { - artifactsObj = this.$scope.currentComponent.selectedInstance.deploymentArtifacts; - } - break; - default: - artifactsObj = this.$scope.selectedComponent.artifacts; - break; - } - _.forEach(artifactsObj, (artifact:Models.ArtifactModel, key) => { - artifacts.push(artifact); - }); - } - } - this.$scope.artifacts = artifacts; - }; - - private openEditArtifactModal = (artifact:Models.ArtifactModel):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/artifact-form/artifact-form-view.html'), - controller: 'Sdc.ViewModels.ArtifactResourceFormViewModel', - size: 'sdc-md', - backdrop: 'static', - keyboard: false, - resolve: { - artifact: ():Models.ArtifactModel => { - return artifact; - }, - component: (): Models.Components.Component => { - return this.$scope.currentComponent; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - modalInstance - .result - .then(():void => { - this.initArtifactArr(this.$scope.artifactType); - }); - }; - - private initScope = ():void => { - let self = this; - this.$scope.isLoading= false; - this.$scope.artifactType = this.artifactsUtils.getArtifactTypeByState(this.$state.current.name); - this.initArtifactArr(this.$scope.artifactType); - - this.$scope.getTitle = ():string => { - return this.artifactsUtils.getTitle(this.$scope.artifactType, this.$scope.selectedComponent); - }; - - let vfiArtifactTypes:any = this.cacheService.get('UIConfiguration').artifacts.deployment.resourceInstanceDeploymentArtifacts; - - this.$scope.isVFiArtifact=(artifact:Models.ArtifactModel):boolean=>{ - return vfiArtifactTypes[artifact.artifactType]; - } - - this.$scope.$watch('selectedComponent', (newResource:Models.Components.Component):void => { - if (newResource) { - this.initArtifactArr(this.$scope.artifactType); - } - }); - - - this.$scope.$watch('currentComponent.selectedInstance', (newInstance:Models.ComponentsInstances.ComponentInstance):void => { - if (newInstance) { - this.initArtifactArr(this.$scope.artifactType); - } - }); - - this.$scope.addOrUpdate = (artifact:Models.ArtifactModel):void => { - this.artifactsUtils.setArtifactType(artifact, this.$scope.artifactType); - let artifactCopy = new Models.ArtifactModel(artifact); - this.openEditArtifactModal(artifactCopy); - }; - - - this.$scope.delete = (artifact:Models.ArtifactModel):void => { - - let onOk = ():void => { - this.$scope.isLoading= true; - this.artifactsUtils.removeArtifact(artifact, this.$scope.artifacts); - - let success = (responseArtifact:Models.ArtifactModel):void => { - this.initArtifactArr(this.$scope.artifactType); - this.$scope.isLoading= false; - }; - - let error =(error:any):void =>{ - console.log('Delete artifact returned error:', error); - this.initArtifactArr(this.$scope.artifactType); - this.$scope.isLoading= false; - }; - if(this.$scope.isComponentInstanceSelected()){ - this.$scope.currentComponent.deleteInstanceArtifact(artifact.uniqueId, artifact.artifactLabel).then(success, error); - }else{ - this.$scope.currentComponent.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(success, error);//TODO simulate error (make sure error returns) - } - }; - let title: string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); - let message: string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - - - this.$scope.getEnvArtifact = (heatArtifact:Models.ArtifactModel):any=>{ - return _.find(this.$scope.artifacts, (item:Models.ArtifactModel)=>{ - return item.generatedFromId === heatArtifact.uniqueId; - }); - }; - - this.$scope.getEnvArtifactName = (artifact:Models.ArtifactModel):string =>{ - let envArtifact = this.$scope.getEnvArtifact(artifact); - if(envArtifact){ - return envArtifact.artifactDisplayName; - } - }; - - this.$scope.isLicenseArtifact = (artifact:Models.ArtifactModel) :boolean => { - let isLicense:boolean = false; - if(this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { - isLicense = this.artifactsUtils.isLicenseType(artifact.artifactType); - } - - return isLicense; - }; - - this.$scope.openEditEnvParametersModal = (artifact:Models.ArtifactModel):void => { - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get('/app/scripts/view-models/forms/env-parameters-form/env-parameters-form.html'), - controller: 'Sdc.ViewModels.EnvParametersFormViewModel', - size: 'sdc-md', - backdrop: 'static', - resolve: { - artifact: ():Models.ArtifactModel => { - return artifact; - }, - component: (): Models.Components.Component => { - return this.$scope.currentComponent; - } - } - }; - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - modalInstance - .result - .then(():void => { - this.initArtifactArr(this.$scope.artifactType); - }); - }; - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts deleted file mode 100644 index b28de8d331..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../../references"/> -module Sdc.ViewModels { - - 'use strict'; - - export interface IEditResourceVersion { - allVersions: any; - changeVersion: string; - } - - interface IDetailsViewModelScope extends ICompositionViewModelScope { - isLoading: boolean; - $parent: ICompositionViewModelScope; - expandedSection: Array<string>; - editForm:ng.IFormController; - editResourceVersion: IEditResourceVersion; - - changeResourceVersion(): void; - } - - export class DetailsViewModel { - - static '$inject' = [ - '$scope', - 'LeftPaletteLoaderService', - 'EventListenerService' - - ]; - - constructor(private $scope:IDetailsViewModelScope, - private LeftPaletteLoaderService:Services.Components.LeftPaletteLoaderService, - private eventListenerService:Services.EventListenerService) { - this.initScope(); - } - - private clearSelectedVersion = ():void => { - this.$scope.editResourceVersion = { - allVersions: {}, - changeVersion: null - }; - }; - - private versioning:Function = (versionNumber:string):string => { - let version:Array<string> = versionNumber.split('.'); - return '00000000'.slice(version[0].length) + version[0] + '.' + '00000000'.slice(version[1].length) + version[1]; - }; - - private initEditResourceVersion = ():void => { - this.clearSelectedVersion(); - this.$scope.editResourceVersion.allVersions[this.$scope.currentComponent.selectedInstance.componentVersion] = this.$scope.currentComponent.selectedInstance.componentUid; - _.merge(this.$scope.editResourceVersion.allVersions, angular.copy(this.$scope.selectedComponent.allVersions)); - let sorted:any= _.sortBy(_.toPairs(this.$scope.editResourceVersion.allVersions), (item)=>{ - return this.versioning(item[0]); - }); - this.clearSelectedVersion(); - _.forEach(sorted, (item)=> { - this.$scope.editResourceVersion.allVersions[item[0]]= item[1]; - }); - - let highestVersion = _.last(Object.keys(this.$scope.selectedComponent.allVersions)); - - //TODO - ask ronny - what happend if the parent is not in the leftPalette (instance of csar for example) - if (parseFloat(highestVersion) % 1) { //if highest is minor, make sure it is the latest checked in - - let latestVersionComponent:Models.Components.Component = _.find(this.LeftPaletteLoaderService.getFullDataComponentListWithVls(this.$scope.currentComponent.componentType), (component:Models.Components.Component) => { //latest checked in - return (component.systemName === this.$scope.selectedComponent.systemName - || component.uuid === this.$scope.selectedComponent.uuid); - }); - let latestVersion:string = latestVersionComponent ? latestVersionComponent.version : highestVersion; - - if (highestVersion != latestVersion) { //highest is checked out - remove from options - this.$scope.editResourceVersion.allVersions = _.omit(this.$scope.editResourceVersion.allVersions, highestVersion); - } - } - this.$scope.editResourceVersion.changeVersion = this.$scope.currentComponent.selectedInstance.componentVersion; - }; - - private initScope = ():void => { - this.$scope.isLoading = false; - this.$scope.$parent.isLoading = false; - this.$scope.expandedSection = ['general', 'tags']; - //this.clearSelectedVersion(); - - this.$scope.$watch('selectedComponent', (component:Models.Components.Component) => { - if (this.$scope.isComponentInstanceSelected()) { - this.initEditResourceVersion(); - } - }); - - this.$scope.changeResourceVersion = ():void => { - this.$scope.isLoading = true; - this.$scope.$parent.isLoading = true; - - let onSuccess = (component:Models.Components.Component)=> { - this.$scope.isLoading = false; - this.$scope.$parent.isLoading = false; - this.$scope.setComponent(component); - this.$scope.updateSelectedComponent(); - - this.eventListenerService.notifyObservers(Sdc.Utils.Constants.GRAPH_EVENTS.ON_VERSION_CHANGED, this.$scope.currentComponent); - }; - - let onFailed = (error:any)=> { - this.$scope.isLoading = false; - this.$scope.$parent.isLoading = false; - console.log(error); - }; - - let componentUid:string = this.$scope.editResourceVersion.allVersions[this.$scope.editResourceVersion.changeVersion]; - this.$scope.currentComponent.changeComponentInstanceVersion(componentUid).then(onSuccess, onFailed); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts deleted file mode 100644 index aef25c51ce..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts +++ /dev/null @@ -1,228 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IResourcePropertiesAndAttributesViewModelScope extends ICompositionViewModelScope { - properties: Models.PropertiesGroup; - attributes: Models.AttributesGroup; - propertiesMessage: string; - addProperty(): void; - updateProperty(property:Models.PropertyModel): void; - deleteProperty(property:Models.PropertyModel): void; - viewAttribute(attribute:Models.AttributeModel): void; - groupNameByKey(key:string): string; - isPropertyOwner():boolean; - } - - export class ResourcePropertiesViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ModalsHandler' - ]; - - - constructor(private $scope:IResourcePropertiesAndAttributesViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private ModalsHandler: Utils.ModalsHandler) { - - this.initScope(); - } - - private initComponentProperties = ():void => { - let result:Models.PropertiesGroup = {}; - - if(this.$scope.selectedComponent){ - this.$scope.propertiesMessage = undefined; - if(this.$scope.isComponentInstanceSelected()){ - if (this.$scope.currentComponent.selectedInstance.originType==='VF') { - // Temporally fix to hide properties for VF (UI stack when there are many properties) - this.$scope.propertiesMessage = "Note: properties for VF are disabled"; - } else { - result[this.$scope.currentComponent.selectedInstance.uniqueId] = this.$scope.currentComponent.componentInstancesProperties[this.$scope.currentComponent.selectedInstance.uniqueId]; - } - }else if(this.$scope.currentComponent.isService()){ - // Temporally fix to hide properties for service (UI stack when there are many properties) - //result = this.$scope.currentComponent.componentInstancesProperties; - this.$scope.propertiesMessage = "Note: properties for service are disabled"; - }else{ - let key = this.$scope.selectedComponent.uniqueId; - result[key]= Array<Models.PropertyModel>(); - let derived = Array<Models.PropertyModel>(); - _.forEach(this.$scope.selectedComponent.properties, (property:Models.PropertyModel) => { - if(key == property.parentUniqueId){ - result[key].push(property); - }else{ - property.readonly = true; - derived.push(property); - } - }); - if(derived.length){ - result['derived']= derived; - } - } - this.$scope.properties = result; - } - }; - - - private initComponentAttributes = ():void => { - let result:Models.AttributesGroup = {}; - - if(this.$scope.selectedComponent){ - if(this.$scope.isComponentInstanceSelected()){ - result[this.$scope.currentComponent.selectedInstance.uniqueId] = this.$scope.currentComponent.componentInstancesAttributes[this.$scope.currentComponent.selectedInstance.uniqueId]; - }else if(this.$scope.currentComponent.isService()){ - result = this.$scope.currentComponent.componentInstancesAttributes; - } - this.$scope.attributes = result; - } - }; - - private openEditPropertyModal = (property:Models.PropertyModel):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/property-form/property-form-view.html'), - controller: 'Sdc.ViewModels.PropertyFormViewModel', - size: 'sdc-l', - backdrop: 'static', - keyboard: false, - resolve: { - property: ():Models.PropertyModel => { - return property; - }, - component: ():Models.Components.Component => { - return this.$scope.currentComponent; - }, - filteredProperties: ():Array<Models.PropertyModel> => { - return this.$scope.selectedComponent.properties - } - } - }; - - - let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$modal.open(modalOptions); - modalInstance - .result - .then(():void => { - // this.initComponentProperties(); - }); - }; - - private openAttributeModal = (atrribute:Models.AttributeModel):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/attribute-form/attribute-form-view.html'), - controller: 'Sdc.ViewModels.AttributeFormViewModel', - size: 'sdc-md', - backdrop: 'static', - keyboard: false, - resolve: { - attribute: ():Models.AttributeModel => { - return atrribute; - }, - component: ():Models.Components.Component => { - return this.$scope.currentComponent; - } - } - }; - this.$modal.open(modalOptions); - }; - - - - - private initScope = ():void => { - this.initComponentProperties(); - this.initComponentAttributes(); - - this.$scope.$watchCollection('currentComponent.componentInstancesProperties', (newData:any):void => { - this.initComponentProperties(); - }); - - this.$scope.$watchCollection('currentComponent.properties', (newData:any):void => { - this.initComponentProperties(); - }); - - this.$scope.$watch('currentComponent.selectedInstance', (newInstance:Models.ComponentsInstances.ComponentInstance):void => { - if (angular.isDefined(newInstance)) { - this.initComponentProperties(); - this.initComponentAttributes(); - } - }); - - this.$scope.$watchCollection('currentComponent.componentInstancesAttributes', (newData:any):void => { - this.initComponentAttributes(); - }); - - this.$scope.isPropertyOwner = ():boolean => { - return this.$scope.currentComponent && this.$scope.currentComponent.isResource() && - !this.$scope.isComponentInstanceSelected(); - }; - - this.$scope.addProperty = ():void => { - let property = new Models.PropertyModel(); - this.openEditPropertyModal(property); - }; - - this.$scope.updateProperty = (property:Models.PropertyModel):void => { - this.openEditPropertyModal(property); - }; - - this.$scope.deleteProperty = (property:Models.PropertyModel):void => { - - let onOk = ():void => { - this.$scope.currentComponent.deleteProperty(property.uniqueId); - }; - - let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - - this.$scope.viewAttribute = (attribute:Models.AttributeModel):void => { - this.openAttributeModal(attribute); - }; - - this.$scope.groupNameByKey = (key:string):string => { - switch (key){ - case 'derived': - return "Derived"; - - case this.$scope.currentComponent.uniqueId: - return this.$filter("resourceName")(this.$scope.currentComponent.name); - - default: - return this.$filter("resourceName")((_.find(this.$scope.currentComponent.componentInstances, {uniqueId:key})).name); - } - }; - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts deleted file mode 100644 index 119a59d5af..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../../references"/>> -module Sdc.ViewModels { - 'use strict'; - - interface IRelationsViewModelScope extends ICompositionViewModelScope { - isLoading: boolean; - $parent: ICompositionViewModelScope; - getRelation(requirement:any): any; - } - - export class RelationsViewModel { - - static '$inject' = [ - '$scope', - '$filter' - ]; - - constructor(private $scope:IRelationsViewModelScope, - private $filter:ng.IFilterService) { - this.initScope(); - } - - - private updateRC = ():void =>{ - if(this.$scope.currentComponent) { - this.$scope.currentComponent.updateRequirementsCapabilities(); - } - }; - - private initScope = ():void => { - - this.$scope.isLoading = this.$scope.$parent.isLoading; - - this.$scope.getRelation = (requirement:any):any => { - - if(this.$scope.isComponentInstanceSelected() && this.$scope.currentComponent.componentInstancesRelations ) { - let relationItem = _.filter(this.$scope.currentComponent.componentInstancesRelations, (relation:any) => { - return relation.fromNode === this.$scope.currentComponent.selectedInstance.uniqueId && - _.some(relation.relationships, {'requirement': requirement.name, - 'requirementOwnerId': requirement.ownerId}); - }); - - if (relationItem && relationItem.length) { - return { - type: requirement.relationship.split('.').pop(), - requirementName: this.$filter('resourceName')(this.$scope.currentComponent.componentInstances[_.map - (this.$scope.currentComponent.componentInstances, "uniqueId").indexOf(relationItem[0].toNode)].name) - }; - } - } - return null; - }; - - if(!this.$scope.isComponentInstanceSelected()) { - this.$scope.$watch('currentComponent.componentInstances + currentComponent.componentInstancesRelations', ():void => { - this.updateRC(); - }); - - } - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view.html b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view.html deleted file mode 100644 index 72eaae27cf..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations-view.html +++ /dev/null @@ -1,57 +0,0 @@ -<perfect-scrollbar class="w-sdc-designer-sidebar-tab-content relations"> - - <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> - <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.capabilities" class="w-sdc-designer-sidebar-section-title"> - Capabilities - <div class="w-sdc-designer-sidebar-section-title-icon"></div> - </expand-collapse> - - <div class="w-sdc-designer-sidebar-section-content capabilities"> - <div class="i-sdc-designer-sidebar-section-content-item"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-group" data-ng-repeat="(key, value) in (isComponentInstanceSelected() ? currentComponent.selectedInstance.capabilities : selectedComponent.capabilities) track by $index"> - <div class="i-sdc-designer-sidebar-section-content-item-relations" data-ng-repeat="capability in value track by $index"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{capability.name}} - <span ng-if="selectedComponent.isComplex() && capability.ownerName" - class="i-sdc-designer-sidebar-section-content-item-relations-details-ownerName" - tooltips tooltip-class="tooltip-custom break-word-tooltip" - tooltip-content="{{capability.ownerName | resourceName}}"> {{capability.ownerName | resourceName}}</span></div> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-desc">{{capability.type}}</div> - </div></div> - </div> - </div> - </div> - </div> - - <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> - <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.requirements" class="w-sdc-designer-sidebar-section-title"> - Requirements - <div class="w-sdc-designer-sidebar-section-title-icon"></div> - </expand-collapse> - - <div class="w-sdc-designer-sidebar-section-content requirements"> - <div class="i-sdc-designer-sidebar-section-content-item"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-group" data-ng-repeat="(key, value) in (isComponentInstanceSelected() ? currentComponent.selectedInstance.requirements : selectedComponent.requirements) track by $index"> - <div class="i-sdc-designer-sidebar-section-content-item-relations" data-ng-repeat="requirement in value track by $index"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{requirement.name}} - <span ng-if="selectedComponent.isComplex() && requirement.ownerName" - class="i-sdc-designer-sidebar-section-content-item-relations-details-ownerName" - tooltips tooltip-class="tooltip-custom break-word-tooltip" - tooltip-content="{{requirement.ownerName | resourceName}}"> {{requirement.ownerName | resourceName}}</span></div> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-desc">{{requirement.node}} - <div data-ng-if="getRelation(requirement) != null"> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-indent-box"></div> - <div class="i-sdc-designer-sidebar-section-content-item-relations-details-child"> - <span class="i-sdc-designer-sidebar-section-content-item-relations-details-desc">{{getRelation(requirement).type}} <br/></span> - <span class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{getRelation(requirement).requirementName}}</span> - </div> - </div> - </div> - </div></div> - </div> - </div> - </div> - </div> - -</perfect-scrollbar> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts deleted file mode 100644 index daeab7f2f3..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IStructureViewModel extends ICompositionViewModelScope {} - - export class StructureViewModel { - static '$inject' = [ - '$scope' - ]; - - constructor(private $scope:IStructureViewModel) { - } - } - } diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts deleted file mode 100644 index 43511e2deb..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts +++ /dev/null @@ -1,253 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - import ArtifactModel = Sdc.Models.ArtifactModel; - - interface IDeploymentArtifactsViewModelScope extends IWorkspaceViewModelScope { - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - artifacts: Array<Models.ArtifactModel>; - editForm:ng.IFormController; - isLoading:boolean; - artifactDescriptions:any; - updateInProgress:boolean; - - addOrUpdate(artifact:Models.ArtifactModel): void; - update(artifact:Models.ArtifactModel): void; - delete(artifact:Models.ArtifactModel): void; - sort(sortBy:string): void; - noArtifactsToShow():boolean; - getValidationPattern(validationType:string, parameterType?:string):RegExp; - validateJson(json:string):boolean; - resetValue(parameter:any):void; - viewModeOrCsarComponent():boolean; - isLicenseArtifact(artifact:Models.ArtifactModel): boolean; - - } - - export class DeploymentArtifactsViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ValidationUtils', - 'ArtifactsUtils', - 'ModalsHandler' - ]; - - constructor(private $scope:IDeploymentArtifactsViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private validationUtils:Sdc.Utils.ValidationUtils, - private artifactsUtils:Sdc.Utils.ArtifactsUtils, - private ModalsHandler:Utils.ModalsHandler) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - private initDescriptions = ():void => { - this.$scope.artifactDescriptions = {}; - _.forEach(this.$scope.component.deploymentArtifacts, (artifact:Models.ArtifactModel):void => { - this.$scope.artifactDescriptions[artifact.artifactLabel] = artifact.description; - }); - }; - - - private setArtifact = (artifact:Models.ArtifactModel):void => { - if (artifact.heatParameters) { - artifact.heatParameters.forEach((parameter:any):void => { - if (!parameter.currentValue && parameter.defaultValue) { - parameter.currentValue = parameter.defaultValue; - } else if ("" === parameter.currentValue) { - parameter.currentValue = null; - } - }); - } - if (!artifact.description || !this.$scope.getValidationPattern('string').test(artifact.description)) { - artifact.description = this.$scope.artifactDescriptions[artifact.artifactLabel]; - } - }; - - private updateAll = ():void => { - let artifacts:Array<Models.ArtifactModel> = []; - _.forEach(this.$scope.component.deploymentArtifacts, (artifact:Models.ArtifactModel):void => { - if (artifact.selected) { - this.setArtifact(artifact); - artifacts.push(artifact); - } - }); - this.$scope.component.updateMultipleArtifacts(artifacts); - }; - - - private initScope = ():void => { - let self = this; - this.$scope.isLoading = false; - this.$scope.updateInProgress = false; - this.initDescriptions(); - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - this.$scope.setValidState(true); - - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'artifactDisplayName'}, - {title: 'Type', property: 'artifactType'}, - {title: 'Deployment timeout', property: 'timeout'} - ]; - - this.$scope.isLicenseArtifact = (artifact:Models.ArtifactModel) :boolean => { - let isLicense:boolean = false; - if(this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { - - isLicense = this.artifactsUtils.isLicenseType(artifact.artifactType); - } - - return isLicense; - }; - - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - this.$scope.getValidationPattern = (validationType:string, parameterType?:string):RegExp => { - return this.validationUtils.getValidationPattern(validationType, parameterType); - }; - - this.$scope.validateJson = (json:string):boolean => { - if(!json){ - return true; - } - return this.validationUtils.validateJson(json); - }; - - this.$scope.viewModeOrCsarComponent = ():boolean => { - return this.$scope.isViewMode() || (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()); - }; - - - this.$scope.addOrUpdate = (artifact:Models.ArtifactModel):void => { - artifact.artifactGroupType = 'DEPLOYMENT'; - let artifactCopy = new Models.ArtifactModel(artifact); - - let success = (response:any):void => { - self.$scope.artifactDescriptions[artifactCopy.artifactLabel] = artifactCopy.description; - self.$scope.artifacts = <ArtifactModel[]>_.values(self.$scope.component.deploymentArtifacts); - }; - - let error = (err:any):void =>{ - console.log(err); - self.$scope.artifacts = <ArtifactModel[]>_.values(self.$scope.component.deploymentArtifacts); - }; - - - this.ModalsHandler.openWizardArtifactModal(artifactCopy, self.$scope.component).then(success, error); - }; - - this.$scope.noArtifactsToShow = ():boolean => { - return !_.some(this.$scope.artifacts, 'esId'); - }; - - - this.$scope.resetValue = (parameter:any):void => { - if (!parameter.currentValue && parameter.defaultValue) { - parameter.currentValue = parameter.defaultValue; - } - else if ('boolean' == parameter.type) { - parameter.currentValue = parameter.currentValue.toUpperCase(); - } - }; - - - this.$scope.$watch('editForm.$valid', ():void => { - if (this.$scope.editForm) { - // this.$scope.setValidState(this.$scope.editForm.$valid); - } - }); - - this.$scope.update = (artifact:Models.ArtifactModel):void => { - if (false == this.$scope.isLoading) { - if (artifact.selected && !this.$scope.isViewMode()) { - this.$scope.isLoading = true; - this.$scope.updateInProgress = true; - let onSuccess = (responseArtifact:Models.ArtifactModel):void => { - this.$scope.artifactDescriptions[responseArtifact.artifactLabel] = responseArtifact.description; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - this.$scope.isLoading = false; - artifact.selected = !artifact.selected; - this.$scope.updateInProgress = false; - }; - - let onFailed = (error:any):void => { - console.log('Delete artifact returned error:', error); - this.$scope.isLoading = false; - artifact.selected = !artifact.selected; - this.$scope.updateInProgress = false; - }; - - this.setArtifact(artifact); - this.$scope.component.addOrUpdateArtifact(artifact).then(onSuccess, onFailed); - } else { - artifact.selected = !artifact.selected; - - } - } - }; - - this.$scope.delete = (artifact:Models.ArtifactModel):void => { - let onOk = ():void => { - this.$scope.isLoading = true; - let onSuccess = ():void => { - this.$scope.isLoading = false; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); - }; - - let onFailed = (error:any):void => { - this.$scope.isLoading = false; - console.log('Delete artifact returned error:', error); - }; - - this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); - }; - - let title:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); - let message:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - }; - - public save = (callback:Function):void => { - this.updateAll(); - this.$scope.setComponent(this.$scope.component); - callback(true); - }; - - public back = (callback:Function):void => { - this.$scope.setComponent(this.$scope.component); - callback(true); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html b/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html deleted file mode 100644 index 1547618134..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html +++ /dev/null @@ -1,149 +0,0 @@ -<div class="workspace-deployment-artifact"> - - <div data-tests-id="add-deployment-artifact-button" ng-if="!isViewMode()" data-ng-class="{'disabled': isDisableMode()}" data-tests-id="add-property-button" class="add-btn" data-ng-click="addOrUpdate({})">Add</div> - - <div class="table-container-flex"> - - <div class="table" data-ng-class="{'view-mode': isViewMode()}"> - <loader data-display="isLoading"></loader> - <div class="head flex-container"> - <div class="table-header head-row hand flex-item" data-ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} - <span data-ng-if="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> - </div> - <div class="table-no-text-header head-row flex-item"></div> - </div> - - <form class="body" name="editForm"> - - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - - <!-- Artifact row --> - <div ng-if="noArtifactsToShow()" data-ng-class="{'disabled': isDisableMode()}" class="no-row-text" translate="DEPLOYMENT_ARTIFACT_NO_ARTIFACTS_TO_DISPLAY"></div> - <div data-ng-repeat-start="artifact in artifacts | orderBy:sortBy:reverse track by $index" - class="flex-container data-row" - data-ng-class="{'selected': artifact.selected || undefined==artifact.selected && updateInProgress}" - data-ng-if="artifact.esId"> - - <div class="table-col-general flex-item" data-ng-click="update(artifact)"> - - <span class="sprite table-arrow" data-tests-id="{{artifact.artifactDisplayName}}" data-ng-class="{'opened': artifact.selected || undefined==artifact.selected && updateInProgress}"></span> - {{artifact.artifactDisplayName}} - </div> - - <div class="table-col-general flex-item" data-tests-id="{{artifact.artifactType}}"> - {{artifact.artifactType}} - </div> - <div class="table-col-general flex-item" data-tests-id="{{artifact.timeout}}"> - {{artifact.timeout? artifact.timeout:''}} - </div> - - <div class="table-btn-col flex-item"> - <button class="table-edit-btn" data-tests-id="edit_{{artifact.artifactDisplayName}}" - data-ng-if="!isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)" data-ng-click="addOrUpdate(artifact)"></button> - <button class="table-delete-btn" data-tests-id="delete_{{artifact.artifactDisplayName}}" - data-ng-if="!isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)" data-ng-click="delete(artifact)"> </button> - <button class="table-download-btn" download-artifact data-tests-id="download_{{artifact.artifactDisplayName}}" - data-ng-if="artifact.artifactName" component="component" artifact="artifact"></button> - - - </div> - </div> - <div data-ng-repeat-end="" data-ng-if="artifact.selected || undefined==artifact.selected && updateInProgress" class="w-sdc-form item-opened"> - <!-- Artifact panel opened --> - - <!-- Description field --> - <div class="w-sdc-form-item" ng-form="descriptionForm" data-ng-class="{error:(descriptionForm.$dirty && descriptionForm.$invalid)}"> - <label class="i-sdc-env-form-label required">Description</label> - <textarea class="i-sdc-form-textarea {{$index}}" data-ng-class="{'view-mode': isViewMode()}" - data-ng-maxlength="256" - maxlength="256" - data-ng-required="true" - name="description" - data-ng-model="artifact.description" - data-ng-model-options="{ debounce: 200 }" - data-ng-pattern="getValidationPattern('string')" - ng-readonly="isViewMode()" - data-tests-id="description"> - </textarea> - - <div class="input-error" data-ng-show="descriptionForm.$dirty && descriptionForm.$invalid"> - <span ng-show="descriptionForm.$error.required" translate="ADD_ARTIFACT_ERROR_DESCRIPTION_REQUIRED"></span> - <span ng-show="descriptionForm.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> - <span ng-show="descriptionForm.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - </div> - - </div> - - <!-- Parameters in 2 columns --> - <div class="w-sdc-form-columns-wrapper" data-ng-if="artifact.heatParameters"> - <!-- Left column --> - <div class="w-sdc-form-column"> - <div class="i-sdc-form-item" ng-form="parameterForm" - data-ng-repeat="parameter in artifact.heatParameters.slice(0, artifact.heatParameters.length%2+artifact.heatParameters.length/2) track by $index"> - <label class="i-sdc-env-form-label" data-ng-class="{required:parameter.defaultValue}" tooltip-side="top" sdc-smart-tooltip>{{parameter.name +' (' + parameter.type + ')'}}</label> - <span class="parameter-description" tooltips tooltip-side="top" tooltip-content="{{parameter.description}}">?</span> - <input class="i-sdc-form-input" data-ng-class="{error:(parameterForm.currentValue.$invalid),'view-mode': isViewMode() }" - data-ng-model-options="{ debounce: 200 }" - data-ng-model="parameter.currentValue" - type="text" - name="currentValue" - data-ng-pattern="getValidationPattern(parameter.type, 'heat')" - data-ng-required="parameter.defaultValue" - data-ng-change="'json'==parameter.type && parameterForm.currentValue.$setValidity('pattern', validateJson(parameter.currentValue))" - data-ng-blur="!parameterForm.currentValue.$error.pattern && resetValue(parameter)" - /> - - <div class="input-error" data-ng-show="parameterForm.currentValue.$invalid"> - <span ng-show="parameterForm.currentValue.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> - </div> - </div> - </div> - - <!-- Right column --> - <div class="w-sdc-form-column"> - <div class="i-sdc-form-item" ng-form="parameterForm" data-ng-repeat="parameter in artifact.heatParameters.slice(artifact.heatParameters.length%2+artifact.heatParameters.length/2) track by $index"> - <label class="i-sdc-env-form-label" data-ng-class="{required:parameter.defaultValue}" tooltip-side="top" sdc-smart-tooltip>{{parameter.name +' (' + parameter.type + ')'}}</label> - <span class="parameter-description" tooltips tooltip-side="top" tooltip-content="{{parameter.description}}">?</span> - <input class="i-sdc-form-input" data-ng-class="{error:(parameterForm.currentValue.$invalid), 'view-mode': isViewMode()}" - data-ng-model-options="{ debounce: 200 }" - data-ng-model="parameter.currentValue" - type="text" - name="currentValue" - data-ng-pattern="getValidationPattern(parameter.type, 'heat')" - data-ng-required="parameter.defaultValue" - data-ng-change="'json'==parameter.type && parameterForm.currentValue.$setValidity('pattern', validateJson(parameter.currentValue))" - data-ng-blur="!parameterForm.currentValue.$error.pattern && resetValue(parameter)" - /> - - <div class="input-error" data-ng-show="parameterForm.currentValue.$invalid"> - <span ng-show="parameterForm.currentValue.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> - <span ng-show="parameterForm.currentValue.$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> - </div> - </div> - </div> - - - </div><!-- Close: Parameters in 2 columns --> - </div><!-- Close: Artifact panel opened --> - - <!-- Add artifacts buttons --> - <button class="add-button" data-ng-repeat="artifact in artifacts track by $index" - type="button" - data-ng-show="!artifact.esId" - data-ng-if="!viewModeOrCsarComponent()" - data-ng-class="{'disabled': isDisableMode() || component.isCsarComponent()}" - data-tests-id="{{artifact.artifactDisplayName}} deployment_artifact" - translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_HEAT" - translate-values="{'name': '{{artifact.artifactDisplayName}}'}" - data-ng-click="addOrUpdate(artifact)"></button> - - <!-- Top add button --> - <button class="add-button" type="button" data-ng-if="!isViewMode()" data-ng-class="{'disabled': isDisableMode()}" translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER" data-ng-click="addOrUpdate({})"></button> - </perfect-scrollbar> - </form> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment-view-model.ts deleted file mode 100644 index f8afc0b758..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment-view-model.ts +++ /dev/null @@ -1,127 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IDeploymentViewModelScope extends IWorkspaceViewModelScope { - - currentComponent: Models.Components.Component; - selectedComponent: Models.Components.Component; - isLoading: boolean; - sharingService:Sdc.Services.SharingService; - sdcMenu:Models.IAppMenu; - version:string; - isViewOnly:boolean; - tabs:Array<Models.Tab>; - - setComponent(component: Models.Components.Component); - isComponentInstanceSelected():boolean; - updateSelectedComponent(): void - openUpdateModal(); - deleteSelectedComponentInstance():void; - onBackgroundClick():void; - setSelectedInstance(componentInstance: Models.ComponentsInstances.ComponentInstance): void; - printScreen():void; - - } - - export class DeploymentViewModel { - - static '$inject' = [ - '$scope', - 'sdcMenu', - 'MenuHandler', - '$modal', - '$templateCache', - '$state', - 'Sdc.Services.SharingService', - '$filter', - 'Sdc.Services.CacheService', - 'ComponentFactory', - 'ChangeLifecycleStateHandler', - 'LeftPaletteLoaderService', - 'ModalsHandler' - ]; - - constructor(private $scope:IDeploymentViewModelScope, - private sdcMenu:Models.IAppMenu, - private MenuHandler: Utils.MenuHandler, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private $state:ng.ui.IStateService, - private sharingService:Services.SharingService, - private $filter:ng.IFilterService, - private cacheService:Services.CacheService, - private ComponentFactory: Utils.ComponentFactory, - private ChangeLifecycleStateHandler: Sdc.Utils.ChangeLifecycleStateHandler, - private LeftPaletteLoaderService: Services.Components.LeftPaletteLoaderService, - private ModalsHandler: Sdc.Utils.ModalsHandler) { - - this.$scope.setValidState(true); - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - - private initComponent = ():void => { - - this.$scope.currentComponent = this.$scope.component; - this.$scope.selectedComponent = this.$scope.currentComponent; - this.updateUuidMap(); - this.$scope.isViewOnly = this.$scope.isViewMode(); - }; - - - private updateUuidMap = ():void => { - /** - * In case user press F5, the page is refreshed and this.sharingService.currentEntity will be undefined, - * but after loadService or loadResource this.sharingService.currentEntity will be defined. - * Need to update the uuidMap with the new resource or service. - */ - this.sharingService.addUuidValue(this.$scope.currentComponent.uniqueId,this.$scope.currentComponent.uuid); - }; - - private initRightTabs = ()=> { - if(this.$scope.currentComponent.groups){ - - let hierarchyTab = new Models.Tab('/app/scripts/view-models/tabs/hierarchy/hierarchy-view.html', 'Sdc.ViewModels.HierarchyViewModel', 'hierarchy', this.$scope.currentComponent, 'hierarchy'); - this.$scope.tabs = Array<Models.Tab>(); - this.$scope.tabs.push(hierarchyTab) - } - - } - private initScope = ():void => { - - this.$scope.sharingService = this.sharingService; - this.$scope.sdcMenu = this.sdcMenu; - this.$scope.isLoading = false; - - this.$scope.version = this.cacheService.get('version'); - this.initComponent(); - - this.$scope.setComponent = (component: Models.Components.Product):void => { - this.$scope.currentComponent = component; - } - - this.initRightTabs(); - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts deleted file mode 100644 index c0d6aba915..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IDistributionStatusModalViewModelScope { - distribution:Models.Distribution; - status:string; - getStatusCount(distributionComponent:Array<Models.DistributionComponent>):any; - getUrlName(url:string):string; - modalDitributionStatus:ng.ui.bootstrap.IModalServiceInstance; - footerButtons: Array<any>; - close(): void; - } - - export class DistributionStatusModalViewModel { - - static '$inject' = ['$scope','$modalInstance', 'data']; - - constructor(private $scope:IDistributionStatusModalViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private data:any - ) { - this.initScope(); - } - - private initScope = ():void => { - this.$scope.distribution = this.data.distribution; - this.$scope.status = this.data.status; - this.$scope.modalDitributionStatus = this.$modalInstance; - - this.$scope.getUrlName = (url:string):string =>{ - let urlName:string = _.last(url.split('/')); - return urlName; - }; - - this.$scope.close = ():void => { - this.$modalInstance.close(); - }; - - this.$scope.footerButtons = [ - {'name': 'Close', 'css': 'blue', 'callback': this.$scope.close } - ]; - - }; - - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution-view-model.ts deleted file mode 100644 index 219585fc3d..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution-view-model.ts +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> - -module Sdc.ViewModels { - 'use strict'; - - interface IDistributionViewModel extends IWorkspaceViewModelScope{ - modalDistribution:ng.ui.bootstrap.IModalServiceInstance; - service: Models.Components.Service; - distributions : Array<Models.Distribution>; - showComponents(distribution:Models.Distribution): void; - markAsDeployed(distribution:Models.Distribution): void; - getStatusCount(distributionComponent:Array<Models.DistributionComponent>):any; - initDistributions():void; - getUrlName(url:string):string; - close(): void; - openDisributionStatusModal:Function; - } - - export class DistributionViewModel{ - - static '$inject' = [ - '$scope', - 'ModalsHandler' - - ]; - - constructor( - private $scope:IDistributionViewModel, - private ModalsHandler: Sdc.Utils.ModalsHandler - ){ - this.initScope(); - this.$scope.setValidState(true); - this.$scope.updateSelectedMenuItem(); - } - - private initScope = (): void => { - this.$scope.service = <Models.Components.Service>this.$scope.component; - - - // Open Distribution status modal - this.$scope.openDisributionStatusModal = (distribution: Models.Distribution,status:string):void => { - this.ModalsHandler.openDistributionStatusModal(distribution,status).then(()=>{ - // OK - }, ()=>{ - // ERROR - }); - }; - - - this.$scope.showComponents = (distribution: Models.Distribution): void => { - let onError = (response) => { - console.info('onError showComponents',response); - }; - let onSuccess = (distributionComponents: Array<Models.DistributionComponent>) => { - distribution.distributionComponents = distributionComponents; - distribution.statusCount = this.$scope.getStatusCount(distribution.distributionComponents); - // distribution.components = this.aggregateDistributionComponent(distributionComponents);; - }; - this.$scope.service.getDistributionsComponent(distribution.distributionID).then(onSuccess, onError); - }; - - this.$scope.getStatusCount = (distributionComponent:Array<Models.DistributionComponent>):any => { - return _.countBy(distributionComponent, 'status') - }; - - this.$scope.getUrlName = (url:string):string =>{ - let urlName:string = _.last(url.split('/')); - return urlName; - }; - - this.$scope.markAsDeployed = (distribution: Models.Distribution): void => { - let onError = (response) => { - console.info('onError markAsDeployed',response); - }; - let onSuccess = (result: any) => { - distribution.deployementStatus = 'Deployed'; - }; - this.$scope.service.markAsDeployed(distribution.distributionID).then(onSuccess, onError); - - }; - - this.$scope.initDistributions = (): void => { - let onError = (response) => { - console.info('onError initDistributions',response); - }; - let onSuccess = (distributions: Array<Models.Distribution>) => { - this.$scope.distributions = distributions; - }; - this.$scope.service.getDistributionsList().then(onSuccess, onError); - }; - - this.$scope.initDistributions(); - - }; - - - private aggregateDistributionComponent = (distributionComponents:Array<Models.DistributionComponent>):any =>{ - let aggregateDistributions:Utils.Dictionary<string,Utils.Dictionary<string,Array<Models.DistributionComponent>>> = new Utils.Dictionary<string,Utils.Dictionary<string,Array<Models.DistributionComponent>>>(); - let tempAggregateDistributions:any= _.groupBy(distributionComponents,'omfComponentID'); - let aa = new Utils.Dictionary<string,Array<Models.DistributionComponent>>(); - - let tempAggregate:any; - _.forEach(tempAggregateDistributions,(distributionComponents:Array<Models.DistributionComponent>,omfComponentID:string)=>{ - - let urls:any = _.groupBy(distributionComponents,'url'); - aggregateDistributions.setValue(omfComponentID,urls); - // aggregateDistributions[omfComponentID] = ; - - }); - console.log(aggregateDistributions); - return aggregateDistributions; - }; - - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/general/general-view-model.ts deleted file mode 100644 index f613648596..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general-view-model.ts +++ /dev/null @@ -1,379 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - import ISubCategory = Sdc.Models.ISubCategory; - import IMainCategory = Sdc.Models.IMainCategory; - import ResourceType = Sdc.Utils.Constants.ResourceType; - - export class Validation { - validationPattern:RegExp; - contactIdValidationPattern:RegExp; - tagValidationPattern:RegExp; - vendorValidationPattern:RegExp; - commentValidationPattern:RegExp; - projectCodeValidationPattern:RegExp; - } - - export interface IGeneralScope extends IWorkspaceViewModelScope { - validation:Validation; - editForm:ng.IFormController; - categories: Array<IMainCategory>; - latestCategoryId: string; - latestVendorName: string; - importedFileExtension:any; - isCreate:boolean; - isShowFileBrowse:boolean; - isShowOnboardingSelectionBrowse:boolean; - importedToscaBrowseFileText:string; - importCsarProgressKey:string; - browseFileLabel:string; - - - onToscaFileChange():void - validateField(field:any):boolean; - validateName(isInit:boolean): void; - calculateUnique(mainCategory:string, subCategory:string):string; // Build unique string from main and sub category - onVendorNameChange(oldVendorName:string): void; - convertCategoryStringToOneArray(category:string, subcategory:string):Array<Models.IMainCategory>; - onCategoryChange():void; - openOnBoardingModal():void; - initCategoreis():void; - } - - export class GeneralViewModel { - - static '$inject' = [ - '$scope', - 'Sdc.Services.CacheService', - 'ValidationPattern', - 'ContactIdValidationPattern', - 'TagValidationPattern', - 'VendorValidationPattern', - 'CommentValidationPattern', - 'ValidationUtils', - 'sdcConfig', - 'ProjectCodeValidationPattern', - '$state', - 'ModalsHandler', - 'EventListenerService', - 'Notification', - 'Sdc.Services.ProgressService', - '$interval', - '$filter', - '$timeout' - ]; - - constructor(private $scope:IGeneralScope, - private cacheService:Services.CacheService, - private ValidationPattern:RegExp, - private ContactIdValidationPattern:RegExp, - private TagValidationPattern:RegExp, - private VendorValidationPattern:RegExp, - private CommentValidationPattern:RegExp, - private ValidationUtils:Sdc.Utils.ValidationUtils, - private sdcConfig:Models.IAppConfigurtaion, - private ProjectCodeValidationPattern:RegExp, - private $state:ng.ui.IStateService, - private ModalsHandler: Sdc.Utils.ModalsHandler, - private EventListenerService:Services.EventListenerService, - private Notification:any, - private progressService:Sdc.Services.ProgressService, - protected $interval:any, - private $filter:ng.IFilterService, - private $timeout:ng.ITimeoutService - ){ - - this.registerToSuccessSaveEvent(); - this.initScopeValidation(); - this.initScopeMethods(); - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - private registerToSuccessSaveEvent = ():void => { - // Register to save success to show notification to user. - this.EventListenerService.registerObserverCallback(Utils.Constants.EVENTS.ON_WORKSPACE_SAVE_BUTTON_SUCCESS, this.showSuccessNotificationMessage); - - }; - - private showSuccessNotificationMessage = ():void => { - // In case we import CSAR. Notify user when import VF was finished. - this.Notification.success({ - message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_DESCRIPTION"), - title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE") - }); - - //set the form Pristine after save to reset the unsaved changes (whit for dom reload) - this.$timeout(()=> { - if(this.$scope.editForm) { - this.$scope.editForm.$setPristine(); - } - }, 500); - - }; - - - - private initScopeValidation = ():void => { - this.$scope.validation = new Validation(); - this.$scope.validation.validationPattern = this.ValidationPattern; - this.$scope.validation.contactIdValidationPattern = this.ContactIdValidationPattern; - this.$scope.validation.tagValidationPattern = this.TagValidationPattern; - this.$scope.validation.vendorValidationPattern = this.VendorValidationPattern; - this.$scope.validation.commentValidationPattern = this.CommentValidationPattern; - this.$scope.validation.projectCodeValidationPattern = this.ProjectCodeValidationPattern; - }; - - private initScope = ():void => { - - // Work around to change the csar version - if (this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { - (<Resource>this.$scope.component).csarVersion = this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG); - } - - this.$scope.importedToscaBrowseFileText = this.$scope.component.name + " (" + (<Resource>this.$scope.component).csarVersion + ")"; - this.$scope.importCsarProgressKey = "importCsarProgressKey"; - this.$scope.browseFileLabel = this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType===ResourceType.VF? "Upload file" : "Upload VFC"; - this.$scope.progressService = this.progressService; - - // Workaround to short vendor name to 25 chars - // onboarding send 27 chars, and the validation pattern is 25 chars. - if (this.$scope.component.vendorName){ - this.$scope.component.vendorName = this.$scope.component.vendorName.substr(0, 25); - } - - // Init UIModel - this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name); - - // Init categories - this.$scope.initCategoreis(); - - // Init the decision if to show file browse. - this.$scope.isShowFileBrowse = false; - if (this.$scope.component.isResource()){ - let resource:Sdc.Models.Components.Resource = <Sdc.Models.Components.Resource>this.$scope.component; - console.log(resource.name + ": " + resource.csarUUID); - if (resource.importedFile){ // Component has imported file. - this.$scope.isShowFileBrowse = true; - } - if (this.$scope.isEditMode() && resource.resourceType== ResourceType.VF && !resource.csarUUID){ - this.$scope.isShowFileBrowse = true; - } - }; - - // Init the decision if to show onboarding - this.$scope.isShowOnboardingSelectionBrowse = false; - if (this.$scope.component.isResource() && - this.$scope.isEditMode() && - (<Resource>this.$scope.component).resourceType== ResourceType.VF && - (<Resource>this.$scope.component).csarUUID) { - this.$scope.isShowOnboardingSelectionBrowse = true; - } - - //init file extensions based on the file that was imported. - if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile){ - let fileName:string = (<Resource>this.$scope.component).importedFile.filename; - let fileExtension:string = fileName.split(".").pop(); - if (this.sdcConfig.csarFileExtension.indexOf(fileExtension.toLowerCase()) !== -1){ - this.$scope.importedFileExtension = this.sdcConfig.csarFileExtension; - (<Resource>this.$scope.component).importedFile.filetype="csar"; - } else if (this.sdcConfig.toscaFileExtension.indexOf(fileExtension.toLowerCase()) !== -1){ - (<Resource>this.$scope.component).importedFile.filetype="yaml"; - this.$scope.importedFileExtension = this.sdcConfig.toscaFileExtension; - } - }else if(this.$scope.isEditMode()&& (<Resource>this.$scope.component).resourceType === ResourceType.VF){ - this.$scope.importedFileExtension = this.sdcConfig.csarFileExtension; - //(<Resource>this.$scope.component).importedFile.filetype="csar"; - } - - this.$scope.setValidState(true); - - this.$scope.calculateUnique = (mainCategory:string, subCategory:string):string => { - let uniqueId:string = mainCategory; - if (subCategory) { - uniqueId += "_#_" + subCategory; // Set the select category combobox to show the selected category. - } - return uniqueId; - }; - - //TODO remove this after handling contact in UI - if(this.$scope.component.isProduct() && this.$scope.isCreateMode()){ - (<Models.Components.Product>this.$scope.component).contacts = []; - (<Models.Components.Product>this.$scope.component).contacts.push(this.cacheService.get("user").userId); - }else if(this.$scope.isCreateMode()){ - this.$scope.component.contactId = this.cacheService.get("user").userId; - } - - }; - - // Convert category string MainCategory_#_SubCategory to Array with one item (like the server except) - private convertCategoryStringToOneArray = ():Array<Models.IMainCategory> => { - let tmp = this.$scope.component.selectedCategory.split("_#_"); - let mainCategory = tmp[0]; - let subCategory = tmp[1]; - - // Find the selected category and add the relevant sub category. - let selectedMainCategory:IMainCategory = <Models.IMainCategory>_.find(this.$scope.categories, function (item) { - return item["name"] === mainCategory; - - }); - - let mainCategoryClone = angular.copy(selectedMainCategory); - if (subCategory) { - let selectedSubcategory = <Models.ISubCategory>_.find(selectedMainCategory.subcategories, function (item) { - return item["name"] === subCategory; - }); - mainCategoryClone['subcategories'] = [angular.copy(selectedSubcategory)]; - } - let tmpSelected = <Models.IMainCategory> mainCategoryClone; - - let result:Array<Models.IMainCategory> = []; - result.push(tmpSelected); - - return result; - }; - - private updateComponentNameInBreadcrumbs = ():void => { - //update breadcrum after changing name - this.$scope.breadcrumbsModel[1].updateSelectedMenuItemText(this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name); - this.$scope.updateMenuComponentName(this.$scope.component.name); - }; - - private initScopeMethods = ():void => { - - this.$scope.initCategoreis = ():void => { - if (this.$scope.componentType === Utils.Constants.ComponentType.RESOURCE) { - this.$scope.categories = this.cacheService.get('resourceCategories'); - - } - if (this.$scope.componentType === Utils.Constants.ComponentType.SERVICE) { - this.$scope.categories = this.cacheService.get('serviceCategories'); - } - } - - this.$scope.validateField = (field:any):boolean => { - if (field && field.$dirty && field.$invalid) { - return true; - } - return false; - }; - - this.$scope.openOnBoardingModal=():void => { - let csarUUID = (<Resource>this.$scope.component).csarUUID; - this.ModalsHandler.openOnboadrdingModal('Update', csarUUID).then(()=>{ - // OK - this.$scope.uploadFileChangedInGeneralTab(); - }, ()=>{ - // ERROR - }); - }; - - this.$scope.validateName = (isInit:boolean):void => { - if (isInit === undefined) { - isInit = false; - } - - let name = this.$scope.component.name; - if (!name || name === "") { - if (this.$scope.editForm - && this.$scope.editForm["componentName"] - && this.$scope.editForm["componentName"].$error) { - - // Clear the error name already exists - this.$scope.editForm["componentName"].$setValidity('nameExist', true); - } - - return; - } - //????????????????????????? - let subtype:string = Utils.Constants.ComponentType.RESOURCE == this.$scope.componentType ? this.$scope.component.getComponentSubType() : undefined; - - let onFailed = (response) => { - //console.info('onFaild', response); - //this.$scope.isLoading = false; - }; - - let onSuccess = (validation:Models.IValidate) => { - this.$scope.editForm["componentName"].$setValidity('nameExist', validation.isValid); - if(validation.isValid){ - //update breadcrumb after changing name - this.updateComponentNameInBreadcrumbs(); - } - }; - - if (isInit) { - // When page is init after update - if (this.$scope.component.name !== this.$scope.originComponent.name) { - if (!(this.$scope.componentType===Utils.Constants.ComponentType.RESOURCE && (<Resource>this.$scope.component).csarUUID!==undefined) - ){ - this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); - } - } - } else { - // Validating on change (has debounce) - if (this.$scope.editForm - && this.$scope.editForm["componentName"] - && this.$scope.editForm["componentName"].$error - && !this.$scope.editForm["componentName"].$error.pattern - && this.$scope.component.name !== this.$scope.originComponent.name - ) { - if (!(this.$scope.componentType===Utils.Constants.ComponentType.RESOURCE && (<Resource>this.$scope.component).csarUUID!==undefined) - ){ - this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); - } - } else if (this.$scope.component.name === this.$scope.originComponent.name) { - // Clear the error - this.$scope.editForm["componentName"].$setValidity('nameExist', true); - } - } - }; - - this.$scope.$watchCollection('component.name', (newData:any):void => { - this.$scope.validateName(false); - }); - - // Notify the parent if this step valid or not. - this.$scope.$watch("editForm.$valid", (newVal, oldVal) => { - this.$scope.setValidState(newVal); - }); - - this.$scope.$watch("editForm.$dirty", (newVal, oldVal) => { - if (newVal!==oldVal) { - this.$state.current.data.unsavedChanges = newVal && !this.$scope.isCreateMode(); - } - }); - - this.$scope.onCategoryChange = ():void => { - this.$scope.component.categories = this.convertCategoryStringToOneArray(); - this.$scope.component.icon = Utils.Constants.DEFAULT_ICON; - }; - - this.$scope.onVendorNameChange = (oldVendorName:string):void => { - if (this.$scope.component.icon === oldVendorName) { - this.$scope.component.icon = Utils.Constants.DEFAULT_ICON; - } - }; - }; - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons-view-model.ts deleted file mode 100644 index a591641d0a..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons-view-model.ts +++ /dev/null @@ -1,131 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 4/4/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IIconsScope extends IWorkspaceViewModelScope { - icons : Array<string>; - iconSprite: string; - setComponentIcon(iconSrc:string): void; - } - - export class IconsViewModel { - - static '$inject' = [ - '$scope', - 'Sdc.Services.AvailableIconsService', - 'ComponentFactory', - '$state' - ]; - - constructor(private $scope:IIconsScope, - private availableIconsService:Services.AvailableIconsService, - private ComponentFactory:Sdc.Utils.ComponentFactory, - private $state:ng.ui.IStateService) { - - - this.initScope(); - this.initIcons(); - this.$scope.updateSelectedMenuItem(); - this.$scope.iconSprite = this.$scope.component.iconSprite; - - if (this.$scope.component.isResource()) { - this.initVendor(); - } - } - - private initialIcon:string = this.$scope.component.icon; - private initIcons = ():void => { - - // For subcategories that where created by admin, there is no icons - this.$scope.icons = new Array<string>(); - if (this.$scope.component.categories && this.$scope.component.categories.length > 0) { - - _.forEach(this.$scope.component.categories, (category:Models.IMainCategory):void => { - if (category.icons) { - this.$scope.icons = this.$scope.icons.concat(category.icons); - } - if (category.subcategories) { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory):void => { - if (subcategory.icons) { - this.$scope.icons = this.$scope.icons.concat(subcategory.icons); - } - }); - } - }); - } - - if (this.$scope.component.isResource()) { - let resourceType:string = this.$scope.component.getComponentSubType(); - if (resourceType === 'VL') { - this.$scope.icons = ['vl']; - } - if (resourceType === 'CP') { - this.$scope.icons = ['cp']; - } - } - - if (this.$scope.icons.length === 0) { - this.$scope.icons = this.availableIconsService.getIcons(this.$scope.component.componentType); - } - //we always add the defual icon to the list - this.$scope.icons.push('defaulticon'); - }; - - private initVendor = ():void => { - let vendors:Array<string> = this.availableIconsService.getIcons(this.$scope.component.componentType).slice(5, 19); - let vendorName = this.$scope.component.vendorName.toLowerCase(); - if ('at&t' === vendorName) { - vendorName = 'att'; - } - if ('nokia' === vendorName) { - vendorName = 'nokiasiemens'; - } - - let vendor:string = _.find(vendors, (vendor:string)=> { - return vendor.replace(/[_]/g, '').toLowerCase() === vendorName; - }); - - if (vendor && this.$scope.icons.indexOf(vendor) === -1) { - this.$scope.icons.push(vendor); - } - }; - - private initScope():void { - this.$scope.icons = []; - this.$scope.setValidState(true); - //if(this.$scope.component.icon === Utils.Constants.DEFAULT_ICON){ - // //this.$scope.setValidState(false); - //} - - this.$scope.setComponentIcon = (iconSrc:string):void => { - this.$state.current.data.unsavedChanges = !this.$scope.isViewMode() && (iconSrc != this.initialIcon); - this.$scope.component.icon = iconSrc; - // this.$scope.setValidState(true); - }; - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts deleted file mode 100644 index 3a048c1879..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import ArtifactModel = Sdc.Models.ArtifactModel; - - export interface IInformationArtifactsScope extends IWorkspaceViewModelScope { - artifacts: Array<Models.ArtifactModel>; - tableHeadersList: Array<any>; - artifactType: string; - isResourceInstance:boolean; - downloadFile:Models.IFileDownload; - isLoading:boolean; - sortBy:string; - reverse:boolean; - - getTitle(): string; - addOrUpdate(artifact:Models.ArtifactModel): void; - delete(artifact:Models.ArtifactModel): void; - download(artifact:Models.ArtifactModel): void; - clickArtifactName(artifact:any):void; - openEditEnvParametersModal(artifactResource:Models.ArtifactModel):void; - sort(sortBy:string): void; - showNoArtifactMessage():boolean; - } - - export class InformationArtifactsViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'Sdc.Services.SharingService', - '$state', - 'sdcConfig', - 'ModalsHandler' - ]; - - constructor(private $scope:IInformationArtifactsScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private sharingService:Sdc.Services.SharingService, - private $state:any, - private sdcConfig:Models.IAppConfigurtaion, - private ModalsHandler:Utils.ModalsHandler) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - - private getMappedObjects():any { - return { - normal: this.$scope.component.artifacts - }; - } - - private initScope = ():void => { - let self = this; - this.$scope.isLoading = false; - this.$scope.sortBy = 'artifactDisplayName'; - this.$scope.reverse = false; - this.$scope.setValidState(true); - this.$scope.artifactType = 'normal'; - this.$scope.getTitle = ():string => { - return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts'; - - }; - - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'artifactDisplayName'}, - {title: 'Type', property: 'artifactType'} - ]; - - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - - this.$scope.addOrUpdate = (artifact:Models.ArtifactModel):void => { - artifact.artifactGroupType = 'INFORMATIONAL'; - this.ModalsHandler.openWizardArtifactModal(artifact, this.$scope.component).then(() => { - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - }); - }; - - this.$scope.showNoArtifactMessage = ():boolean => { - let artifacts:any = []; - artifacts = _.filter(this.$scope.artifacts, (artifact:Models.ArtifactModel)=> { - return artifact.esId; - }); - - if (artifacts.length === 0) { - return true; - } - return false; - }; - - this.$scope.delete = (artifact:Models.ArtifactModel):void => { - - let onOk = ():void => { - this.$scope.isLoading = true; - let onSuccess = ():void => { - this.$scope.isLoading = false; - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); - }; - - let onFailed = (error:any):void => { - console.log('Delete artifact returned error:', error); - this.$scope.isLoading = false; - }; - - this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); - }; - - let title:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - - this.$scope.clickArtifactName = (artifact:any) => { - if (!artifact.esId) { - this.$scope.addOrUpdate(artifact); - } - - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts deleted file mode 100644 index 2dc1b1d9ff..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts +++ /dev/null @@ -1,145 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import Dictionary = Sdc.Utils.Dictionary; - import InputModel = Sdc.Models.InputModel; - - export interface IInputsViewModelScope extends IWorkspaceViewModelScope { - InstanceInputsProperties:Models.InstanceInputsPropertiesMapData; //this is tha map object that hold the selected inputs and the inputs we already used - vfInstancesList: Array<Models.ComponentsInstances.ComponentInstance>; - component:Models.Components.Resource; - - onArrowPressed():void; - getInputPropertiesForInstance(instanceId:string, instance:Models.ComponentsInstances.ComponentInstance): ng.IPromise<boolean> ; - loadInputPropertiesForInstance(instanceId:string, input:Models.InputModel): ng.IPromise<boolean> ; - loadInputInputs(input:Models.InputModel): ng.IPromise<boolean>; - } - - export class ResourceInputsViewModel { - - static '$inject' = [ - '$scope', - '$q' - ]; - - constructor(private $scope:IInputsViewModelScope, private $q: ng.IQService) { - this.initScope(); - } - - private initScope = (): void => { - - this.$scope.InstanceInputsProperties = new Models.InstanceInputsPropertiesMapData(); - this.$scope.vfInstancesList = this.$scope.component.componentInstances; - - // Need to cast all inputs to InputModel for the search to work - let tmpInputs:Array<Models.InputModel> = new Array<Models.InputModel>(); - _.each(this.$scope.component.inputs, (input):void => { - tmpInputs.push(new Models.InputModel(input)); - }); - this.$scope.component.inputs = tmpInputs; - // This function is not supported for resource - //this.$scope.component.getComponentInputs(); - - /* - * When clicking on instance input in the left or right table, this function will load all properties of the selected input - */ - this.$scope.getInputPropertiesForInstance = (instanceId:string, instance:Models.ComponentsInstances.ComponentInstance): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - instance.properties = this.$scope.component.componentInstancesProperties[instanceId]; - deferred.resolve(true); - return deferred.promise; - }; - - /* - * When clicking on input in the right table, this function will load all inputs of the selected input - */ - this.$scope.loadInputInputs = (input:Models.InputModel): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - - let onSuccess = () => { deferred.resolve(true); }; - let onError = () => { deferred.resolve(false); }; - - if(!input.inputs) { - this.$scope.component.getResourceInputInputs(input.uniqueId).then(onSuccess, onError); - } else { - deferred.resolve(true); - } - return deferred.promise; - }; - - /* - * When clicking on instance input in the left or right table, this function will load all properties of the selected input - */ - this.$scope.loadInputPropertiesForInstance = (instanceId:string, input:Models.InputModel): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - - let onSuccess = (properties:Array<Models.PropertyModel>) => { - input.properties = properties; - deferred.resolve(true); - }; - - let onError = () => { - deferred.resolve(false) - }; - - if(!input.properties) { - this.$scope.component.getComponentInstanceInputProperties(instanceId, input.uniqueId).then(onSuccess, onError); - } else { - deferred.resolve(true); - } - return deferred.promise; - }; - - /* - * When pressing the arrow, we create service inputs from the inputs selected - */ - this.$scope.onArrowPressed = ():void => { - let onSuccess = (inputsCreated: Array<Models.InputModel>) => { - - //disabled all the inputs in the left table - _.forEach(this.$scope.InstanceInputsProperties, (properties:Array<Models.PropertyModel>) => { - _.forEach(properties, (property:Models.PropertyModel) => { - property.isAlreadySelected = true; - }); - }); - - // Adding color to the new inputs (right table) - _.forEach(inputsCreated, (input) => { - input.isNew = true; - }); - - // Removing color to the new inputs (right table) - setTimeout(() => { - _.forEach(inputsCreated, (input) => { - input.isNew = false; - }); - this.$scope.$apply(); - }, 3000); - }; - - this.$scope.component.createInputsFormInstances(this.$scope.InstanceInputsProperties).then(onSuccess); - }; - - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html b/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html deleted file mode 100644 index 7cdf5a2fa4..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html +++ /dev/null @@ -1,136 +0,0 @@ -<div class="workspace-inputs"> - <div class="table-container-flex"> - <div class="w-sdc-inputs-search pull-left hideme"> - <input type="text" class="w-sdc-inputs-search-input" placeholder="Search"/> - <div class="search-icon-container"> - <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> - </div> - </div> - <div class="table"> - <div class="table-header">VFC instances inputs</div> - <div class="body"> - <div class="table-loader" ng-class="{'tlv-loader large loader': isLoading}"></div> - <perfect-scrollbar scroll-y-margin-offset="0" class="scrollbar-container"> - - <expand-collapse expanded-selector=".vf-instance-list.{{$index}}" - class="expand-collapse-table-row" - load-data-function="getInputPropertiesForInstance(instance.uniqueId, instance)" - is-close-on-init="true" - data-ng-repeat-start="instance in vfInstancesList track by $index"> - <div class="flex-container data-row"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="table-col-general flex-item text"> - <span class="title-text">{{instance.name}}</span> - </div> - </div> - - </expand-collapse> - - <div data-ng-repeat-end="" class="vf-instance-list {{$index}}"> - - <div class="empty-row" ng-if="instance.properties.length===0">No properties to display</div> - - <div ng-repeat="property in instance.properties track by $index"> - <div class="property-row flex-container"> - <div class="flex-item text property-name-container"> - <span class="title-blue-text property-name-text">{{property.name}}</span> - <span class="text instance-name-text">{{property.name}}</span> - </div> - <div class="type-schema-container"> - <div class="text"> - <span>{{property.type}}</span> - </div> - </div> - <div class="type-schema-container"> - <div class="text"> - <span>{{property.schema.property.type}} </span> - </div> - </div> - <!--<sdc-checkbox - class="type-schema-container input-check-box" - disabled ="property.isAlreadySelected" - sdc-checklist-model="InstanceInputsProperties[instance.uniqueId]" - sdc-checklist-value="property" - data-ng-click="$event.stopPropagation()"></sdc-checkbox>--> - </div> - </div> - - </div> - - </perfect-scrollbar> - </div> - </div> - </div> - - <div class="inputs-button-container pull-left"> - <!--<div ng-click="onArrowPressed()" class="right-arrow-btn"></div>--> - </div> - - <div class="table-container-flex"> - <div class="w-sdc-inputs-search pull-left"> - <input type="text" class="w-sdc-inputs-search-input" data-ng-model="search.filterTerm" placeholder="Search" data-ng-model-options="{debounce: 200}"/> - <div class="search-icon-container"> - <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> - </div> - </div> - <div class="table"> - <div class="body"> - <div class="table-header">Resource instance inputs</div> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - <expand-collapse expanded-selector=".resource-inputs.{{$index}}" - class="expand-collapse-table-row" - load-data-function="loadInputPropertiesForInstance(resourceInput.uniqueId, resourceInput)" - is-close-on-init="true" - data-ng-repeat-start="resourceInput in component.inputs | filter:search track by $index "> - <div class="input-row service-input-row"> - <div class="title-text">{{resourceInput.name}}</div> - <div class="flex-container" ng-class="resourceInput.isNew ? 'new-input': 'service-input-row'"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="flex-item"> - <div> - <span class="title-text">Description:</span> - <span>{{resourceInput.description}}</span> - </div> - </div> - <div class="flex-item "> - <div class="text"> - <span class="title-text">VF Instance:</span> - <span>{{resourceInput.name}}</span> - </div> - <div class="text"> - <span class="title-text">Type:</span> - <span>{{resourceInput.type}} </span> - </div> - </div> - </div> - </div> - </expand-collapse> - - <div data-ng-repeat-end="" class="input-inputs-list resource-inputs {{$index}}"> - <div class="empty-row" ng-if="resourceInput.properties.length===0">No properties to display</div> - <div ng-repeat="property in resourceInput.properties track by $index"> - <div class="property-row flex-container"> - <div class="flex-item text property-name-container"> - <span - class="title-blue-text property-name-text">{{property.name}}</span> - <span class="text instance-name-text">{{property.name}}</span> - </div> - <div class="type-schema-container"> - <div class="text"> - <span>{{property.type}}</span> - </div> - </div> - <div class="type-schema-container"> - <div class="text"> - <span>{{property.schema.property.type}} </span> - </div> - </div> - </div> - </div> - </div> - - </perfect-scrollbar> - </div> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts deleted file mode 100644 index 6c8391720a..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts +++ /dev/null @@ -1,246 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import IAngularEvent = angular.IAngularEvent; - import ComponentInstance = Sdc.Models.ComponentsInstances.ComponentInstance; - - - interface IServiceInputsViewModelScope extends IWorkspaceViewModelScope { - - vfInstancesList: Array<ComponentInstance>; - selectedInputs:Array<Models.InputModel>; - instanceInputsMap:Models.InstancesInputsMapData; //this is tha map object that hold the selected inputs and the inputs we already used - component:Models.Components.Service; - sdcMenu:Models.IAppMenu; - - onArrowPressed():void; - loadComponentInputs(): void; - loadInstanceInputs(instance:ComponentInstance): ng.IPromise<boolean> ; - loadInputPropertiesForInstance(instanceId:string, input:Models.InputModel): ng.IPromise<boolean> ; - loadInputInputs(input:Models.InputModel): ng.IPromise<boolean>; - deleteInput(input:Models.InputModel):void - } - - export class ServiceInputsViewModel { - - static '$inject' = [ - '$scope', - '$q', - 'ModalsHandler' - ]; - - constructor(private $scope:IServiceInputsViewModelScope, - private $q: ng.IQService, - private ModalsHandler: Sdc.Utils.ModalsHandler) { - this.initScope(); - } - - /* - * When loading the screen again, we need to disabled the inputs that already created on the service, - * we do that by comparing the service input name, to the instance name + '_' + the resource instance input name. - */ - private disableEnableSelectedInputs = (instance: ComponentInstance): void => { - - let alreadySelectedInput = new Array<Models.InputModel>(); - _.forEach(instance.inputs, (input:Models.InputModel) => { - let expectedServiceInputName = instance.normalizedName + '_' + input.name; - let inputAlreadyInService: Models.InputModel = _.find(this.$scope.component.inputs, (serviceInput: Models.InputModel) => { - return serviceInput.name === expectedServiceInputName; - }); - if(inputAlreadyInService) { - input.isAlreadySelected = true; - alreadySelectedInput.push(input); - } else { - input.isAlreadySelected = false; - } - }); - this.$scope.instanceInputsMap[instance.uniqueId] = alreadySelectedInput; - }; - - private initScope = (): void => { - - this.$scope.instanceInputsMap = new Models.InstancesInputsMapData(); - this.$scope.isLoading = true; - this.$scope.selectedInputs = new Array<Models.InputModel>(); - - // Why do we need this? we call this later. - //this.$scope.component.getComponentInputs(); - - let onSuccess = (componentInstances:Array<ComponentInstance>) => { - console.log("component instances loaded: ", componentInstances); - this.$scope.vfInstancesList = componentInstances; - this.$scope.isLoading = false; - }; - - //This function will get al component instance for the left table - in future the instances will be filter according to search text - this.$scope.component.getComponentInstancesFilteredByInputsAndProperties().then(onSuccess); - - // This function will get the service inputs for the right table - this.$scope.component.getComponentInputs(); - - - /* - * When clicking on instance in the left table, this function will load all instance inputs - */ - this.$scope.loadInstanceInputs = (instance:ComponentInstance): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - - let onSuccess = (inputs:Array<Models.InputModel>) => { - instance.inputs = inputs; - this.disableEnableSelectedInputs(instance); - deferred.resolve(true); - }; - - let onError = () => { - deferred.resolve(false); - }; - - if(!instance.inputs) { - this.$scope.component.getComponentInstanceInputs(instance.uniqueId, instance.componentUid).then(onSuccess, onError); - this.disableEnableSelectedInputs(instance); - } else { - deferred.resolve(true); - } - return deferred.promise; - }; - - /* - * When clicking on instance input in the left or right table, this function will load all properties of the selected input - */ - this.$scope.loadInputPropertiesForInstance = (instanceId:string, input:Models.InputModel): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - - let onSuccess = (properties:Array<Models.PropertyModel>) => { - input.properties = properties; - deferred.resolve(true); - }; - - let onError = () => { - deferred.resolve(false) - }; - - if(!input.properties) { - this.$scope.component.getComponentInstanceInputProperties(instanceId, input.uniqueId).then(onSuccess, onError); - } else { - deferred.resolve(true); - } - return deferred.promise; - }; - - /* - * When clicking on input in the right table, this function will load all inputs of the selected input - */ - this.$scope.loadInputInputs = (input:Models.InputModel): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - - let onSuccess = () => { deferred.resolve(true); }; - let onError = () => { deferred.resolve(false); }; - - if(!input.inputs) { // Caching, if exists do not get it. - this.$scope.component.getServiceInputInputs(input.uniqueId).then(onSuccess, onError); - } else { - deferred.resolve(true); - } - return deferred.promise; - }; - - /* - * When pressing the arrow, we create service inputs from the inputs selected - */ - this.$scope.onArrowPressed = ():void => { - let onSuccess = (inputsCreated: Array<Models.InputModel>) => { - - //disabled all the inputs in the left table - _.forEach(this.$scope.instanceInputsMap, (inputs:Array<Models.InputModel>, instanceId:string) => { - _.forEach(inputs, (input:Models.InputModel) => { - input.isAlreadySelected = true; - }); - }); - - this.addColorToItems(inputsCreated); - }; - - this.$scope.component.createInputsFormInstances(this.$scope.instanceInputsMap).then(onSuccess); - }; - - this.$scope.deleteInput = (input: Models.InputModel):void => { - - var onDelete = ():void => { - var onSuccess = (deletedInput: Models.InputModel, componentInstanceId:string):void => { - // Remove from component.inputs the deleted input (service inputs) - var remainingServiceInputs:Array<Models.InputModel> = _.filter(this.$scope.component.inputs, (input:Models.InputModel):boolean => { - return input.uniqueId !== deletedInput.uniqueId; - }); - this.$scope.component.inputs = remainingServiceInputs; - - // Find the instance that contains the deleted input, and set disable|enable the deleted input - var deletedInputComponentInstance:ComponentInstance = _.find(this.$scope.vfInstancesList, (instanceWithChildToDelete:ComponentInstance):boolean => { - return instanceWithChildToDelete.uniqueId === componentInstanceId; - }); - this.disableEnableSelectedInputs(deletedInputComponentInstance); - }; - - var onFailed = (error:any) : void => { - console.log("Error deleting input"); - }; - - this.addColorToItems([input]); - - // Get service inputs of input (so after delete we will know the component instance) - this.$scope.loadInputInputs(input).then((result:boolean):void=>{ - if (result && input.inputs.length>0) { - var componentInstanceId:string = input.inputs[0].componentInstanceId; - this.$scope.component.deleteServiceInput(input.uniqueId).then((deletedInput: Models.InputModel):void => { - onSuccess(deletedInput, componentInstanceId); - }, onFailed); - } - }); - }; - - // Get confirmation modal text from menu.json - var state = "deleteInput"; - var title:string = this.$scope.sdcMenu.alertMessages[state].title; - var message:string = this.$scope.sdcMenu.alertMessages[state].message.format([input.name]); - - // Open confirmation modal - this.ModalsHandler.openAlertModal(title, message).then(onDelete); - } - }; - - private addColorToItems = (inputsCreated:Array<Models.InputModel>):void => { - - // Adding color to the new inputs (right table) - _.forEach(inputsCreated, (input) => { - input.isNew = true; - }); - - // Removing color to the new inputs (right table) - setTimeout(() => { - _.forEach(inputsCreated, (input) => { - input.isNew = false; - }); - this.$scope.$apply(); - }, 3000); - }; - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html b/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html deleted file mode 100644 index bf15a70322..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html +++ /dev/null @@ -1,205 +0,0 @@ -<div class="workspace-inputs"> - <div class="table-container-flex"> - <div class="w-sdc-inputs-search pull-left hideme"> - <input type="text" class="w-sdc-inputs-search-input" placeholder="Search"/> - <div class="search-icon-container"> - <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> - </div> - </div> - <div class="table"> - <div class="table-header">Resource instance inputs</div> - <div class="body"> - <div class="table-loader" ng-class="{'tlv-loader large loader': isLoading}"></div> - <perfect-scrollbar scroll-y-margin-offset="0" class="scrollbar-container"> - - <expand-collapse expanded-selector=".vf-instance-list.{{$index}}" - class="expand-collapse-table-row" - load-data-function="loadInstanceInputs(instance)" - is-close-on-init="true" - data-ng-repeat-start="instance in vfInstancesList track by $index"> - <div class="flex-container data-row"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="table-col-general flex-item text" data-tests-id="inputs-vf-instance-{{$index}}"> - <span class="title-text">{{instance.name}}</span> - </div> - </div> - - </expand-collapse> - - <div data-ng-repeat-end="" class="vf-instance-list {{$index}}"> - - <expand-collapse expanded-selector=".input-list.{{$parent.$index}}-{{$index}}" - class="expand-collapse-table-row" - load-data-function="loadInputPropertiesForInstance(instance.uniqueId, input)" - is-close-on-init="true" - data-ng-repeat-start="input in instance.inputs track by $index"> - <div class="input-row" ng-class="{'selected': selectedInput.uniqueId === input.uniqueId}"> - <div class="title-text">{{input.name}}</div> - <div class="flex-container"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="flex-item"> - - <div> - <span class="title-text">Description:</span> - <span tooltips tooltip-content="{{input.description}}">{{input.description}}</span> - </div> - </div> - <div class="flex-item "> - <div class="text"> - <span class="title-text">VF Instance:</span> - <span tooltips tooltip-content="{{instance.name}}">{{instance.name}}</span> - </div> - <div class="text"> - <span class="title-text">Type:</span> - <span tooltips tooltip-content="{{input.type}}">{{input.type}} </span> - </div> - </div> - <sdc-checkbox - class="input-check-box" - disabled ="input.isAlreadySelected || isViewMode()" - sdc-checklist-model="instanceInputsMap[instance.uniqueId]" - sdc-checklist-value="input" - data-tests-id="inputs-checkbox-{{$index}}" - data-ng-click=" $event.stopPropagation()"></sdc-checkbox> - </div> - </div> - - - </expand-collapse> - - <div data-ng-repeat-end="" class="input-list {{$parent.$index}}-{{$index}}"> - <div class="empty-row" ng-if="input.properties.length===0">No properties to display</div> - - <div ng-repeat="property in input.properties track by $index"> - <div class="property-row flex-container"> - <div class="flex-item text property-name-container"> - <span class="title-blue-text property-name-text" tooltips tooltip-content="{{property.name}}">{{property.name}}</span> - <span class="text instance-name-text" tooltips tooltip-content="{{property.name}}">{{property.name}}</span> - </div> - <div class="type-schema-container"> - <div class="text"> - <span tooltips tooltip-content="{{property.type}}">{{property.type}}</span> - </div> - </div> - <div class="type-schema-container"> - <div class="text"> - <span tooltips tooltip-content="{{property.schema.property.type}}">{{property.schema.property.type}} </span> - </div> - </div> - </div> - </div> - </div> - </div> - </perfect-scrollbar> - </div> - </div> - </div> - - <div class="inputs-button-container pull-left"> - <div ng-click="onArrowPressed()" class="right-arrow-btn" data-tests-id="add-inputs-to-service-button"></div> - </div> - - <div class="table-container-flex"> - <div class="w-sdc-inputs-search pull-left"> - <input type="text" class="w-sdc-inputs-search-input" data-ng-model="search.filterTerm" placeholder="Search" data-ng-model-options="{debounce: 200}"/> - <div class="search-icon-container"> - <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> - </div> - </div> - <div class="table"> - <div class="body"> - <div class="table-header">Service Inputs</div> - <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> - <expand-collapse expanded-selector=".service-inputs.{{$index}}" - class="expand-collapse-table-row" - load-data-function="loadInputInputs(serviceInput)" - is-close-on-init="true" - data-ng-repeat-start="serviceInput in component.inputs | filter:search track by $index "> - <div class="input-row service-input-row " data-tests-id="service-input-{{$index}}" ng-class="serviceInput.isNew ? 'new-input': ''"> - <div class="title-text">{{serviceInput.name}}</div> - <div class="flex-container"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="flex-item"> - <div> - <span class="title-text">Description:</span> - <span tooltips tooltip-content="{{serviceInput.description}}">{{serviceInput.description}}</span> - </div> - </div> - <div class="flex-item "> - <div class="text"> - <span class="title-text">VF Instance:</span> - <span tooltips tooltip-content="{{serviceInput.name}}">{{serviceInput.name}}</span> - </div> - <div class="text"> - <span class="title-text">Type:</span> - <span tooltips tooltip-content="{{serviceInput.type}}">{{serviceInput.type}} </span> - </div> - </div> - <div class="delete"> - <span class="sprite-new delete-icon remove-input-icon" - data-ng-class="{'disabled': isViewMode()}" - data-ng-click="deleteInput(serviceInput); $event.stopPropagation();" - data-tests-id="delete-input-{{$index}}"></span> - </div> - </div> - </div> - </expand-collapse> - - <div data-ng-repeat-end="" class="service-inputs {{$index}}"> - <expand-collapse expanded-selector=".input-inputs-list.{{$parent.$index}}-{{$index}}" - class="expand-collapse-table-row" - load-data-function="loadInputPropertiesForInstance(input.componentInstanceId, input)" - is-close-on-init="true" - data-ng-repeat-start="input in serviceInput.inputs track by $index"> - <div class="input-row"> - <div class="title-text">{{input.name}}</div> - <div class="flex-container"> - <div class="expand-collapse-inputs-table-icon"></div> - <div class="flex-item"> - <div> - <span class="title-text">Description:</span> - <span tooltips tooltip-content="{{input.description}}">{{input.description}}</span> - </div> - </div> - <div class="flex-item "> - <div class="text"> - <span class="title-text">VF Instance:</span> - <span tooltips tooltip-content="{{instance.componentInstanceName}}">{{instance.componentInstanceName}}</span> - </div> - <div class="text"> - <span class="title-text">Type:</span> - <span tooltips tooltip-content="{{input.type}}">{{input.type}} </span> - </div> - </div> - </div> - </div> - </expand-collapse> - - <div data-ng-repeat-end="" class="input-inputs-list {{$parent.$index}}-{{$index}}"> - <div class="empty-row" ng-if="input.properties.length===0">No properties to display</div> - <div ng-repeat="property in input.properties track by $index"> - <div class="property-row flex-container"> - <div class="flex-item text property-name-container"> - <span - class="title-blue-text property-name-text" tooltips tooltips-content="{{property.name}}">{{property.name}}</span> - <span class="text instance-name-text" tooltips tooltips-content="{{property.name}}">{{property.name}}</span> - </div> - <div class="type-schema-container"> - <div class="text"> - <span tooltips tooltips-content="{{property.type}}">{{property.type}}</span> - </div> - </div> - <div class="type-schema-container"> - <div class="text"> - <span tooltips tooltips-content="{{property.schema.property.type}}">{{property.schema.property.type}} </span> - </div> - </div> - </div> - </div> - </div> - </div> - </perfect-scrollbar> - </div> - </div> - </div> -</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts deleted file mode 100644 index 064f1c5896..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts +++ /dev/null @@ -1,80 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface INetworkCallFlowViewModelScope extends IWorkspaceViewModelScope { - vendorMessageModel:VendorModel; - } - - export class participant { - name:string; - id:string; - - constructor(instance:Models.ComponentsInstances.ComponentInstance){ - this.name = instance.name; - this.id = instance.uniqueId; - } - } - - - export class NetworkCallFlowViewModel { - - static '$inject' = [ - '$scope', - 'uuid4' - ]; - - constructor(private $scope:INetworkCallFlowViewModelScope, - private uuid4:any) { - - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - private getVFParticipantsFromInstances(instances:Array<Models.ComponentsInstances.ComponentInstance>):Array<participant> { - let participants = []; - _.forEach(instances,(instance)=> { - if(Utils.Constants.ResourceType.VF == instance.originType){ - participants.push(new participant(instance)); - } - }); - return participants; - } - - - private initScope():void { - this.$scope.vendorMessageModel = new VendorModel( - this.$scope.component.artifacts.filteredByType(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW), - this.$scope.component.uniqueId, - this.$scope.isViewMode(), - this.$scope.user.userId, - this.uuid4.generate(), - Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW, - this.getVFParticipantsFromInstances(this.$scope.component.componentInstances) - ); - - this.$scope.thirdParty = true; - this.$scope.setValidState(true); - } - - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts deleted file mode 100644 index faf77a5215..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 4/7/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - export interface IProductHierarchyScope extends IWorkspaceViewModelScope { - - categoriesOptions: Array<Models.IMainCategory>; - product:Models.Components.Product; - isLoading:boolean; - showDropDown:boolean; - - onInputTextClicked():void; - onGroupSelected(category: Models.IMainCategory, subcategory: Models.ISubCategory, group: Models.IGroup):void; - clickOutside():void; - deleteGroup(uniqueId:string):void; - } - - export class ProductHierarchyViewModel { - - static '$inject' = [ - '$scope', - 'Sdc.Services.CacheService', - 'ComponentFactory', - '$state' - ]; - - constructor(private $scope:IProductHierarchyScope, - private cacheService:Sdc.Services.CacheService, - private ComponentFactory: Sdc.Utils.ComponentFactory, - private $state:ng.ui.IStateService) { - - - this.$scope.product = <Models.Components.Product>this.$scope.getComponent(); - this.$scope.setValidState(true); - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - private initCategories = () => { - this.$scope.categoriesOptions = angular.copy(this.cacheService.get('productCategories')); - let selectedGroup:Array<Models.IGroup> = []; - _.forEach(this.$scope.product.categories, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - selectedGroup = selectedGroup.concat(subcategory.groupings); - }); - }); - _.forEach(this.$scope.categoriesOptions, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - _.forEach(subcategory.groupings, (group:Models.ISubCategory) => { - let componentGroup:Models.IGroup = _.find(selectedGroup, (componentGroupObj) => { - return componentGroupObj.uniqueId == group.uniqueId; - }); - if(componentGroup){ - group.isDisabled = true; - } - }); - }); - }); - }; - - private setFormValidation = ():void => { - //if(!this.$scope.product.categories || this.$scope.product.categories.length === 0){ - // this.$scope.setValidState(false); - //} - //else{ - this.$scope.setValidState(true); - // } - - }; - - private initScope = ():void => { - this.$scope.isLoading= false; - this.$scope.showDropDown =false; - this.initCategories(); - this.setFormValidation(); - - this.$scope.onGroupSelected = (category: Models.IMainCategory, subcategory: Models.ISubCategory, group: Models.IGroup):void => { - this.$scope.product.addGroup(category, subcategory, group); - this.$state.current.data.unsavedChanges = !this.$scope.isViewMode(); - group.isDisabled = true; - this.$scope.showDropDown = false; - this.setFormValidation(); - }; - - this.$scope.onInputTextClicked = ():void => {//just edit the component in place, no pop up nor server update ? - this.$scope.showDropDown = !this.$scope.showDropDown; - }; - - this.$scope.clickOutside = (): any => { - this.$scope.showDropDown = false; - }; - - this.$scope.deleteGroup = (uniqueId:string) : void => { - //delete group from component - this.$scope.product.deleteGroup(uniqueId); - this.$state.current.data.unsavedChanges = !this.$scope.isViewMode(); - this.setFormValidation(); - //enabled group - _.forEach(this.$scope.categoriesOptions, (category: Models.IMainCategory) => { - _.forEach(category.subcategories, (subcategory:Models.ISubCategory) => { - let groupObj:Models.IGroup = _.find (subcategory.groupings, (group) => { - return group.uniqueId === uniqueId; - }); - if(groupObj){ - groupObj.isDisabled = false; - } - }); - }); - } - }; - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties-view-model.ts deleted file mode 100644 index 9b824bfca9..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties-view-model.ts +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - - interface IPropertiesViewModelScope extends IWorkspaceViewModelScope { - tableHeadersList: Array<any>; - reverse: boolean; - sortBy:string; - filteredProperties:any; - - addOrUpdateProperty(property?:Models.PropertyModel): void; - delete(property:Models.PropertyModel): void; - sort(sortBy:string): void; - } - - export class PropertiesViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ModalsHandler' - ]; - - - constructor(private $scope:IPropertiesViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService, - private ModalsHandler:Utils.ModalsHandler) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - - private openEditPropertyModal = (property:Models.PropertyModel):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/property-form/property-form-view.html'), - controller: 'Sdc.ViewModels.PropertyFormViewModel', - size: 'sdc-l', - backdrop: 'static', - keyboard: false, - resolve: { - property: ():Models.PropertyModel => { - return property; - }, - component: ():Models.Components.Component => { - return <Models.Components.Component> this.$scope.component; - }, - filteredProperties: ():Array<Models.PropertyModel> => { - return this.$scope.filteredProperties.properties; - } - } - }; - this.$modal.open(modalOptions); - }; - - private initScope = ():void => { - - //let self = this; - this.$scope.filteredProperties={properties:[]}; - this.$scope.sortBy = 'name'; - this.$scope.reverse = false; - this.$scope.setValidState(true); - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Type', property: 'type'}, - {title: 'Schema', property: 'schema.property.type'}, - {title: 'Description', property: 'description'}, - ]; - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - - this.$scope.addOrUpdateProperty = (property?:Models.PropertyModel):void => { - this.openEditPropertyModal(property ? property : new Models.PropertyModel()); - }; - - this.$scope.delete = (property:Models.PropertyModel):void => { - - let onOk = ():void => { - this.$scope.component.deleteProperty(property.uniqueId); - }; - let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); - let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); - this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); - }; - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts deleted file mode 100644 index 97a117e8b7..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts +++ /dev/null @@ -1,165 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by rcohen on 9/22/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import tree = d3.layout.tree; - - export class SortTableDefined { - reverse:boolean; - sortByField:string; - } - - interface IReqAndCapabilitiesViewModelScope extends IWorkspaceViewModelScope { - requirementsTableHeadersList: Array<any>; - capabilitiesTableHeadersList: Array<any>; - capabilityPropertiesTableHeadersList: Array<any>; - requirementsSortTableDefined: SortTableDefined; - capabilitiesSortTableDefined: SortTableDefined; - propertiesSortTableDefined: SortTableDefined; - requirements:Array<Models.Requirement>; - capabilities:Array<Models.Capability>; - mode:string; - filteredProperties:Array<Array<Models.PropertyModel>>; - searchText:string; - - sort(sortBy:string, sortByTableDefined:SortTableDefined):void; - updateProperty(property:Models.PropertyModel, indexInFilteredProperties:number):void; - allCapabilitiesSelected(selected:boolean):void; - } - - export class ReqAndCapabilitiesViewModel { - - static '$inject' = [ - '$scope', - '$filter', - '$modal', - '$templateCache', - 'ModalsHandler' - ]; - - - constructor(private $scope:IReqAndCapabilitiesViewModelScope, - private $filter:ng.IFilterService, - private $modal:ng.ui.bootstrap.IModalService, - private $templateCache:ng.ITemplateCacheService) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - - private openEditPropertyModal = (property:Models.PropertyModel, indexInFilteredProperties:number):void => { - let viewModelsHtmlBasePath:string = '/app/scripts/view-models/'; - //...because there is not be api - _.forEach(this.$scope.filteredProperties[indexInFilteredProperties],(prop:Models.PropertyModel)=>{ - prop.readonly = true; - }); - let modalOptions:ng.ui.bootstrap.IModalSettings = { - template: this.$templateCache.get(viewModelsHtmlBasePath + 'forms/property-form/property-form-view.html'), - controller: 'Sdc.ViewModels.PropertyFormViewModel', - size: 'sdc-l', - backdrop: 'static', - keyboard: false, - resolve: { - property: ():Models.PropertyModel => { - return property; - }, - component: ():Models.Components.Component => { - return <Models.Components.Component> this.$scope.component; - }, - filteredProperties: ():Array<Models.PropertyModel> => { - return this.$scope.filteredProperties[indexInFilteredProperties]; - } - } - }; - this.$modal.open(modalOptions); - }; - - private initScope = ():void => { - - this.$scope.requirementsSortTableDefined = { - reverse: false, - sortByField: 'name' - }; - this.$scope.capabilitiesSortTableDefined = { - reverse: false, - sortByField: 'name' - }; - this.$scope.propertiesSortTableDefined = { - reverse: false, - sortByField: 'name' - }; - - this.$scope.setValidState(true); - this.$scope.requirementsTableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Capability', property: 'capability'}, - {title: 'Node', property: 'node'}, - {title: 'Relationship', property: 'relationship'}, - {title: 'Connected To', property: ''}, - {title: 'Occurrences', property: ''} - ]; - this.$scope.capabilitiesTableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Type', property: 'type'}, - {title: 'Description', property: ''}, - {title: 'Valid Source', property: ''}, - {title: 'Occurrences', property: ''} - ]; - this.$scope.capabilityPropertiesTableHeadersList = [ - {title: 'Name', property: 'name'}, - {title: 'Type', property: 'type'}, - {title: 'Schema', property: 'schema.property.type'}, - {title: 'Description', property: 'description'}, - ]; - this.$scope.filteredProperties=[]; - - this.$scope.mode='requirements'; - this.$scope.requirements=[]; - _.forEach(this.$scope.component.requirements,(req:Array<Models.Requirement>,capName)=>{ - this.$scope.requirements=this.$scope.requirements.concat(req); - }); - - this.$scope.capabilities=[]; - _.forEach(this.$scope.component.capabilities,(cap:Array<Models.Capability>,capName)=>{ - this.$scope.capabilities=this.$scope.capabilities.concat(cap); - }); - - this.$scope.sort = (sortBy:string, sortByTableDefined:SortTableDefined):void => { - sortByTableDefined.reverse = (sortByTableDefined.sortByField === sortBy) ? !sortByTableDefined.reverse : false; - sortByTableDefined.sortByField = sortBy; - }; - - this.$scope.updateProperty = (property:Models.PropertyModel, indexInFilteredProperties:number):void => { - this.openEditPropertyModal(property, indexInFilteredProperties); - }; - - this.$scope.allCapabilitiesSelected = (selected:boolean):void => { - _.forEach(this.$scope.capabilities,(cap:Models.Capability)=>{ - cap.selected = selected; - }); - }; - } - } -} - diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts deleted file mode 100644 index 1e6bc04924..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - import ArtifactModel = Sdc.Models.ArtifactModel; - - export interface IToscaArtifactsScope extends IWorkspaceViewModelScope { - artifacts: Array<Models.ArtifactModel>; - tableHeadersList: Array<any>; - artifactType: string; - downloadFile:Models.IFileDownload; - isLoading:boolean; - sortBy:string; - reverse:boolean; - - getTitle(): string; - download(artifact:Models.ArtifactModel): void; - sort(sortBy:string): void; - showNoArtifactMessage():boolean; - } - - export class ToscaArtifactsViewModel { - - static '$inject' = [ - '$scope', - '$filter' - ]; - - constructor(private $scope:IToscaArtifactsScope, - private $filter:ng.IFilterService) { - this.initScope(); - this.$scope.updateSelectedMenuItem(); - } - - private initScope = ():void => { - let self = this; - this.$scope.isLoading = false; - this.$scope.sortBy = 'artifactDisplayName'; - this.$scope.reverse = false; - this.$scope.setValidState(true); - this.$scope.artifactType = 'normal'; - this.$scope.getTitle = ():string => { - return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts'; - - }; - - this.$scope.tableHeadersList = [ - {title: 'Name', property: 'artifactDisplayName'}, - {title: 'Type', property: 'artifactType'} - ]; - - this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.toscaArtifacts); - this.$scope.sort = (sortBy:string):void => { - this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; - this.$scope.sortBy = sortBy; - }; - - - - this.$scope.showNoArtifactMessage = ():boolean => { - if (this.$scope.artifacts.length === 0) { - return true; - } - return false; - }; - - } - } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/workspace-view-model.ts b/catalog-ui/app/scripts/view-models/workspace/workspace-view-model.ts deleted file mode 100644 index a8523f24f5..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/workspace-view-model.ts +++ /dev/null @@ -1,703 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/** - * Created by obarda on 3/30/2016. - */ -/// <reference path="../../references"/> -module Sdc.ViewModels { - - 'use strict'; - import Resource = Sdc.Models.Components.Resource; - import ResourceType = Sdc.Utils.Constants.ResourceType; - - export interface IWorkspaceViewModelScope extends ng.IScope { - - isLoading: boolean; - isCreateProgress: boolean; - component: Models.Components.Component; - originComponent: Models.Components.Component; - componentType: string; - importFile: any; - leftBarTabs: Utils.MenuItemGroup; - isNew: boolean; - isFromImport: boolean; - isValidForm: boolean; - mode: Utils.Constants.WorkspaceMode; - breadcrumbsModel: Array<Utils.MenuItemGroup>; - sdcMenu: Models.IAppMenu; - changeLifecycleStateButtons: any; - version: string; - versionsList: Array<any>; - changeVersion: any; - isComposition: boolean; - isDeployment: boolean; - $state: ng.ui.IStateService; - user: Models.IUserProperties; - thirdParty: boolean; - disabledButtons: boolean; - menuComponentTitle: string; - progressService: Sdc.Services.ProgressService; - progressMessage: string; - // leftPanelComponents:Array<Models.Components.Component>; //this is in order to load the left panel once, and not wait long time when moving to composition - - showChangeStateButton(): boolean; - getComponent(): Sdc.Models.Components.Component; - setComponent(component: Sdc.Models.Components.Component): void; - onMenuItemPressed(state: string): ng.IPromise<boolean>; - save(): ng.IPromise<boolean>; - setValidState(isValid: boolean): void; - revert(): void; - changeLifecycleState(state: string): void; - enabledTabs(): void - isDesigner(): boolean; - isViewMode(): boolean; - isEditMode(): boolean; - isCreateMode(): boolean; - isDisableMode(): boolean; - showFullIcons(): boolean; - goToBreadcrumbHome(): void; - onVersionChanged(selectedId: string): void; - getLatestVersion(): void; - getStatus(): string; - showLifecycleIcon(): boolean; - updateSelectedMenuItem(): void; - uploadFileChangedInGeneralTab(): void; - updateMenuComponentName(ComponentName: string): void; - } - - export class WorkspaceViewModel { - - static '$inject' = [ - '$scope', - 'injectComponent', - 'ComponentFactory', - '$state', - 'sdcMenu', - '$q', - 'MenuHandler', - 'Sdc.Services.CacheService', - 'ChangeLifecycleStateHandler', - 'ModalsHandler', - 'LeftPaletteLoaderService', - '$filter', - 'EventListenerService', - 'Sdc.Services.EntityService', - 'Notification', - '$stateParams', - 'Sdc.Services.ProgressService' - ]; - - constructor(private $scope: IWorkspaceViewModelScope, - private injectComponent: Models.Components.Component, - private ComponentFactory: Utils.ComponentFactory, - private $state: ng.ui.IStateService, - private sdcMenu: Models.IAppMenu, - private $q: ng.IQService, - private MenuHandler: Utils.MenuHandler, - private cacheService: Services.CacheService, - private ChangeLifecycleStateHandler: Sdc.Utils.ChangeLifecycleStateHandler, - private ModalsHandler: Sdc.Utils.ModalsHandler, - private LeftPaletteLoaderService: Services.Components.LeftPaletteLoaderService, - private $filter: ng.IFilterService, - private EventListenerService: Services.EventListenerService, - private EntityService: Sdc.Services.EntityService, - private Notification: any, - private $stateParams: any, - private progressService: Sdc.Services.ProgressService) { - - this.initScope(); - this.initAfterScope(); - } - - private role: string; - private components: Array<Models.Components.Component>; - - private initViewMode = (): Utils.Constants.WorkspaceMode => { - let mode = Utils.Constants.WorkspaceMode.VIEW; - - if (!this.$state.params['id']) { //&& !this.$state.params['vspComponent'] - mode = Utils.Constants.WorkspaceMode.CREATE; - } else { - if (this.$scope.component.lifecycleState === Utils.Constants.ComponentState.NOT_CERTIFIED_CHECKOUT && - this.$scope.component.lastUpdaterUserId === this.cacheService.get("user").userId) { - if (this.$scope.component.isProduct() && this.role == Utils.Constants.Role.PRODUCT_MANAGER) { - mode = Utils.Constants.WorkspaceMode.EDIT; - } - if ((this.$scope.component.isService() || this.$scope.component.isResource()) && this.role == Utils.Constants.Role.DESIGNER) { - mode = Utils.Constants.WorkspaceMode.EDIT; - } - } - } - return mode; - }; - - private initChangeLifecycleStateButtons = (): void => { - let state = this.$scope.component.isService() && (Utils.Constants.Role.OPS == this.role || Utils.Constants.Role.GOVERNOR == this.role) ? this.$scope.component.distributionStatus : this.$scope.component.lifecycleState; - this.$scope.changeLifecycleStateButtons = this.sdcMenu.roles[this.role].changeLifecycleStateButtons[state]; - }; - - private isNeedSave = (): boolean => { - if (this.$scope.isEditMode() && //this is a workaround for onboarding - we need to get the artifact in order to avoid saving the vf when moving from their tabs - (this.$state.current.name === Utils.Constants.States.WORKSPACE_MANAGEMENT_WORKFLOW || this.$state.current.name === Utils.Constants.States.WORKSPACE_NETWORK_CALL_FLOW)) { - return true; - } - return this.$scope.isEditMode() && - this.$state.current.data && this.$state.current.data.unsavedChanges; - }; - - private initScope = (): void => { - - this.$scope.component = this.injectComponent; - this.$scope.menuComponentTitle = this.$scope.component.name; - this.$scope.disabledButtons = false; - this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component); - this.$scope.componentType = this.$scope.component.componentType; - this.$scope.version = this.cacheService.get('version'); - this.$scope.user = this.cacheService.get("user"); - this.role = this.$scope.user.role; - this.$scope.mode = this.initViewMode(); - this.$scope.isValidForm = true; - this.initChangeLifecycleStateButtons(); - this.initVersionObject(); - this.$scope.$state = this.$state; - this.$scope.isLoading = false; - this.$scope.isComposition = (this.$state.current.name.indexOf(Utils.Constants.States.WORKSPACE_COMPOSITION) > -1); - this.$scope.isDeployment = (this.$state.current.name.indexOf(Utils.Constants.States.WORKSPACE_DEPLOYMENT) > -1); - this.$scope.progressService = this.progressService; - - this.$scope.getComponent = (): Sdc.Models.Components.Component => { - return this.$scope.component; - }; - - this.$scope.updateMenuComponentName = (ComponentName: string): void => { - this.$scope.menuComponentTitle = ComponentName; - }; - - this.$scope.sdcMenu = this.sdcMenu; - // Will be called from each step after save to update the resource. - this.$scope.setComponent = (component: Sdc.Models.Components.Component): void => { - this.$scope.component = component; - }; - - this.$scope.uploadFileChangedInGeneralTab = (): void => { - // In case user select browse file, and in update mode, need to disable submit for testing and checkin buttons. - if (this.$scope.isEditMode() && this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType == ResourceType.VF) { - this.$scope.disabledButtons = true; - } - }; - - this.$scope.onMenuItemPressed = (state: string): ng.IPromise<boolean> => { - let deferred = this.$q.defer(); - if (this.isNeedSave()) { - if (this.$scope.isValidForm) { - let onSuccess = (): void => { - this.$state.go(state, { - id: this.$scope.component.uniqueId, - type: this.$scope.component.componentType.toLowerCase(), - components: this.components - }); - deferred.resolve(true); - }; - this.$scope.save().then(onSuccess); - } else { - console.log('form is not valid'); - deferred.reject(false); - } - } else { - this.$state.go(state, { - id: this.$scope.component.uniqueId, - type: this.$scope.component.componentType.toLowerCase(), - components: this.components - }); - deferred.resolve(true); - } - return deferred.promise; - }; - - this.$scope.setValidState = (isValid: boolean): void => { - this.$scope.isValidForm = isValid; - }; - - this.$scope.onVersionChanged = (selectedId: string): void => { - this.$scope.isLoading = true; - if (this.$state.current.data && this.$state.current.data.unsavedChanges) { - this.$scope.changeVersion.selectedVersion = _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId}); - } - this.$state.go(this.$state.current.name, { - id: selectedId, - type: this.$scope.componentType.toLowerCase(), - mode: Utils.Constants.WorkspaceMode.VIEW, - components: this.$state.params['components'] - }); - - }; - - this.$scope.getLatestVersion = (): void => { - this.$scope.onVersionChanged(_.first(this.$scope.versionsList).versionId); - }; - - this.$scope.save = (state?: string): ng.IPromise<boolean> => { - this.EventListenerService.notifyObservers(Utils.Constants.EVENTS.ON_WORKSPACE_SAVE_BUTTON_CLICK); - - this.progressService.initCreateComponentProgress(this.$scope.component.uniqueId); - - let deferred = this.$q.defer(); - let modalInstance: ng.ui.bootstrap.IModalServiceInstance; - - let onFailed = () => { - this.EventListenerService.notifyObservers(Utils.Constants.EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR); - this.progressService.deleteProgressValue(this.$scope.component.uniqueId); - modalInstance && modalInstance.close(); // Close the modal in case it is opened. - this.$scope.isCreateProgress = false; - this.$scope.isLoading = false; // stop the progress. - - this.$scope.setValidState(true); // Set the form valid (if sent form is valid, the error from server). - if (!this.$scope.isCreateMode()) { - this.$scope.component = this.$scope.originComponent; // Set the component back to the original. - this.enableMenuItems(); // Enable the menu items (left tabs), so user can press on them. - this.$scope.disabledButtons = false; // Enable "submit for testing" & checking buttons. - } - - deferred.reject(false); - }; - - let onSuccessCreate = (component: Models.Components.Component) => { - - this.EventListenerService.notifyObservers(Utils.Constants.EVENTS.ON_WORKSPACE_SAVE_BUTTON_SUCCESS); - this.progressService.deleteProgressValue(this.$scope.component.uniqueId); - //update components for breadcrumbs - this.components.unshift(component); - this.$state.go(Utils.Constants.States.WORKSPACE_GENERAL, { - id: component.uniqueId, - type: component.componentType.toLowerCase(), - components: this.components - }); - - deferred.resolve(true); - }; - - let onSuccessUpdate = (component: Models.Components.Component) => { - this.$scope.isCreateProgress = false; - this.$scope.disabledButtons = false; - this.EventListenerService.notifyObservers(Utils.Constants.EVENTS.ON_WORKSPACE_SAVE_BUTTON_SUCCESS); - this.progressService.deleteProgressValue(this.$scope.component.uniqueId); - - // Stop the circle loader. - this.$scope.isLoading = false; - - component.tags = _.reject(component.tags, (item)=> { - return item === component.name - }); - - // Update the components - this.$scope.component = component; - this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component); - - //update components for breadcrumbs - this.components.unshift(component); - - // Enable left tags - this.$scope.enabledTabs(); - - - if (this.$state.current.data) { - this.$state.current.data.unsavedChanges = false; - } - - deferred.resolve(true); - }; - - if (this.$scope.isCreateMode()) { - this.$scope.progressMessage = "Creating Asset..."; - // CREATE MODE - this.$scope.isCreateProgress = true; - - // Start creating the component - this.ComponentFactory.createComponentOnServer(this.$scope.component).then(onSuccessCreate, onFailed); - - // In case we import CSAR. Notify user that import VF will take long time (the create is performed in the background). - if (this.$scope.component.isResource() && (<Resource>this.$scope.component).csarUUID) { - this.Notification.info({ - message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_DESCRIPTION"), - title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE") - }); - } - } else { - // UPDATE MODE - this.$scope.isCreateProgress = true; - this.$scope.progressMessage = "Updating Asset..."; - this.disableMenuItems(); - - - // Work around to change the csar version - if (this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { - (<Resource>this.$scope.component).csarVersion = this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG); - this.cacheService.remove(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG); - } - - this.$scope.component.updateComponent().then(onSuccessUpdate, onFailed); - } - return deferred.promise; - }; - - this.$scope.revert = (): void => { - //in state of import file leave the file in place - if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) { - let tempFile: Sdc.Directives.FileUploadModel = (<Resource>this.$scope.component).importedFile; - this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); - (<Resource>this.$scope.component).importedFile = tempFile; - } else { - this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); - } - - }; - - this.$scope.changeLifecycleState = (state: string): void => { - if (this.isNeedSave() && state !== 'deleteVersion') { - this.$scope.save().then(() => { - changeLifecycleState(state); - }) - } else { - changeLifecycleState(state); - } - }; - - let defaultActionAfterChangeLifecycleState = (): void => { - if (this.$state.current.data && this.$state.current.data.unsavedChanges) { - this.$state.current.data.unsavedChanges = false; - } - this.$state.go('dashboard'); - }; - - let changeLifecycleState = (state: string) => { - if ('monitor' === state) { - this.$state.go('workspace.distribution'); - return; - } - - let data = this.$scope.changeLifecycleStateButtons[state]; - let onSuccess = (component: Models.Components.Component): void => { - //Updating the component from server response - - //the server returns only metaData (small component) except checkout (Full component) ,so we update only the statuses of distribution & lifecycle - this.$scope.component.lifecycleState = component.lifecycleState; - this.$scope.component.distributionStatus = component.distributionStatus; - - switch (data.url) { - case 'lifecycleState/CHECKOUT': - // only checkOut get the full component from server - this.$scope.component = component; - // Work around to change the csar version - if (this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { - (<Resource>this.$scope.component).csarVersion = this.cacheService.get(Utils.Constants.CHANGE_COMPONENT_CSAR_VERSION_FLAG); - } - - //when checking out a minor version uuid remains - let bcComponent: Sdc.Models.Components.Component = _.find(this.components, (item) => { - return item.uuid === component.uuid; - }); - if (bcComponent) { - this.components[this.components.indexOf(bcComponent)] = component; - } else { - //when checking out a major(certified) version - this.components.unshift(component); - } - - this.$state.go(this.$state.current.name, { - id: component.uniqueId, - type: component.componentType.toLowerCase(), - components: this.components - }); - this.Notification.success({ - message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'lifecycleState/CHECKIN': - defaultActionAfterChangeLifecycleState(); - this.Notification.success({ - message: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'lifecycleState/UNDOCHECKOUT': - defaultActionAfterChangeLifecycleState(); - this.Notification.success({ - message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'lifecycleState/certificationRequest': - defaultActionAfterChangeLifecycleState(); - this.Notification.success({ - message: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TITLE") - }); - break; - //Tester Role - case 'lifecycleState/failCertification': - defaultActionAfterChangeLifecycleState(); - this.Notification.success({ - message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'lifecycleState/certify': - defaultActionAfterChangeLifecycleState(); - this.Notification.success({ - message: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TITLE") - }); - break; - //DE203504 Bug Fix Start - case 'lifecycleState/startCertification': - this.initChangeLifecycleStateButtons(); - this.Notification.success({ - message: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'lifecycleState/cancelCertification': - this.initChangeLifecycleStateButtons(); - this.Notification.success({ - message: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TITLE") - }); - break; - //Ops Role - case 'distribution/PROD/activate': - this.initChangeLifecycleStateButtons(); - this.Notification.success({ - message: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TITLE") - }); - break; - //Governor Role - case 'distribution-state/reject': - this.initChangeLifecycleStateButtons(); - this.Notification.success({ - message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE") - }); - break; - case 'distribution-state/approve': - this.initChangeLifecycleStateButtons(); - this.$state.go('catalog'); - this.Notification.success({ - message: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TEXT"), - title: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TITLE") - }); - break; - //DE203504 Bug Fix End - - default : - defaultActionAfterChangeLifecycleState(); - - } - if (data.url != 'lifecycleState/CHECKOUT') { - this.$scope.isLoading = false; - } - }; - //this.$scope.isLoading = true; - this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess); - }; - - this.$scope.enabledTabs = (): void => { - this.$scope.leftBarTabs.menuItems.forEach((item: Utils.MenuItem) => { - item.isDisabled = false; - }); - }; - - this.$scope.isViewMode = (): boolean => { - return this.$scope.mode === Utils.Constants.WorkspaceMode.VIEW; - }; - - this.$scope.isDesigner = (): boolean => { - return this.role == Utils.Constants.Role.DESIGNER; - }; - - this.$scope.isDisableMode = (): boolean => { - return this.$scope.mode === Utils.Constants.WorkspaceMode.VIEW && this.$scope.component.lifecycleState === Utils.Constants.ComponentState.NOT_CERTIFIED_CHECKIN; - }; - - this.$scope.showFullIcons = (): boolean => { - //we show revert and save icons only in general\icon view - return this.$state.current.name === Utils.Constants.States.WORKSPACE_GENERAL || - this.$state.current.name === Utils.Constants.States.WORKSPACE_ICONS; - }; - - this.$scope.isCreateMode = (): boolean => { - return this.$scope.mode === Utils.Constants.WorkspaceMode.CREATE; - }; - - this.$scope.isEditMode = (): boolean => { - return this.$scope.mode === Utils.Constants.WorkspaceMode.EDIT; - }; - - this.$scope.goToBreadcrumbHome = (): void => { - let bcHome: Sdc.Utils.MenuItemGroup = this.$scope.breadcrumbsModel[0]; - this.$state.go(bcHome.menuItems[bcHome.selectedIndex].state); - }; - - this.$scope.showLifecycleIcon = (): boolean => { - return this.role == Utils.Constants.Role.DESIGNER || - this.role == Utils.Constants.Role.PRODUCT_MANAGER; - }; - - this.$scope.getStatus = (): string => { - if (this.$scope.isCreateMode()) { - return 'IN DESIGN'; - } - - return this.$scope.component.getStatus(this.sdcMenu); - }; - - this.initMenuItems(); - - this.$scope.showChangeStateButton = (): boolean => { - let result: boolean = true; - if (!this.$scope.component.isLatestVersion() && Utils.Constants.Role.OPS != this.role && Utils.Constants.Role.GOVERNOR != this.role) { - result = false; - } - if (this.role === Utils.Constants.Role.PRODUCT_MANAGER && !this.$scope.component.isProduct()) { - result = false; - } - if ((this.role === Utils.Constants.Role.DESIGNER || this.role === Utils.Constants.Role.TESTER) - && this.$scope.component.isProduct()) { - result = false; - } - if (Utils.Constants.ComponentState.NOT_CERTIFIED_CHECKOUT === this.$scope.component.lifecycleState && this.$scope.isViewMode()) { - result = false; - } - if (Utils.Constants.ComponentState.CERTIFIED != this.$scope.component.lifecycleState && - (Utils.Constants.Role.OPS == this.role || Utils.Constants.Role.GOVERNOR == this.role)) { - result = false; - } - return result; - }; - - this.$scope.updateSelectedMenuItem = (): void => { - let selectedItem: Sdc.Utils.MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item: Sdc.Utils.MenuItem) => { - return item.state === this.$state.current.name; - }); - this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0; - }; - - this.$scope.$watch('$state.current.name', (newVal: string): void => { - if (newVal) { - this.$scope.isComposition = (newVal.indexOf(Utils.Constants.States.WORKSPACE_COMPOSITION) > -1); - this.$scope.isDeployment = (newVal.indexOf(Utils.Constants.States.WORKSPACE_DEPLOYMENT) > -1); - } - }); - }; - - private initAfterScope = (): void => { - // In case user select csar from the onboarding modal, need to disable checkout and submit for testing. - if (this.$state.params['disableButtons'] === true) { - this.$scope.uploadFileChangedInGeneralTab(); - } - }; - - private initVersionObject = (): void => { - this.$scope.versionsList = (this.$scope.component.getAllVersionsAsSortedArray()).reverse(); - this.$scope.changeVersion = {selectedVersion: _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId})}; - }; - - private getNewComponentBreadcrumbItem = (): Utils.MenuItem => { - let text = ""; - if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { - text = this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name; - } else { - text = 'Create new ' + this.$state.params['type']; - } - return new Utils.MenuItem(text, null, Utils.Constants.States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]); - }; - - private updateMenuItemByRole = (menuItems: Array<Utils.MenuItem>, role: string) => { - let tempMenuItems: Array<Utils.MenuItem> = new Array<Utils.MenuItem>(); - menuItems.forEach((item: Utils.MenuItem) => { - //remove item if role is disabled - if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) { - tempMenuItems.push(item); - } - }); - return tempMenuItems; - }; - - private initBreadcrumbs = () => { - this.components = this.cacheService.get('breadcrumbsComponents'); - let breadcrumbsComponentsLvl = this.MenuHandler.generateBreadcrumbsModelFromComponents(this.components, this.$scope.component); - - if (this.$scope.isCreateMode()) { - let createItem = this.getNewComponentBreadcrumbItem(); - if (!breadcrumbsComponentsLvl.menuItems) { - breadcrumbsComponentsLvl.menuItems = []; - } - breadcrumbsComponentsLvl.menuItems.unshift(createItem); - breadcrumbsComponentsLvl.selectedIndex = 0; - } - - this.$scope.breadcrumbsModel = [breadcrumbsComponentsLvl, this.$scope.leftBarTabs]; - }; - - private initMenuItems() { - - let inCreateMode = this.$scope.isCreateMode(); - this.$scope.leftBarTabs = new Utils.MenuItemGroup(); - this.$scope.leftBarTabs.menuItems = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role); - - this.$scope.leftBarTabs.menuItems.forEach((item: Utils.MenuItem) => { - item.params = [item.state]; - item.callback = this.$scope.onMenuItemPressed; - item.isDisabled = (inCreateMode && Utils.Constants.States.WORKSPACE_GENERAL != item.state) || - (Utils.Constants.States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups.length === 0 && this.$scope.component.isResource()); - }); - - if (this.cacheService.get('breadcrumbsComponents')) { - this.initBreadcrumbs(); - } else { - let onSuccess = (components: Array<Models.Components.Component>) => { - this.cacheService.set('breadcrumbsComponents', components); - this.initBreadcrumbs(); - }; - this.EntityService.getCatalog().then(onSuccess); //getAllComponents() doesnt return components from catalog - } - } - - private disableMenuItems() { - this.$scope.leftBarTabs.menuItems.forEach((item: Utils.MenuItem) => { - item.params = [item.state]; - item.callback = this.$scope.onMenuItemPressed; - item.isDisabled = (Utils.Constants.States.WORKSPACE_GENERAL != item.state); - }); - } - - private enableMenuItems() { - this.$scope.leftBarTabs.menuItems.forEach((item: Utils.MenuItem) => { - item.params = [item.state]; - item.callback = this.$scope.onMenuItemPressed; - item.isDisabled = false; - }); - } - - } -} - - diff --git a/catalog-ui/app/scripts/view-models/workspace/workspace.less b/catalog-ui/app/scripts/view-models/workspace/workspace.less deleted file mode 100644 index d8bff1b634..0000000000 --- a/catalog-ui/app/scripts/view-models/workspace/workspace.less +++ /dev/null @@ -1,144 +0,0 @@ -.sdc-workspace-container { - .bg_p; - - .add-btn { - .f-color.a; - .f-type._12_m; - .hand; - float: right; - margin-bottom: 15px; - - &:before { - .sprite-new; - .plus-icon; - margin-right: 5px; - content: ""; - - } - &:hover { - .f-color.b; - &:before { - .sprite-new; - .plus-icon-hover; - } - } - - } - .w-sdc-left-sidebar { - padding: 3px 3px 0px 0px; - background-color: @main_color_p; - box-shadow: 7px -3px 6px -8px @main_color_n; - z-index: 2; - } - - .sdc-asset-creation-info { - .n_12_r; - float: right; - margin: 8px 20px 0 0; - } - - .w-sdc-main-right-container { - - padding: 0px 0px 0px 0px; - background-color: @main_color_p; - z-index: 1; - - .sdc-workspace-top-bar { - height: @action_nav_height; - padding: 12px 10px 0px 50px; - border-bottom: 1px solid @main_color_o; - display: flex; - justify-content: space-between; - - .version-container { - - } - - .progress-container { - flex-grow: 4; - z-index: 10000000; - - .general-view-top-progress { - width: 30%; - margin: 0 auto; - } - } - - .not-latest { - position: absolute; - left: 24px; - top: 20px; - .sprite-new; - .asdc-warning; - } - - .sdc-workspace-top-bar-buttons { - - > button, > span:not(.delimiter) { - margin-right: 10px; - vertical-align: middle; - .hand; - - &.sprite-new { - text-indent: 100%; - } - &.disabled, &:hover.disabled { - pointer-events: none; - } - } - .delimiter { - height: 32px; - width: 1px; - background-color: #959595; - display: inline-block; - vertical-align: middle; - margin-right: 20px; - } - - } - - .lifecycle-state { - padding: 7px 0 0 10px; - margin: 2px 0 7px 10px; - border-left: 1px solid @main_color_o; - line-height: 15px; - font-family: @font-omnes-medium; - color: @main_color_m; - - .lifecycle-state-icon { - .sprite-new; - } - .lifecycle-state-text { - - font-weight: bold; - text-transform: uppercase; - vertical-align: top; - padding: 3px; - } - } - - .version-selector { - // float:left; - background-color: transparent; - border: none; - margin-top: 6px; - } - } - .w-sdc-main-container-body-content { - height:100%; - - text-align: center; - align-items: center; - padding: 40px 14% 20px 14%; - &.third-party { - text-align: left; - padding: 0; - position: absolute; - top: @action_nav_height; - left: 0; - right: 0; - bottom: 0; - } - } - } -} diff --git a/catalog-ui/app/styles/app.less b/catalog-ui/app/styles/app.less deleted file mode 100644 index cec5b86753..0000000000 --- a/catalog-ui/app/styles/app.less +++ /dev/null @@ -1,122 +0,0 @@ -.sdc-main-container{ - width: 100%; - height: 100%; -} - -// injector:less -@import 'animation.less'; -@import 'buttons.less'; -@import 'dark-header.less'; -@import 'fonts.less'; -@import 'form-elements.less'; -@import 'global.less'; -@import 'layout/header.less'; -@import 'layout/main.less'; -@import 'layout/sidebar.less'; -@import 'mixins.less'; -@import 'mixins_old.less'; -@import 'modal.less'; -@import 'scroller.less'; -@import 'sprite-old.less'; -@import 'sprite-product-icons.less'; -@import 'sprite-resource-icons.less'; -@import 'sprite-services-icons.less'; -@import 'sprite.less'; -@import 'table-flex.less'; -@import 'tlv-buttons.less'; -@import 'tlv-checkbox.less'; -@import 'tlv-loader.less'; -@import 'tlv-sprite.less'; -@import 'tooltips.less'; -@import 'variables-old.less'; -@import 'variables.less'; -@import 'welcome-sprite.less'; -@import 'welcome-style.less'; -@import '../scripts/directives/ecomp-header/ecomp-header.less'; -@import '../scripts/directives/edit-name-popover/edit-name-popover.less'; -@import '../scripts/directives/elements/checkbox/checkbox.less'; -@import '../scripts/directives/elements/radiobutton/radiobutton.less'; -@import '../scripts/directives/ellipsis/ellipsis-directive.less'; -@import '../scripts/directives/file-upload/file-upload.less'; -@import '../scripts/directives/graphs-v2/composition-graph/composition-graph.less'; -@import '../scripts/directives/graphs-v2/deployment-graph/deployment-graph.less'; -@import '../scripts/directives/graphs-v2/palette/palette.less'; -@import '../scripts/directives/graphs-v2/relation-menu/relation-menu.less'; -@import '../scripts/directives/info-tooltip/info-tooltip.less'; -@import '../scripts/directives/layout/top-nav/top-nav.less'; -@import '../scripts/directives/layout/top-progress/top-progress.less'; -@import '../scripts/directives/loader/loader-directive.less'; -@import '../scripts/directives/modal/sdc-modal.less'; -@import '../scripts/directives/page-scroller/page-scroller.less'; -@import '../scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.less'; -@import '../scripts/directives/property-types/type-list/type-list-directive.less'; -@import '../scripts/directives/property-types/type-map/type-map-directive.less'; -@import '../scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less'; -@import '../scripts/directives/sdc-tabs/sdc-tabs.less'; -@import '../scripts/directives/structure-tree/structure-tree-directive.less'; -@import '../scripts/directives/tag/tag-directive.less'; -@import '../scripts/directives/tutorial/tutorial-directive.less'; -@import '../scripts/directives/user-header-details/user-header-details-directive.less'; -@import '../scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less'; -@import '../scripts/directives/utils/expand-collapse/expand-collapse.less'; -@import '../scripts/directives/utils/page-selector/page-selector.less'; -@import '../scripts/directives/utils/sdc-tags/sdc-tags.less'; -@import '../scripts/directives/utils/sdc_messages/sdc-messages.less'; -@import '../scripts/directives/utils/wizard_steps/sdc-wizard-steps.less'; -@import '../scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less'; -@import '../scripts/view-models/admin-dashboard/admin-dashboard.less'; -@import '../scripts/view-models/admin-dashboard/category-management/category-management.less'; -@import '../scripts/view-models/admin-dashboard/user-management/user-management.less'; -@import '../scripts/view-models/catalog/catalog.less'; -@import '../scripts/view-models/component-viewer/activity-log/activity-log-view.less'; -@import '../scripts/view-models/component-viewer/component-viewer.less'; -@import '../scripts/view-models/component-viewer/properties/properties-view.less'; -@import '../scripts/view-models/dashboard/dashboard.less'; -@import '../scripts/view-models/forms/artifact-form/artifact-form.less'; -@import '../scripts/view-models/forms/env-parameters-form/env-parameters-form.less'; -@import '../scripts/view-models/forms/property-form/property-form.less'; -@import '../scripts/view-models/forms/resource-instance-name-form/resource-instance-name.less'; -@import '../scripts/view-models/modals/confirmation-modal/confirmation-modal.less'; -@import '../scripts/view-models/modals/email-modal/email-modal.less'; -@import '../scripts/view-models/modals/error-modal/error.less'; -@import '../scripts/view-models/modals/message-modal/message-client-modal/client-message-modal.less'; -@import '../scripts/view-models/modals/message-modal/message-server-modal/server-message-modal.less'; -@import '../scripts/view-models/modals/onboarding-modal/onboarding-modal.less'; -@import '../scripts/view-models/onboard-vendor/onboard-vendor.less'; -@import '../scripts/view-models/preloading/preloading-view.less'; -@import '../scripts/view-models/support/support.less'; -@import '../scripts/view-models/tabs/general-tab.less'; -@import '../scripts/view-models/tabs/hierarchy/hierarchy.less'; -@import '../scripts/view-models/tutorial-end/tutorial-end.less'; -@import '../scripts/view-models/wizard/artifact-deployment-step/artifact-deployment-step.less'; -@import '../scripts/view-models/wizard/artifact-form-step/artifact-form-step.less'; -@import '../scripts/view-models/wizard/artifact-information-step/artifact-information-step.less'; -@import '../scripts/view-models/wizard/general-step/general-step.less'; -@import '../scripts/view-models/wizard/hierarchy-step/hierarchy-step.less'; -@import '../scripts/view-models/wizard/icons-step/icons-step.less'; -@import '../scripts/view-models/wizard/properties-step/properties-step.less'; -@import '../scripts/view-models/wizard/property-form/property-form.less'; -@import '../scripts/view-models/wizard/wizard-creation-base.less'; -@import '../scripts/view-models/workspace/tabs/activity-log/activity-log.less'; -@import '../scripts/view-models/workspace/tabs/attributes/attributes.less'; -@import '../scripts/view-models/workspace/tabs/composition/composition.less'; -@import '../scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less'; -@import '../scripts/view-models/workspace/tabs/composition/tabs/details/details.less'; -@import '../scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less'; -@import '../scripts/view-models/workspace/tabs/composition/tabs/relations/relations.less'; -@import '../scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less'; -@import '../scripts/view-models/workspace/tabs/deployment/deployment.less'; -@import '../scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less'; -@import '../scripts/view-models/workspace/tabs/distribution/distribution.less'; -@import '../scripts/view-models/workspace/tabs/general/general.less'; -@import '../scripts/view-models/workspace/tabs/icons/icons.less'; -@import '../scripts/view-models/workspace/tabs/information-artifacts/information-artifacts.less'; -@import '../scripts/view-models/workspace/tabs/inputs/inputs.less'; -@import '../scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less'; -@import '../scripts/view-models/workspace/tabs/inputs/service-input/service-inputs.less'; -@import '../scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less'; -@import '../scripts/view-models/workspace/tabs/properties/properties.less'; -@import '../scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less'; -@import '../scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less'; -@import '../scripts/view-models/workspace/workspace.less'; -// endinjector:less diff --git a/catalog-ui/app/styles/images/resource-icons/compute-uncertified.png b/catalog-ui/app/styles/images/resource-icons/compute-uncertified.png Binary files differdeleted file mode 100644 index f1254d2dfc..0000000000 --- a/catalog-ui/app/styles/images/resource-icons/compute-uncertified.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/sprites/sprite-global.png b/catalog-ui/app/styles/images/sprites/sprite-global.png Binary files differdeleted file mode 100644 index bb2334216a..0000000000 --- a/catalog-ui/app/styles/images/sprites/sprite-global.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/SD&C_Welcome15.jpg b/catalog-ui/app/styles/images/welcome/SD&C_Welcome15.jpg Binary files differdeleted file mode 100644 index b53b229546..0000000000 --- a/catalog-ui/app/styles/images/welcome/SD&C_Welcome15.jpg +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/SD&C_Welcome15_b.jpg b/catalog-ui/app/styles/images/welcome/SD&C_Welcome15_b.jpg Binary files differdeleted file mode 100644 index bae42eb7d6..0000000000 --- a/catalog-ui/app/styles/images/welcome/SD&C_Welcome15_b.jpg +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/001.jpg b/catalog-ui/app/styles/images/welcome/bg/001.jpg Binary files differdeleted file mode 100644 index 19bc76b300..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/001.jpg +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/002.jpg b/catalog-ui/app/styles/images/welcome/bg/002.jpg Binary files differdeleted file mode 100644 index 7d5fc2ef12..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/002.jpg +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/003.png b/catalog-ui/app/styles/images/welcome/bg/003.png Binary files differdeleted file mode 100644 index c33b14fe9c..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/003.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/004.png b/catalog-ui/app/styles/images/welcome/bg/004.png Binary files differdeleted file mode 100644 index 08578bb1ec..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/004.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/bg02.png b/catalog-ui/app/styles/images/welcome/bg/bg02.png Binary files differdeleted file mode 100644 index 3b10aa45f7..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/bg02.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/bg03.png b/catalog-ui/app/styles/images/welcome/bg/bg03.png Binary files differdeleted file mode 100644 index 50fe924f5d..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/bg03.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/connection02.png b/catalog-ui/app/styles/images/welcome/bg/connection02.png Binary files differdeleted file mode 100644 index 157acba384..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/connection02.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/connection03.png b/catalog-ui/app/styles/images/welcome/bg/connection03.png Binary files differdeleted file mode 100644 index 01f21fcf41..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/connection03.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/connection04.png b/catalog-ui/app/styles/images/welcome/bg/connection04.png Binary files differdeleted file mode 100644 index 174dbfe5dd..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/connection04.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/global.png b/catalog-ui/app/styles/images/welcome/bg/global.png Binary files differdeleted file mode 100644 index 09b366404e..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/global.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/shape02.png b/catalog-ui/app/styles/images/welcome/bg/shape02.png Binary files differdeleted file mode 100644 index 91400da15d..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/shape02.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/shape03.png b/catalog-ui/app/styles/images/welcome/bg/shape03.png Binary files differdeleted file mode 100644 index af6384674b..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/shape03.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/shape04.png b/catalog-ui/app/styles/images/welcome/bg/shape04.png Binary files differdeleted file mode 100644 index 36759df6e5..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/shape04.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/bg/shape05.png b/catalog-ui/app/styles/images/welcome/bg/shape05.png Binary files differdeleted file mode 100644 index 336411fd80..0000000000 --- a/catalog-ui/app/styles/images/welcome/bg/shape05.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/laptop.png b/catalog-ui/app/styles/images/welcome/laptop.png Binary files differdeleted file mode 100644 index 160e743d1b..0000000000 --- a/catalog-ui/app/styles/images/welcome/laptop.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/logo_att.png b/catalog-ui/app/styles/images/welcome/logo_att.png Binary files differdeleted file mode 100644 index e145a1ae5d..0000000000 --- a/catalog-ui/app/styles/images/welcome/logo_att.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/ss-01.png b/catalog-ui/app/styles/images/welcome/ss-01.png Binary files differdeleted file mode 100644 index abd4cd7a46..0000000000 --- a/catalog-ui/app/styles/images/welcome/ss-01.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/ss-02.png b/catalog-ui/app/styles/images/welcome/ss-02.png Binary files differdeleted file mode 100644 index d4d0038b64..0000000000 --- a/catalog-ui/app/styles/images/welcome/ss-02.png +++ /dev/null diff --git a/catalog-ui/app/styles/images/welcome/ss-03.png b/catalog-ui/app/styles/images/welcome/ss-03.png Binary files differdeleted file mode 100644 index 9a259ca7c2..0000000000 --- a/catalog-ui/app/styles/images/welcome/ss-03.png +++ /dev/null diff --git a/catalog-ui/app/styles/welcome-style.less b/catalog-ui/app/styles/welcome-style.less deleted file mode 100644 index 0d969878c7..0000000000 --- a/catalog-ui/app/styles/welcome-style.less +++ /dev/null @@ -1,651 +0,0 @@ -@zoom-in-animation-play: 2s; -@zoom-in-animation: 3s; -@slide-fade-in-text-main-animation: 2s; - -html, -body { - height: 100%; - /*overflow-x: hidden;*/ -} - -* { - box-sizing: border-box; -} - -body { - background-image: url(images/welcome/bg/global.png); -} - -.sdc-welcome-new-page { - - opacity: 1; - height: 100%; - background-color: @main_color_l; - - .os-welcome { - top: 47%; - position: fixed; - left: 42%; - font-size: 40px; - } - - #slide-2, #slide-3, #slide-4, #slide-5 { - padding: 0 50px 0 30px; - } - - .visible { - visibility: visible; - } - - .asdc-welcome-close { - position: absolute; - right: 38px; - top: 30px; - z-index: 101; - cursor: pointer; - - .sprite-welcome; - .sprite-welcome.close; - - &:hover { - .sprite-welcome.close_white; - } - } - - .asdc-welcome-frame { - height: 100vh; - width: 100%; - background-size: cover; - position: relative; - display: flex; - align-items: center; - justify-content: center; - } - - .asdc-welcome-frame.frame-0 { - background-image: url(images/welcome/bg/002.jpg); - background-size: cover; - - .asdc-whats-new { - - z-index: 1; - - .news-items-row { - display: flex; - flex-direction: row; - - .news-item-wrapper { - width: 250px; - height: 343px; - background-color: @main_color_p; - margin: 16px; - padding: 40px 20px 20px 20px; - border-radius: 4px; - opacity: 0; - - ul { - padding-left: 17px; - li { - list-style: disc; - } - } - - ol { - padding-left: 12px; - } - - &.bg-1 {border-bottom: solid 5px @main_color_a;} - &.bg-2 {border-bottom: solid 5px @main_color_j;} - &.bg-3 {border-bottom: solid 5px @main_color_d;} - &.bg-4 {border-bottom: solid 5px @main_color_i;} - &.bg-5 {border-bottom: solid 5px @main_color_e;} - &.bg-6 {border-bottom: solid 5px @func_color_b;} - &.bg-7 {border-bottom: solid 5px @main_color_c;} - &.bg-8 {border-bottom: solid 5px @main_color_k;} - - .news-body { - .m_14_r; - } - .news-title { - margin-bottom: 20px; - .s_18_m; - } - } - } - - - } - } - - .asdc-welcome-frame.frame-01 { - background-image: url(images/welcome/bg/002.png); - background-size: cover; - } - - .asdc-welcome-frame.frame-02 .asdc-welcome-slide-image-box { - position: absolute; - right: 11.6vw; - top: 10.5vw; - z-index: 1; - } - - .asdc-welcome-frame.frame-02 .asdc-welcome-slide-text-box { - position: absolute; - top: 33%; - left: 10%; - z-index: 1; - } - - .asdc-welcome-frame.frame-02 .asdc-welcome-frame-shape { - background-image: url(images/welcome/bg/shape02.png); - position: absolute; - height: 19vw; - width: 19vw; - top: 2.1vw; - left: 32.1vw; - /* opacity: .3; */ - background-size: contain; - /* background-repeat: no-repeat; */ - z-index: 0; - visibility: hidden; - - animation-duration: @zoom-in-animation; - -moz-animation-duration: @zoom-in-animation; - -webkit-animation-duration: @zoom-in-animation; - } - - .asdc-welcome-frame.frame-02 .asdc-welcome-frame-connection { - background-image: url(images/welcome/bg/connection02.png); - width: 56px; - height: 27vw; - position: absolute; - bottom: 0; - right: 295px; - background-position: 0px 35vw; - } - - .asdc-welcome-frame.frame-03 .asdc-welcome-slide-image-box { - position: absolute; - left: 6%; - top: 20%; - z-index: 1; - } - - .asdc-welcome-frame.frame-03 .asdc-welcome-slide-text-box { - position: absolute; - top: 38%; - right: 14.2vw; - z-index: 1; - } - - .asdc-welcome-frame.frame-03 .asdc-welcome-frame-shape { - background-image: url(images/welcome/bg/shape03.png); - position: absolute; - height: 378px; - width: 252px; - top: 0vw; - right: 195px; - background-size: contain; - z-index: 0; - visibility: hidden; - - animation-duration: @zoom-in-animation; - -moz-animation-duration: @zoom-in-animation; - -webkit-animation-duration: @zoom-in-animation; - } - - .asdc-welcome-frame.frame-03 .asdc-welcome-frame-connection { - background-image: url(images/welcome/bg/connection03.png); - width: 204px; - height: 371px; - position: absolute; - bottom: -109px; - right: 590px; - } - - .asdc-welcome-frame.frame-04 .asdc-welcome-slide-image-box { - position: absolute; - right: 10%; - top: 20%; - z-index: 5; - } - - .asdc-welcome-frame.frame-04 .asdc-welcome-slide-text-box { - position: absolute; - top: 34%; - left: 8%; - z-index: 5; - } - - .asdc-welcome-frame.frame-04 .asdc-welcome-frame-connection { - background-image: url(images/welcome/bg/connection04.png); - width: 56px; - height: 752px; - position: absolute; - bottom: -143px; - right: 946px; - } - - .asdc-welcome-frame.frame-04 .asdc-welcome-frame-shape { - background-image: url(images/welcome/bg/shape04.png); - position: absolute; - height: 412px; - width: 355px; - top: 0; - right: 734px; - z-index: 1; - visibility: hidden; - - animation-duration: @zoom-in-animation; - -moz-animation-duration: @zoom-in-animation; - -webkit-animation-duration: @zoom-in-animation; - } - - .asdc-welcome-frame.frame-05 .asdc-welcome-slide-text-box { - position: absolute; - top: 29%; - right: 10%; - z-index: 5; - } - - .asdc-welcome-frame.frame-05 .asdc-welcome-frame-shape { - background-image: url(images/welcome/bg/shape05.png); - position: absolute; - height: 794px; - width: 597px; - top: 0; - right: 40%; - z-index: 1; - visibility: hidden; - - animation-duration: @zoom-in-animation; - -moz-animation-duration: @zoom-in-animation; - -webkit-animation-duration: @zoom-in-animation; - } - - .asdc-welcome-frame.frame-06 { - background-image: url(images/welcome/bg/004.png); - background-size: cover; - } - - .asdc-welcome-frame.frame-06 .asdc-welcome-main { - bottom: 30%; - } - - .asdc-welcome-header { - /*background-color: rgba(17, 21, 33, 0.52);*/ - height: 70px; - width: 100%; - padding: 55px 0 0 65px; - color: #fff; - z-index: 1; - position: absolute; - left: 0; - top: 0; - } - - .welcome-nav { - visibility: hidden; - } - - .welcome-logo { - cursor: pointer; - } - - #sdc-welcome-video-wrapper { - opacity: 0; - } - - .asdc-welcome-video-close { - position: absolute; - top: 30px; - right: 30px; - z-index: 1; - } - - .asdc-welcome-video { - position: fixed; - top: 50%; - left: 50%; - min-width: 100%; - min-height: 100%; - width: auto; - height: auto; - -webkit-transform: translateX(-50%) translateY(-50%); - transform: translateX(-50%) translateY(-50%); - } - - .asdc-welcome-video-icon { - cursor: pointer; - /*margin-bottom: 80px;*/ - visibility: hidden; - width: 140px; - margin: 0 auto; - right: -24px; - position: relative; - - animation-duration: @zoom-in-animation-play; - -moz-animation-duration: @zoom-in-animation-play; - -webkit-animation-duration: @zoom-in-animation-play; - - .asdc-welcome-video-icon-play { - position: absolute; - top: -11px; - left: -11px; - z-index: 1; - } - - .asdc-welcome-video-icon-play:hover + .asdc-welcome-inner-circle { - -webkit-animation-play-state: running; - -moz-animation-play-state: running; - animation-play-state: running; - - -webkit-transform: rotate(360deg); - -moz-transform: rotate(360deg); - transform: rotate(360deg); - - -webkit-animation:turning_acw 3s; - -moz-animation:turning_acw 3s; - animation:turning_acw 3s; - - -webkit-animation-iteration-count: 99; - -moz-animation-iteration-count: 99; - animation-iteration-count: 99; - } - - .asdc-welcome-inner-circle { - border: 2px solid #ECEBFA; - border-left-color:#666666; - border-right-color:#999999; - .opacity(0.5); - - -webkit-transform: rotate(360deg); - -moz-transform: rotate(360deg); - transform: rotate(360deg); - - position:absolute; - - width: 96px; - height: 96px; - - .border-radius(96px); - - -webkit-animation:turning_acw 3s; - -moz-animation:turning_acw 3s; - animation:turning_acw 3s; - - -webkit-animation-iteration-count: 3; - -moz-animation-iteration-count: 3; - animation-iteration-count: 3; - } - } - - /*@-webkit-keyframes turning_acw { - 0%{ - -webkit-transform: rotate(360deg); } - 100%{ - -webkit-transform: rotate(0deg); } - } - - @-moz-keyframes turning_acw { - 0%{ - -moz-transform: rotate(360deg); } - 100%{ - -moz-transform: rotate(0deg); } - }*/ - - @keyframes turning_acw { - 0%{ - transform: rotate(360deg); } - 100%{ - transform: rotate(0deg); } - } - - .asdc-welcome-title { - color: #373f51; - font-size: 2.4vw; - font-family: omnes-light; - line-height: 1.0em; - letter-spacing: -0.01em; - } - - .asdc-welcome-main { - text-align: center; - position: absolute; - bottom: 40%; - z-index: 1; - color: #fff; - left: 0; - width: 100%; - } - - .whats-new { - .p_16_r; - position: absolute; - left: 205px; - top: 45px; - cursor: pointer; - text-decoration: none; - } - - .asdc-welcome-main-title { - color: #fff; - font-size: 62px; - font-family: omnes-light; - visibility: hidden; - height: 72px; - - animation-duration: @slide-fade-in-text-main-animation; - -moz-animation-duration: @slide-fade-in-text-main-animation; - -webkit-animation-duration: @slide-fade-in-text-main-animation; - } - - .asdc-welcome-main-message { - font-size: 28px; - font-family: omnes-light; - line-height: 1.8em; - visibility: hidden; - - animation-duration: @slide-fade-in-text-main-animation; - -moz-animation-duration: @slide-fade-in-text-main-animation; - -webkit-animation-duration: @slide-fade-in-text-main-animation; - } - - .asdc-welcome-main-back-btn-ph { - margin: 24px 0 70px; - } - - .asdc-welcome-main-back-btn { - font-size: 16px; - color: #009fdb; - font-family: omnes-medium; - border: 2px solid; - border-radius: 3px; - line-height: 40px; - min-width: 242px; - display: inline-block; - visibility: hidden; - text-decoration: none; - - &:hover { - color: #33bfec; - border-color: #33bfec; - } - } - - .asdc-welcome-cover { - position: absolute; - top: 0px; - right: 0; - left: 0; - bottom: 0; - background-color: rgba(14, 13, 12, 0.8); - z-index: 0; - } - - .asdc-welcome-slide-text-box { - border-radius: 10px; - background-color: #fff; - padding: 10px; - } - - .asdc-welcome-slide-text-box-title { - color: #373f51; - font-size: 2.4vw; - font-family: omnes-light; - letter-spacing: -0.015em; - line-height: 1.04em; - visibility: hidden; - - animation-duration: @slide-fade-in-text-main-animation; - -moz-animation-duration: @slide-fade-in-text-main-animation; - -webkit-animation-duration: @slide-fade-in-text-main-animation; - } - - .asdc-welcome-slide-text-box-content { - color: #737b81; - font-size: 1vw; - font-family: omnes-light; - padding-top: .5vw; - line-height: 1.3em; - visibility: hidden; - - animation-duration: @slide-fade-in-text-main-animation; - -moz-animation-duration: @slide-fade-in-text-main-animation; - -webkit-animation-duration: @slide-fade-in-text-main-animation; - } - - .asdc-welcome-slide-image-box { - box-shadow: 1px 1px 5px 0px rgba(0, 0, 0, 0.2); - height: 29.6vw; - width: 40vw; - } - - .asdc-welcome-slide-image { - height: 100%; - width: 100%; - } - - /*.asdc-welcome-frame-content {*/ - /*display: flex;*/ - /*justify-content: center;*/ - /*align-items: center;*/ - /*}*/ - /*.asdc-welcome-frame-content-text {*/ - /*color: #666;*/ - /*font-size: 16px;*/ - /*font-family: omnes-light;*/ - /*margin-top: 30px;*/ - /*line-height: 1.6em;*/ - /*}*/ - /*.asdc-welcome-frame-content-text-p {*/ - /*position: relative;*/ - /*}*/ - /*.asdc-welcome-frame-content-text-p-icon {*/ - /*position: absolute;*/ - /*height: 25px;*/ - /*width: 25px;*/ - /*left: -40px;*/ - /*top: 10px;*/ - /*}*/ - /*.asdc-welcome-frame.frame-02 .asdc-welcome-frame-content-right,*/ - /*.asdc-welcome-frame.frame-04 .asdc-welcome-frame-content-right {*/ - /*max-width: 30%;*/ - /*flex: 1;*/ - /*margin-left: 5%;*/ - /*}*/ - /*.asdc-welcome-frame.frame-02 .asdc-welcome-frame-content-left,*/ - /*.asdc-welcome-frame.frame-04 .asdc-welcome-frame-content-left {*/ - /*max-width: 55%;*/ - /*flex: 1;*/ - /*}*/ - /*.asdc-welcome-frame.frame-04 .asdc-welcome-frame-content-img {*/ - /*width: 36vw;*/ - /*}*/ - /*.asdc-welcome-frame.frame-03 .asdc-welcome-frame-content-left {*/ - /*max-width: 30%;*/ - /*flex: 1;*/ - /*margin-right: 5%;*/ - /*}*/ - /*.asdc-welcome-frame.frame-03 .asdc-welcome-frame-content-right {*/ - /*max-width: 55%;*/ - /*flex: 1;*/ - /*}*/ - /*.asdc-welcome-frame.frame-03 .asdc-welcome-frame-content-img {*/ - /*left: 0;*/ - /*right: auto;*/ - /*}*/ - /*.asdc-welcome-frame.frame-03 .asdc-welcome-frame-content-img-bubble {*/ - /*left: auto;*/ - /*top: 0;*/ - /*position: absolute;*/ - /*right: 0;*/ - /*top: -7vh;*/ - /*}*/ - /*.asdc-welcome-frame.frame-05 .asdc-welcome-frame-content{*/ - /*color: #fff;*/ - /*font-size: 37px;*/ - /*font-family: omnes-light;*/ - /*flex-direction: column;*/ - /*}*/ - /*.asdc-welcome-frame-content-img-ph {*/ - /*position: relative;*/ - /*!*width: 42%*!*/ - /*!*width: 840px;*!*/ - /*!*height: 674px;*!*/ - /*width: 52vw;*/ - /*height: 39vw;*/ - /*}*/ - /*.asdc-welcome-frame-content-img {*/ - /*width: 45vw;*/ - /*position: absolute;*/ - /*z-index: 1;*/ - /*right: 0;*/ - /*bottom: 0;*/ - /*}*/ - /*.asdc-welcome-frame-content-img-bubble {*/ - /*border-radius: 50%;*/ - /*height: 38vw;*/ - /*width: 38vw;*/ - /*position: absolute;*/ - /*left: 0;*/ - /*top: 0;*/ - /*position: absolute;*/ - /*right: 0;*/ - /*top: -7vh;*/ - /*}*/ - /*.asdc-welcome-frame-content-img-bubble.blue {*/ - /*background: linear-gradient(to right, #067ab4 0%, #44c8f5 100%);*/ - /*}*/ - /*.asdc-welcome-frame-content-img-bubble.green {*/ - /*background: linear-gradient(to right, #77be46 0%, #d2e15f 100%);*/ - /*}*/ - /*.asdc-welcome-frame-content-img-bubble.purple {*/ - /*background: linear-gradient(to right, #8a559f 0%, #d6b7e5 100%);*/ - /*}*/ - /*.asdc-welcome-button {*/ - /*font-family: omnes-medium;*/ - /*font-size: 14px;*/ - /*background-color: #009fdb;*/ - /*text-decoration: none;*/ - /*border: 0;*/ - /*border-radius: 4px;*/ - /*color: #fff;*/ - /*text-align: center;*/ - /*line-height: 30px;*/ - /*min-width: 200px;*/ - /*margin-top: 50px;*/ - /*}*/ - .asdc-welcome-footer { - background-color: #000; - position: absolute; - bottom: 0; - width: 100%; - font-size: 12px; - padding: 20px 10%; - left: 0; - color: #fff; - text-align: center; - } - -} diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/.npmignore b/catalog-ui/app/third-party/ng-infinite-scroll/.npmignore deleted file mode 100644 index dcbd092327..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -compile/* -node_modules -.tmp diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/.travis.yml b/catalog-ui/app/third-party/ng-infinite-scroll/.travis.yml deleted file mode 100644 index ee95ccb343..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: node_js -node_js: - - 0.10 - -install: - - npm install - -before_script: - - npm install -g grunt-cli - -script: - - grunt test:protractor-travis diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/Gruntfile.coffee b/catalog-ui/app/third-party/ng-infinite-scroll/Gruntfile.coffee deleted file mode 100644 index a9b9405731..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/Gruntfile.coffee +++ /dev/null @@ -1,110 +0,0 @@ -module.exports = (grunt) -> - grunt.loadNpmTasks 'grunt-coffeelint' - grunt.loadNpmTasks 'grunt-contrib-clean' - grunt.loadNpmTasks 'grunt-contrib-coffee' - grunt.loadNpmTasks 'grunt-contrib-concat' - grunt.loadNpmTasks 'grunt-contrib-connect' - grunt.loadNpmTasks 'grunt-contrib-uglify' - grunt.loadNpmTasks 'grunt-protractor-runner' - - sauceUser = 'pomerantsevp' - sauceKey = '497ab04e-f31b-4a7b-9b18-ae3fbe023222' - - grunt.initConfig - pkg: grunt.file.readJSON 'package.json' - meta: - banner: '/* <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' - coffeelint: - src: 'src/**/*.coffee' - options: - max_line_length: - level: 'ignore' - line_endings: - value: 'unix' - level: 'error' - no_stand_alone_at: - level: 'error' - clean: - options: - force: true - build: ["compile/**", "build/**"] - coffee: - compile: - files: [ - { - expand: true - cwd: 'src/' - src: '**/*.coffee' - dest: 'compile/' - ext: '.js' - } - ], - options: - bare: true - concat: - options: - banner: '<%= meta.banner %>' - dist: - src: 'compile/**/*.js' - dest: 'build/ng-infinite-scroll.js' - uglify: - options: - banner: '<%= meta.banner %>' - dist: - src: ['build/ng-infinite-scroll.js'] - dest: 'build/ng-infinite-scroll.min.js' - connect: - testserver: - options: - port: 8000 - hostname: '0.0.0.0' - middleware: (connect, options) -> - base = if Array.isArray(options.base) then options.base[options.base.length - 1] else options.base - [connect.static(base)] - protractor: - local: - options: - configFile: 'test/protractor-local.conf.js' - args: - params: - testThrottleValue: 500 - travis: - options: - configFile: 'test/protractor-travis.conf.js' - args: - params: - # When using Sauce Connect, we should use a large timeout - # since everything is generally much slower than when testing locally. - testThrottleValue: 10000 - sauceUser: sauceUser - sauceKey: sauceKey - - grunt.registerTask 'webdriver', () -> - done = this.async() - p = require('child_process').spawn('node', ['node_modules/protractor/bin/webdriver-manager', 'update']) - p.stdout.pipe(process.stdout) - p.stderr.pipe(process.stderr) - p.on 'exit', (code) -> - if code isnt 0 then grunt.fail.warn('Webdriver failed to update') - done() - - grunt.registerTask 'sauce-connect', () -> - done = this.async() - require('sauce-connect-launcher')({username: sauceUser, accessKey: sauceKey}, (err, sauceConnectProcess) -> - if err then console.error(err.message) - else done() - ) - - grunt.registerTask 'default', ['coffeelint', 'clean', 'coffee', 'concat', 'uglify'] - grunt.registerTask 'test:protractor-local', [ - 'default', - 'webdriver', - 'connect:testserver', - 'protractor:local' - ] - - grunt.registerTask 'test:protractor-travis', [ - 'connect:testserver', - 'sauce-connect', - 'protractor:travis' - ] diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/LICENSE b/catalog-ui/app/third-party/ng-infinite-scroll/LICENSE deleted file mode 100644 index 44ae2bfc40..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2012 Michelle Tilley - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/README.md b/catalog-ui/app/third-party/ng-infinite-scroll/README.md deleted file mode 100644 index aa8d8630e2..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/README.md +++ /dev/null @@ -1,71 +0,0 @@ -[**Maintainer help needed**: I'm looking for fellows that are willing to help me maintain and improve this project.](https://github.com/sroze/ngInfiniteScroll/issues/267) - ---- - -![logo](http://sroze.github.com/ngInfiniteScroll/images/logo-resized.png) - -[![Build Status](https://travis-ci.org/sroze/ngInfiniteScroll.png?branch=master)](https://travis-ci.org/sroze/ngInfiniteScroll) - -ngInfiniteScroll is a directive for [AngularJS](http://angularjs.org/) to evaluate an expression when the bottom of the directive's element approaches the bottom of the browser window, which can be used to implement infinite scrolling. - -Demos ------ - -Check out the running demos [at the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/demos.html). - -Version Numbers ---------------- - -ngInfinite Scroll follows [semantic versioning](http://semver.org/) and uses the following versioning scheme: - - * Versions starting with 0 (e.g. 0.1.0, 0.2.0, etc.) are for initial development, and the API is not stable - * Versions with an even minor version (1.0.0, 1.4.0, 2.2.0, etc.) are stable releases - * Versions with an odd minor version (1.1.0, 1.3.0, 2.1.0, etc.) are development releases - -The [download page](http://sroze.github.com/ngInfiniteScroll/#download) allows you to pick among various versions and specify which releases are stable (not including pre-release builds). - -Getting Started ---------------- - - * Download ngInfiniteScroll from [the download page on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/#download) or install it with: - * [Bower](http://bower.io/) via `bower install ngInfiniteScroll` - * [NPM](https://www.npmjs.com) via `npm install --save ng-infinite-scroll` - * [Nuget](https://www.nuget.org) via `PM> Install-Package ng-infinite-scroll` - * Include the script tag on your page after the AngularJS script tag (ngInfiniteScroll *doesn't* require jQuery) - - <script type='text/javascript' src='path/to/angular.min.js'></script> - <script type='text/javascript' src='path/to/ng-infinite-scroll.min.js'></script> - - * Ensure that your application module specifies `infinite-scroll` as a dependency: - - angular.module('myApplication', ['infinite-scroll']); - - * Use the directive by specifying an `infinite-scroll` attribute on an element. - - <div infinite-scroll="myPagingFunction()" infinite-scroll-distance="3"></div> - -Note that neither the module nor the directive use the `ng` prefix, as that prefix is reserved for the core Angular module. - -Detailed Documentation ----------------------- - -ngInfiniteScroll accepts several attributes to customize the behavior of the directive; detailed instructions can be found [on the ngInfiniteScroll web site](http://sroze.github.com/ngInfiniteScroll/documentation.html). - -Ports ------ - -If you use [AngularDart](https://github.com/angular/angular.dart), Juha Komulainen has [a port of the project](http://pub.dartlang.org/packages/ng_infinite_scroll) you can use. - -License -------- - -ngInfiniteScroll is licensed under the MIT license. See the LICENSE file for more details. - -Testing -------- - -ngInfiniteScroll uses Protractor for testing. Note that you will need to have Chrome browser, and the `grunt-cli` npm package installed globally if you wish to use grunt (`npm install -g grunt-cli`). Then, install the dependencies with `npm install`. - -* `grunt test:protractor-local` - run tests - -Thank you very much @pomerantsev for your work on these Protractor tests. diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/bower.json b/catalog-ui/app/third-party/ng-infinite-scroll/bower.json deleted file mode 100644 index 1171c45190..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/bower.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "ngInfiniteScroll", - "main": "build/ng-infinite-scroll.js", - "ignore": [ - "**/.*", - "_*", - "node_modules", - "compile", - "test", - "Gruntfile.coffee", - ".*" - ], - "dependencies": { - "angular": ">=1.2.0" - } -} diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.js b/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.js deleted file mode 100644 index 0585004832..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.js +++ /dev/null @@ -1,209 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -/* ng-infinite-scroll - v1.3.0 - 2016-06-30 */ -angular.module('infinite-scroll', []).value('THROTTLE_MILLISECONDS', null).directive('infiniteScroll', [ - '$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', function($rootScope, $window, $interval, THROTTLE_MILLISECONDS) { - return { - scope: { - infiniteScroll: '&', - infiniteScrollContainer: '=', - infiniteScrollDistance: '=', - infiniteScrollDisabled: '=', - infiniteScrollUseDocumentBottom: '=', - infiniteScrollListenForEvent: '@' - }, - link: function(scope, elem, attrs) { - var changeContainer, checkInterval, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, unregisterEventListener, useDocumentBottom, windowElement; - windowElement = angular.element($window); - scrollDistance = null; - scrollEnabled = null; - checkWhenEnabled = null; - container = null; - immediateCheck = true; - useDocumentBottom = false; - unregisterEventListener = null; - checkInterval = false; - height = function(elem) { - elem = elem[0] || elem; - if (isNaN(elem.offsetHeight)) { - return elem.document.documentElement.clientHeight; - } else { - return elem.offsetHeight; - } - }; - offsetTop = function(elem) { - if (!elem[0].getBoundingClientRect || elem.css('none')) { - return; - } - return elem[0].getBoundingClientRect().top + pageYOffset(elem); - }; - pageYOffset = function(elem) { - elem = elem[0] || elem; - if (isNaN(window.pageYOffset)) { - return elem.document.documentElement.scrollTop; - } else { - return elem.ownerDocument.defaultView.pageYOffset; - } - }; - handler = function() { - var containerBottom, containerTopOffset, elementBottom, remaining, shouldScroll; - if (container === windowElement) { - containerBottom = height(container) + pageYOffset(container[0].document.documentElement); - elementBottom = offsetTop(elem) + height(elem); - } else { - containerBottom = height(container); - containerTopOffset = 0; - if (offsetTop(container) !== void 0) { - containerTopOffset = offsetTop(container); - } - elementBottom = offsetTop(elem) - containerTopOffset + height(elem); - } - if (useDocumentBottom) { - elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement); - } - remaining = elementBottom - containerBottom; - shouldScroll = remaining <= height(container) * scrollDistance + 1; - if (shouldScroll) { - checkWhenEnabled = true; - if (scrollEnabled) { - if (scope.$$phase || $rootScope.$$phase) { - return scope.infiniteScroll(); - } else { - return scope.$apply(scope.infiniteScroll); - } - } - } else { - if (checkInterval) { - $interval.cancel(checkInterval); - } - return checkWhenEnabled = false; - } - }; - throttle = function(func, wait) { - var later, previous, timeout; - timeout = null; - previous = 0; - later = function() { - previous = new Date().getTime(); - $interval.cancel(timeout); - timeout = null; - return func.call(); - }; - return function() { - var now, remaining; - now = new Date().getTime(); - remaining = wait - (now - previous); - if (remaining <= 0) { - $interval.cancel(timeout); - timeout = null; - previous = now; - return func.call(); - } else { - if (!timeout) { - return timeout = $interval(later, remaining, 1); - } - } - }; - }; - if (THROTTLE_MILLISECONDS != null) { - handler = throttle(handler, THROTTLE_MILLISECONDS); - } - scope.$on('$destroy', function() { - container.unbind('scroll', handler); - if (unregisterEventListener != null) { - unregisterEventListener(); - unregisterEventListener = null; - } - if (checkInterval) { - return $interval.cancel(checkInterval); - } - }); - handleInfiniteScrollDistance = function(v) { - return scrollDistance = parseFloat(v) || 0; - }; - scope.$watch('infiniteScrollDistance', handleInfiniteScrollDistance); - handleInfiniteScrollDistance(scope.infiniteScrollDistance); - handleInfiniteScrollDisabled = function(v) { - scrollEnabled = !v; - if (scrollEnabled && checkWhenEnabled) { - checkWhenEnabled = false; - return handler(); - } - }; - scope.$watch('infiniteScrollDisabled', handleInfiniteScrollDisabled); - handleInfiniteScrollDisabled(scope.infiniteScrollDisabled); - handleInfiniteScrollUseDocumentBottom = function(v) { - return useDocumentBottom = v; - }; - scope.$watch('infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom); - handleInfiniteScrollUseDocumentBottom(scope.infiniteScrollUseDocumentBottom); - changeContainer = function(newContainer) { - if (container != null) { - container.unbind('scroll', handler); - } - container = newContainer; - if (newContainer != null) { - return container.bind('scroll', handler); - } - }; - changeContainer(windowElement); - if (scope.infiniteScrollListenForEvent) { - unregisterEventListener = $rootScope.$on(scope.infiniteScrollListenForEvent, handler); - } - handleInfiniteScrollContainer = function(newContainer) { - if ((newContainer == null) || newContainer.length === 0) { - return; - } - if (newContainer.nodeType && newContainer.nodeType === 1) { - newContainer = angular.element(newContainer); - } else if (typeof newContainer.append === 'function') { - newContainer = angular.element(newContainer[newContainer.length - 1]); - } else if (typeof newContainer === 'string') { - newContainer = angular.element(document.querySelector(newContainer)); - } - if (newContainer != null) { - return changeContainer(newContainer); - } else { - throw new Error("invalid infinite-scroll-container attribute."); - } - }; - scope.$watch('infiniteScrollContainer', handleInfiniteScrollContainer); - handleInfiniteScrollContainer(scope.infiniteScrollContainer || []); - if (attrs.infiniteScrollParent != null) { - changeContainer(angular.element(elem.parent())); - } - if (attrs.infiniteScrollImmediateCheck != null) { - immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck); - } - return checkInterval = $interval((function() { - if (immediateCheck) { - handler(); - } - return $interval.cancel(checkInterval); - })); - } - }; - } -]); - -if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports) { - module.exports = 'infinite-scroll'; -} diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.min.js b/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.min.js deleted file mode 100644 index e2a3036422..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/build/ng-infinite-scroll.min.js +++ /dev/null @@ -1,22 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -/* ng-infinite-scroll - v1.3.0 - 2016-06-30 */ -angular.module("infinite-scroll",[]).value("THROTTLE_MILLISECONDS",null).directive("infiniteScroll",["$rootScope","$window","$interval","THROTTLE_MILLISECONDS",function(a,b,c,d){return{scope:{infiniteScroll:"&",infiniteScrollContainer:"=",infiniteScrollDistance:"=",infiniteScrollDisabled:"=",infiniteScrollUseDocumentBottom:"=",infiniteScrollListenForEvent:"@"},link:function(e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return z=angular.element(b),u=null,v=null,j=null,k=null,r=!0,y=!1,x=null,i=!1,q=function(a){return a=a[0]||a,isNaN(a.offsetHeight)?a.document.documentElement.clientHeight:a.offsetHeight},s=function(a){if(a[0].getBoundingClientRect&&!a.css("none"))return a[0].getBoundingClientRect().top+t(a)},t=function(a){return a=a[0]||a,isNaN(window.pageYOffset)?a.document.documentElement.scrollTop:a.ownerDocument.defaultView.pageYOffset},p=function(){var b,d,g,h,l;return k===z?(b=q(k)+t(k[0].document.documentElement),g=s(f)+q(f)):(b=q(k),d=0,void 0!==s(k)&&(d=s(k)),g=s(f)-d+q(f)),y&&(g=q((f[0].ownerDocument||f[0].document).documentElement)),h=g-b,l=h<=q(k)*u+1,l?(j=!0,v?e.$$phase||a.$$phase?e.infiniteScroll():e.$apply(e.infiniteScroll):void 0):(i&&c.cancel(i),j=!1)},w=function(a,b){var d,e,f;return f=null,e=0,d=function(){return e=(new Date).getTime(),c.cancel(f),f=null,a.call()},function(){var g,h;return g=(new Date).getTime(),h=b-(g-e),h<=0?(c.cancel(f),f=null,e=g,a.call()):f?void 0:f=c(d,h,1)}},null!=d&&(p=w(p,d)),e.$on("$destroy",function(){if(k.unbind("scroll",p),null!=x&&(x(),x=null),i)return c.cancel(i)}),n=function(a){return u=parseFloat(a)||0},e.$watch("infiniteScrollDistance",n),n(e.infiniteScrollDistance),m=function(a){if(v=!a,v&&j)return j=!1,p()},e.$watch("infiniteScrollDisabled",m),m(e.infiniteScrollDisabled),o=function(a){return y=a},e.$watch("infiniteScrollUseDocumentBottom",o),o(e.infiniteScrollUseDocumentBottom),h=function(a){if(null!=k&&k.unbind("scroll",p),k=a,null!=a)return k.bind("scroll",p)},h(z),e.infiniteScrollListenForEvent&&(x=a.$on(e.infiniteScrollListenForEvent,p)),l=function(a){if(null!=a&&0!==a.length){if(a.nodeType&&1===a.nodeType?a=angular.element(a):"function"==typeof a.append?a=angular.element(a[a.length-1]):"string"==typeof a&&(a=angular.element(document.querySelector(a))),null!=a)return h(a);throw new Error("invalid infinite-scroll-container attribute.")}},e.$watch("infiniteScrollContainer",l),l(e.infiniteScrollContainer||[]),null!=g.infiniteScrollParent&&h(angular.element(f.parent())),null!=g.infiniteScrollImmediateCheck&&(r=e.$eval(g.infiniteScrollImmediateCheck)),i=c(function(){return r&&p(),c.cancel(i)})}}}]),"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="infinite-scroll"); diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/package.json b/catalog-ui/app/third-party/ng-infinite-scroll/package.json deleted file mode 100644 index 8859faecdc..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/package.json +++ /dev/null @@ -1,80 +0,0 @@ -{ - "name": "ng-infinite-scroll", - "version": "1.3.0", - "description": "Infinite scrolling for AngularJS", - "repository": { - "type": "git", - "url": "git://github.com/sroze/ngInfiniteScroll.git" - }, - "main": "build/ng-infinite-scroll.js", - "browser": "build/ng-infinite-scroll.js", - "scripts": { - "test": "grunt test:protractor-local" - }, - "author": { - "name": "Michelle Tilley", - "email": "michelle@michelletilley.net", - "url": "http://michelletilley.net" - }, - "contributors": [ - { - "name": "Samuel ROZE", - "email": "samuel.roze@gmail.com", - "url": "http://sroze.io" - } - ], - "license": "MIT", - "devDependencies": { - "coffee-script": "~1.8.0", - "grunt": "~0.4.5", - "grunt-coffeelint": "~0.0.13", - "grunt-contrib-clean": "~0.6.0", - "grunt-contrib-coffee": "~0.12.0", - "grunt-contrib-concat": "~0.5.0", - "grunt-contrib-connect": "0.8.0", - "grunt-contrib-uglify": "~0.6.0", - "grunt-protractor-runner": "1.1.4", - "mkdirp": "0.5.0", - "protractor": "1.4.0", - "sauce-connect-launcher": "0.9.0" - }, - "gitHead": "6fbf4b41947f9a3023b4aba0e613231950ccc4a1", - "bugs": { - "url": "https://github.com/sroze/ngInfiniteScroll/issues" - }, - "homepage": "https://github.com/sroze/ngInfiniteScroll#readme", - "_id": "ng-infinite-scroll@1.3.0", - "_shasum": "c2e98d8fd134b0525a4d2cf58c95d9b583755112", - "_from": "ng-infinite-scroll@>=1.3.0 <2.0.0", - "_npmVersion": "3.9.5", - "_nodeVersion": "6.2.2", - "_npmUser": { - "name": "graingert", - "email": "tagrain@gmail.com" - }, - "dist": { - "shasum": "c2e98d8fd134b0525a4d2cf58c95d9b583755112", - "tarball": "https://registry.npmjs.org/ng-infinite-scroll/-/ng-infinite-scroll-1.3.0.tgz" - }, - "maintainers": [ - { - "name": "binarymuse", - "email": "michelle@michelletilley.net" - }, - { - "name": "graingert", - "email": "tagrain@gmail.com" - }, - { - "name": "sroze", - "email": "samuel.roze@gmail.com" - } - ], - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/ng-infinite-scroll-1.3.0.tgz_1467302375605_0.8192659560590982" - }, - "directories": {}, - "_resolved": "https://registry.npmjs.org/ng-infinite-scroll/-/ng-infinite-scroll-1.3.0.tgz", - "readme": "ERROR: No README data found!" -} diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/src/infinite-scroll.coffee b/catalog-ui/app/third-party/ng-infinite-scroll/src/infinite-scroll.coffee deleted file mode 100644 index cf2f90fc19..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/src/infinite-scroll.coffee +++ /dev/null @@ -1,209 +0,0 @@ -angular.module('infinite-scroll', []) - .value('THROTTLE_MILLISECONDS', null) - .directive 'infiniteScroll', [ - '$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', -($rootScope, $window, $interval, THROTTLE_MILLISECONDS) -> - scope: - infiniteScroll: '&' - infiniteScrollContainer: '=' - infiniteScrollDistance: '=' - infiniteScrollDisabled: '=' - infiniteScrollUseDocumentBottom: '=', - infiniteScrollListenForEvent: '@' - - link: (scope, elem, attrs) -> - windowElement = angular.element($window) - - scrollDistance = null - scrollEnabled = null - checkWhenEnabled = null - container = null - immediateCheck = true - useDocumentBottom = false - unregisterEventListener = null - checkInterval = false - - height = (elem) -> - elem = elem[0] or elem - - if isNaN(elem.offsetHeight) then elem.document.documentElement.clientHeight else elem.offsetHeight - - offsetTop = (elem) -> - if not elem[0].getBoundingClientRect or elem.css('none') - return - - elem[0].getBoundingClientRect().top + pageYOffset(elem) - - pageYOffset = (elem) -> - elem = elem[0] or elem - - if isNaN(window.pageYOffset) then elem.document.documentElement.scrollTop else elem.ownerDocument.defaultView.pageYOffset - - # infinite-scroll specifies a function to call when the window, - # or some other container specified by infinite-scroll-container, - # is scrolled within a certain range from the bottom of the - # document. It is recommended to use infinite-scroll-disabled - # with a boolean that is set to true when the function is - # called in order to throttle the function call. - handler = -> - if container == windowElement - containerBottom = height(container) + pageYOffset(container[0].document.documentElement) - elementBottom = offsetTop(elem) + height(elem) - else - containerBottom = height(container) - containerTopOffset = 0 - if offsetTop(container) != undefined - containerTopOffset = offsetTop(container) - elementBottom = offsetTop(elem) - containerTopOffset + height(elem) - - if(useDocumentBottom) - elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement) - - remaining = elementBottom - containerBottom - shouldScroll = remaining <= height(container) * scrollDistance + 1 - - if shouldScroll - checkWhenEnabled = true - - if scrollEnabled - if scope.$$phase || $rootScope.$$phase - scope.infiniteScroll() - else - scope.$apply(scope.infiniteScroll) - else - if checkInterval then $interval.cancel checkInterval - checkWhenEnabled = false - - # The optional THROTTLE_MILLISECONDS configuration value specifies - # a minimum time that should elapse between each call to the - # handler. N.b. the first call the handler will be run - # immediately, and the final call will always result in the - # handler being called after the `wait` period elapses. - # A slimmed down version of underscore's implementation. - throttle = (func, wait) -> - timeout = null - previous = 0 - later = -> - previous = new Date().getTime() - $interval.cancel(timeout) - timeout = null - func.call() - - return -> - now = new Date().getTime() - remaining = wait - (now - previous) - if remaining <= 0 - $interval.cancel(timeout) - timeout = null - previous = now - func.call() - else timeout = $interval(later, remaining, 1) unless timeout - - if THROTTLE_MILLISECONDS? - handler = throttle(handler, THROTTLE_MILLISECONDS) - - scope.$on '$destroy', -> - container.unbind 'scroll', handler - if unregisterEventListener? - unregisterEventListener() - unregisterEventListener = null - if checkInterval - $interval.cancel checkInterval - - # infinite-scroll-distance specifies how close to the bottom of the page - # the window is allowed to be before we trigger a new scroll. The value - # provided is multiplied by the container height; for example, to load - # more when the bottom of the page is less than 3 container heights away, - # specify a value of 3. Defaults to 0. - handleInfiniteScrollDistance = (v) -> - scrollDistance = parseFloat(v) or 0 - - scope.$watch 'infiniteScrollDistance', handleInfiniteScrollDistance - # If I don't explicitly call the handler here, tests fail. Don't know why yet. - handleInfiniteScrollDistance scope.infiniteScrollDistance - - # infinite-scroll-disabled specifies a boolean that will keep the - # infnite scroll function from being called; this is useful for - # debouncing or throttling the function call. If an infinite - # scroll is triggered but this value evaluates to true, then - # once it switches back to false the infinite scroll function - # will be triggered again. - handleInfiniteScrollDisabled = (v) -> - scrollEnabled = !v - if scrollEnabled && checkWhenEnabled - checkWhenEnabled = false - handler() - - scope.$watch 'infiniteScrollDisabled', handleInfiniteScrollDisabled - # If I don't explicitly call the handler here, tests fail. Don't know why yet. - handleInfiniteScrollDisabled scope.infiniteScrollDisabled - - # use the bottom of the document instead of the element's bottom. - # This useful when the element does not have a height due to its - # children being absolute positioned. - handleInfiniteScrollUseDocumentBottom = (v) -> - useDocumentBottom = v - - scope.$watch 'infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom - handleInfiniteScrollUseDocumentBottom scope.infiniteScrollUseDocumentBottom - - # infinite-scroll-container sets the container which we want to be - # infinte scrolled, instead of the whole window. Must be an - # Angular or jQuery element, or, if jQuery is loaded, - # a jQuery selector as a string. - changeContainer = (newContainer) -> - if container? - container.unbind 'scroll', handler - - container = newContainer - if newContainer? - container.bind 'scroll', handler - - changeContainer windowElement - - if scope.infiniteScrollListenForEvent - unregisterEventListener = $rootScope.$on scope.infiniteScrollListenForEvent, handler - - handleInfiniteScrollContainer = (newContainer) -> - # TODO: For some reason newContainer is sometimes null instead - # of the empty array, which Angular is supposed to pass when the - # element is not defined - # (https://github.com/sroze/ngInfiniteScroll/pull/7#commitcomment-5748431). - # So I leave both checks. - if (not newContainer?) or newContainer.length == 0 - return - - if newContainer.nodeType && newContainer.nodeType == 1 - newContainer = angular.element newContainer - else if typeof newContainer.append == 'function' - newContainer = angular.element newContainer[newContainer.length - 1] - else if typeof newContainer == 'string' - newContainer = angular.element document.querySelector newContainer - - if newContainer? - changeContainer newContainer - else - throw new Error("invalid infinite-scroll-container attribute.") - - scope.$watch 'infiniteScrollContainer', handleInfiniteScrollContainer - handleInfiniteScrollContainer(scope.infiniteScrollContainer or []) - - # infinite-scroll-parent establishes this element's parent as the - # container infinitely scrolled instead of the whole window. - if attrs.infiniteScrollParent? - changeContainer angular.element elem.parent() - - # infinte-scoll-immediate-check sets whether or not run the - # expression passed on infinite-scroll for the first time when the - # directive first loads, before any actual scroll. - if attrs.infiniteScrollImmediateCheck? - immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck) - - checkInterval = $interval (-> - if immediateCheck - handler() - $interval.cancel checkInterval - ) -] -if typeof module != "undefined" && typeof exports != "undefined" && module.exports == exports - module.exports = 'infinite-scroll' diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js deleted file mode 100644 index 134c723f91..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js +++ /dev/null @@ -1,27 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var config = require('./protractor-shared.conf').config; - -config.multiCapabilities = [ - { browserName: 'chrome' } -]; - -exports.config = config; diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js deleted file mode 100644 index d1e567d7b4..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -exports.config = { - specs: ['**/*.spec.coffee'], - baseUrl: 'http://localhost:8000/', - allScriptsTimeout: 30000, - getPageTimeout: 30000 -}; diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js deleted file mode 100644 index 54fe0bd828..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js +++ /dev/null @@ -1,32 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var config = require('./protractor-shared.conf').config; - -// All available platform / browser combinations can be found on https://saucelabs.com/platforms -config.multiCapabilities = [ - { - browserName: 'chrome', - platform: 'OS X 10.10', - version: '37' - } -]; - -exports.config = config; diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee b/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee deleted file mode 100644 index 07e6fec8be..0000000000 --- a/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee +++ /dev/null @@ -1,221 +0,0 @@ -fs = require "fs" -mkdirp = require "mkdirp" - -getTemplate = (angularVersion, container, attrs, throttle) -> - """ - <!doctype html> - <head> - <style> - html, body { - height: 100%; - } - </style> - <script src='http://ajax.googleapis.com/ajax/libs/angularjs/#{angularVersion}/angular.min.js'></script> - <script src="../../build/ng-infinite-scroll.js"></script> - <script> - angular.module('app', ['infinite-scroll']) - .config(function ($provide) { - $provide.value('THROTTLE_MILLISECONDS', #{throttle}); - }) - .run(function ($rootScope) { - $rootScope.items = []; - $rootScope.loadMore = function () { - [].push.apply($rootScope.items, new Array(100)); - }; - - $rootScope.busy = true; - - $rootScope.enable = function () { - $rootScope.busy = false; - }; - - $rootScope.triggerEvent = function () { - $rootScope.$emit('anEvent'); - }; - }); - </script> - </head> - <body ng-app="app"> - <a id="action" ng-click="enable()">Enable</a> - <a id="force" ng-click="loadMore()">Force</a> - <a id="trigger" ng-click="triggerEvent()">Trigger</a> - #{containers[container].start} - <div infinite-scroll="loadMore()" #{containers[container].attr} #{attrs}> - <p ng-repeat='item in items track by $index'> - {{$index}} - </p> - </div> - #{containers[container].end} - </body> - """ - -containers = - window: - start: "" - end: "" - attr: "" - parent: - start: "<div id='parent' style='height: 50%; overflow: auto;'>" - end: "</div>" - attr: "infinite-scroll-parent" - ancestor: - start: "<div id='ancestor' style='height: 50%; overflow: auto;'><div>" - end: "</div></div>" - attr: "infinite-scroll-container='\"#ancestor\"'" - -getElementByIdScript = (id) -> - "document.getElementById('#{id}')" - -calculateChildrenHeightScript = (id) -> - """ - [].concat.apply([], #{getElementByIdScript(id)}.childNodes) - .map(function (el) { return el.offsetHeight ? el.offsetHeight : 0; }) - .reduce(function (cur, prev) { return prev + cur; }, 0) - """ - -scrollToBottomScript = (container) -> - if container is "window" - "window.scrollTo(0, document.body.scrollHeight)" - else - "#{getElementByIdScript(container)}.scrollTop = #{calculateChildrenHeightScript(container)}" - -scrollToLastScreenScript = (container, offset) -> - # 2 * window.innerHeight means that the bottom of the screen should be somewhere close to - # body height - window height. That means that the top of the window is body height - 2 * window height. - if container is "window" - "window.scrollTo(0, document.body.scrollHeight - 2 * window.innerHeight + #{offset})" - else - """ - #{getElementByIdScript(container)}.scrollTop = - #{calculateChildrenHeightScript(container)} - 2 * #{getElementByIdScript(container)}.offsetHeight + #{offset} - """ - -collapseItemsScript = (container) -> - """ - var items = document.getElementsByTagName('p') - for (i = 0; i < items.length; ++i) { - items[i].style.display = 'none' - } - """ - -getItems = -> - element.all(By.repeater "item in items") - -tmpDir = ".tmp" -pathToDocument = "#{tmpDir}/index.html" - -describe "ng-infinite-scroll", -> - for angularVersion in ["1.2.0", "1.3.4"] - describe "with Angular #{angularVersion}", -> - for container in ["window", "ancestor", "parent"] - describe "with #{container} as container", -> - - replaceIndexFile = (attrs, throttle) -> - mkdirp tmpDir - fs.writeFileSync(pathToDocument, getTemplate(angularVersion, container, attrs, throttle)) - - describe "without throttling", -> - - throttle = null - - it "should be triggered immediately and when container is scrolled to the bottom", -> - replaceIndexFile "", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToBottomScript(container)) - expect(getItems().count()).toBe 200 - - it "does not trigger immediately when infinite-scroll-immediate-check is false", -> - replaceIndexFile "infinite-scroll-immediate-check='false'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 0 - element(By.id("force")).click() - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToBottomScript(container)) - expect(getItems().count()).toBe 200 - - it "respects the disabled attribute", -> - replaceIndexFile "infinite-scroll-disabled='busy'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 0 - element(By.id("action")).click() - expect(getItems().count()).toBe 100 - - it "respects the infinite-scroll-distance attribute", -> - replaceIndexFile "infinite-scroll-distance='1'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToLastScreenScript(container, -20)) - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToLastScreenScript(container, 20)) - expect(getItems().count()).toBe 200 - - describe "with an event handler", -> - - it "calls the event handler on an event", -> - replaceIndexFile "infinite-scroll-listen-for-event='anEvent'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(collapseItemsScript(container)) - expect(getItems().count()).toBe 100 - element(By.id("trigger")).click() - expect(getItems().count()).toBe 200 - - describe "with throttling", -> - - throttle = browser.params.testThrottleValue - - it "should be triggered immediately and when container is scrolled to the bottom", -> - replaceIndexFile "", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToBottomScript(container)) - expect(getItems().count()).toBe 100 - browser.sleep(throttle) - expect(getItems().count()).toBe 200 - - it "does not trigger immediately when infinite-scroll-immediate-check is false", -> - replaceIndexFile "infinite-scroll-immediate-check='false'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 0 - element(By.id("force")).click() - expect(getItems().count()).toBe 100 - - it "respects the disabled attribute and is throttled when page loads", -> - replaceIndexFile "infinite-scroll-disabled='busy'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 0 - element(By.id("action")).click() - expect(getItems().count()).toBe 0 - browser.sleep(throttle) - expect(getItems().count()).toBe 100 - - it "is not throttled when re-enabled if the throttle time has already elapsed", -> - replaceIndexFile "infinite-scroll-disabled='busy'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 0 - browser.sleep(throttle) - element(By.id("action")).click() - expect(getItems().count()).toBe 100 - - it "respects the infinite-scroll-distance attribute", -> - replaceIndexFile "infinite-scroll-distance='1'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(scrollToLastScreenScript(container, 20)) - expect(getItems().count()).toBe 100 - browser.sleep(throttle) - expect(getItems().count()).toBe 200 - - describe "with an event handler", -> - - it "calls the event handler on an event", -> - replaceIndexFile "infinite-scroll-listen-for-event='anEvent'", throttle - browser.get pathToDocument - expect(getItems().count()).toBe 100 - browser.driver.executeScript(collapseItemsScript(container)) - expect(getItems().count()).toBe 100 - element(By.id("trigger")).click() - expect(getItems().count()).toBe 100 - browser.sleep(throttle) - expect(getItems().count()).toBe 200 diff --git a/catalog-ui/bower dependecies b/catalog-ui/bower dependecies deleted file mode 100644 index 7a21bbcef7..0000000000 --- a/catalog-ui/bower dependecies +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "catalog-ui", - "private": true, - "dependencies": { - "angular": "~1.3.x", - "angular-base64": "~2.0.5", //for translate base 64 - "angular-base64-upload": "~0.1.8", //upload file base 64 - "angular-bootstrap": "~0.13.0", - "angular-dragdrop": "~1.0.11", //for drag & drop elements in canvas - "angular-filter": "~0.5.6", // for filter categories - "angular-md5": "~0.1.7", //translate from & to md5 - "angular-perfect-scrollbar": "~0.0.4", // fir design cross browser scrollbar - "angular-qtip2-directive": "~0.1.2", // for design tooltips - "angular-resource": "~1.3.15", // for restfully Api - "angular-sanitize": "~1.4.4", //https://docs.angularjs.org/api/ngSanitize/service/$sanitize - "angular-ui-router": "~0.2.14", - "angular-uuid4": "~0.3.0", - "bootstrap": "3.3.4", // dependency for angular bootstrap - "checklist-model": "~0.2.4", // for categories check list model - "jquery": "~1.11.1", - "lodash": "~3.7.0", // js utils functions - "angular-translate": "~2.8.0", // dependencies for language support - "angular-translate-loader-static-files": "~2.8.0" // for language support - }, - "resolutions": { - "angular": "~1.3.x", - "jquery": "~2.0.3" - } -} diff --git a/catalog-ui/bower.json b/catalog-ui/bower.json deleted file mode 100644 index d941f1620a..0000000000 --- a/catalog-ui/bower.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "catalog-ui", - "private": true, - "dependencies": { - "angular": "1.5.0", - "angular-base64": "2.0.5", - "angular-base64-upload": "0.1.19", - "angular-bootstrap": "0.14.3", - "angular-dragdrop": "https://github.com/dimkinv/angular-dragdrop.git#1.0.14", - "angular-filter": "0.5.14", - "angular-mocks": "1.5.0", - "angular-perfect-scrollbar": "0.0.4", - "angular-resource": "1.5.11", - "angular-sanitize": "1.4.4", - "angular-tooltips": "0.1.23", - "angular-translate": "2.8.0", - "angular-translate-loader-static-files": "2.8.0", - "angular-ui-router": "0.2.14", - "angular-uuid4": "0.3.0", - "bootstrap": "3.3.4", - "checklist-model": "0.2.4", - "jquery": "2.2.4", - "jspdf": "1.0.272", - "animate.css": "~3.5.1", - "angular-clipboard": "1.5.0", - "ui-bootstrap": "1.3.3", - "angular-resizable": "1.2.0", - "angular-ui-notification": "0.2.0", - "js-md5": "md5#0.4.1", - "cytoscape": "^2.7.10", - "lodash": "^4.17.2", - "restangular": "^1.5.2", - "cytoscape-expand-collapse": "https://github.com/bardit/cytoscape.js-expand-collapse.git", - "cytoscape-qtip": "https://github.com/bardit/cytoscape.js-qtip.git", - "qtip2": "^2.2.1" - }, - "resolutions": { - "angular": "1.5.0", - "jquery": "2.2.4", - "angular-translate": "2.8.1" - } -} diff --git a/catalog-ui/build_catalog_ui.bat b/catalog-ui/build_catalog_ui.bat index 7a153e9ae7..b00ee0875b 100644 --- a/catalog-ui/build_catalog_ui.bat +++ b/catalog-ui/build_catalog_ui.bat @@ -1,27 +1,26 @@ rem nvmw use v0.12.4 +echo "configure proxy for ATT" +call npm config set proxy http://one.proxy.att.com:8080 + +echo "npm cache clean" +call npm cache clean echo "npm install" call npm install if %errorlevel% NEQ 0 GOTO BAD_EXIT -echo "bower install" -call bower install -if %errorlevel% NEQ 0 GOTO BAD_EXIT - - -echo "build --v" -grunt build --v +echo "npm run build:prod" +npm run build:prod if %errorlevel% NEQ 0 GOTO BAD_EXIT GOTO SMOOTH - :BAD_EXIT echo BOO -exit/ b 1 +exit /b 1 :SMOOTH diff --git a/catalog-ui/build_catalog_ui.sh b/catalog-ui/build_catalog_ui.sh index 8bae776893..36f798513a 100644 --- a/catalog-ui/build_catalog_ui.sh +++ b/catalog-ui/build_catalog_ui.sh @@ -1,84 +1,50 @@ - #!/bin/sh -### Set the node environment. -#NODE_VERSION="v6.2.2" - -#echo "Set the node environment." -#. "$NVM_DIR/nvm.sh" -#echo "OK." -#echo "" +### Set the node environment. +NODE_VERSION="v6.10.0" -### Add newer c++ compiler. -#if [ -f /opt/rh/devtoolset-4/enable ]; then -# . /opt/rh/devtoolset-4/enable -#fi +### Set the NVM root dir +NVM_DIR=/home/${USER}/.nvm -### Set the node version manager version. -#echo "Set the node version manager version." -#nvm use ${NODE_VERSION} -#echo "OK." -#echo "" - -### Run install bower. -echo "Run install bower." -#if [ -e $NVM_DIR/versions/node/${NODE_VERSION}/lib/node_modules/bower/bin/bower ]; then -# echo " - bower is already installed." -#else -npm install bower -#fi -#echo "OK." -#echo "" +echo "Set the node environment." +. "${NVM_DIR}/nvm.sh" +echo "OK." +echo "" -### Run install grunt-cli. -echo "Run install grunt-cli." -#if [ -e $NVM_DIR/versions/node/${NODE_VERSION}/lib/node_modules/grunt-cli/bin/grunt ]; then -# echo " - grunt-cli is already installed." -#else -npm install grunt-cli -#fi -#echo "OK." -#echo "" +### Add newer c++ compiler. +if [ -f /opt/rh/devtoolset-4/enable ]; then + . /opt/rh/devtoolset-4/enable +fi -### Clean the Node cache. -#echo "Clean the Node cache - if stuck." -#npm cache clean -#echo "OK." -#echo "" +### Set the node version manager version. +echo "Set the node version manager version." +nvm use ${NODE_VERSION} +echo "OK." +echo "" ### Run the Node package manager (NPM). echo "Run the Node package manager (NPM)." -#npm config set proxy http://one.proxy.att.com:8080 -#npm config set https-proxy http://one.proxy.att.com:8080 -#npm config set registry https://registry.npmjs.org - npm install echo "OK." echo "" -### Install the Bower components. -echo "Install the Bower components." -bower install -echo "OK." -echo "" - - - ### Build the application. echo "Build the application." -grunt build +npm run build:prod +echo "OK." +echo "" diff --git a/catalog-ui/configurations/dev.js b/catalog-ui/configurations/dev.js new file mode 100644 index 0000000000..4058071183 --- /dev/null +++ b/catalog-ui/configurations/dev.js @@ -0,0 +1,431 @@ +const SDC_CONFIG = { + "environment": "dev", + "api": { + "GET_component": "/v1/catalog/:type/:id", + "PUT_component": "/v1/catalog/:type/:id/metadata", + "GET_component_validate_name": "/v1/catalog/:type/validate-name/:name", + "POST_changeLifecycleState": "/v1/catalog/", + "component_api_root": "/v1/catalog/", + "GET_user": "/v1/user/:id", + "GET_user_authorize": "/v1/user/authorize", + "GET_all_users": "/v1/user/users", + "POST_create_user": "/v1/user", + "DELETE_delete_user": "/v1/user/:id", + "POST_edit_user_role": "/v1/user/:id/role", + "GET_resource": "/v1/catalog/resources/:id", + "GET_resources_latestversion_notabstract":"/v1/catalog/:type/latestversion/notabstract/:id", + "GET_resources_certified_not_abstract": "/v1/catalog/resources/certified/notabstract/:id", + "GET_resources_certified_abstract": "/v1/catalog/resources/certified/abstract/:id", + "GET_resource_property": "/v1/catalog/:type/:entityId/properties/:id", + "PUT_resource": "/v1/catalog/resources/:id/metadata", + "GET_resource_artifact": "/v1/catalog/:type/:entityId/artifacts/:id", + "GET_download_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstances/:instanceId/artifacts/:id", + "POST_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstance/:instanceId/artifacts/:id", + "GET_resource_additional_information": "/v1/catalog/:type/:entityId/additionalinfo/:id", + "GET_service_artifact": "/v1/catalog/services/:serviceId/artifacts/:id", + "GET_resource_interface_artifact": "/v1/catalog/:type/:entityId/standard/:operation/artifacts/:id", + "GET_resource_api_artifact": "/v1/catalog/:type/:entityId/artifacts/api/:id", + "GET_configuration_ui": "/v1/configuration/ui", + "GET_resource_validate_name": "/v1/catalog/resources/validate-name/:name", + "GET_activity_log": "/v1/catalog/audit-records/:type/:id", + "GET_service": "/v1/catalog/services/:id", + "GET_service_validate_name": "/v1/catalog/services/validate-name/:name", + "GET_service_distributions":"/v1/catalog/services/:uuid/distribution", + "GET_service_distributions_components":"/v1/catalog/services/distribution/:distributionId", + "POST_service_distribution_deploy" : "/v1/catalog/services/:serviceId/distribution/:distributionId/markDeployed", + "GET_element": "/v1/followed", + "GET_catalog": "/v1/screen", + "GET_ecomp_menu_items": "/v1/user/:userId/functionalmenu", + "GET_resource_category": "/v1/resourceCategories", + "GET_service_category": "/v1/serviceCategories", + "resource_instance": "/v1/catalog/:entityType/:entityId/resourceInstance/:id", + "GET_resource_instance_property": "/v1/catalog/:type/:entityId/resourceInstance/:componentInstanceId/property/:propertyValueId", + "GET_relationship": "/v1/catalog/:entityType/:entityId/resourceInstance/:action", + "GET_lifecycle_state_resource": "/v1/catalog/:type/:id/lifecycleState/:action", + "GET_lifecycle_state_CHECKIN":"lifecycleState/CHECKIN", + "GET_lifecycle_state_CERTIFICATIONREQUEST":"lifecycleState/CERTIFICATIONREQUEST", + "GET_lifecycle_state_UNDOCHECKOUT":"lifecycleState/UNDOCHECKOUT", + "root": "/sdc1/feProxy/rest", + "PUT_service": "/v1/catalog/services/:id/metadata", + "GET_download_artifact": "/v1/catalog/", + "GET_SDC_Version": "/version", + "GET_categories": "/v1/categories/:types", + "POST_category": "/v1/category/:types/:categoryId", + "POST_subcategory": "/v1/category/:types/:categoryId/subCategory/:subCategoryId", + "POST_change_instance_version": "/v1/catalog/:entityType/:entityId/resourceInstance/:id/changeVersion", + "GET_requirements_capabilities": "/v1/catalog/requirmentsCapabilities/:type/:id", + "GET_resource_artifact_types": "/v1/artifactTypes", + "GET_product_catalog": "/v1/productScreen", + "GET_product_category": "/v1/productCategories", + "GET_product_category_temp": "/v1/artifactTypes", + "POST_product": "/v1/catalog/products/:id/metadata", + "GET_product_validate_name": "/v1/catalog/services/validate-name/:name", + "GET_product": "/v1/catalog/products/:id", + "GET_product_sub_category": "/v1/productSubCategories", + "GET_onboarding": "/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/packages", + "GET_component_from_csar_uuid": "/v1/catalog/resources/csar/:csar_uuid", + "kibana": "/sdc1/kibanaProxy/" + }, + "resourceTypesFilter":{ + "resource":["CP","VFC","VL"], + "service":["CP","VF","VL"], + "product":[] + }, + "logConfig": { + "minLogLevel": "debug", + "prefix": "sdcApp" + }, + "cookie": { + "junctionName": "IV_JCT", + "prefix": "AMWEBJCT!", + "userIdSuffix": "USER_ID", + "userFirstName": "HTTP_CSP_FIRSTNAME", + "userLastName": "HTTP_CSP_LASTNAME", + "userEmail": "HTTP_CSP_EMAIL", + "xEcompRequestId": " X-ECOMP-RequestID" + }, + "imagesPath": "", + "cpEndPointInstances" : ["cloudep","ossep","personep","premisesep"], + "toscaFileExtension":"yaml,yml", + "csarFileExtension":"csar", + "showOutlook": false, + "validationConfigPath":"configurations/validation.json", + "categories": {}, + "testers": { + "RESOURCE": { + "Network L2-3": "DL-ASDCL1-3ResourceCertificationTeam", + "Network L4+": "DL-ASDCL4-7ResourceCertificationTeam", + "Application L4+": "DL-ASDCL4-7ResourceCertificationTeam", + "default": "DL-ASDCL1-3ResourceCertificationTeam;DL-ASDCL4-7ResourceCertificationTeam" + }, + "SERVICE": { + "Network L1-3": "DL-ASDCL1-4ServiceCertificationTeam", + "Network L4+": "DL-ASDCL4-7ServiceCertificationTeam", + "default": "DL-ASDCL1-4ServiceCertificationTeam;DL-ASDCL4-7ServiceCertificationTeam" + } + }, + "roles": ["ADMIN", "TESTER", "GOVERNOR", "OPS", "DESIGNER", "PRODUCT_MANAGER", "PRODUCT_STRATEGIST"], + "tutorial": { + "tabs": [ + { + "id":1, + "name":"TUTRIAL_GENERAL_TAB_1", + "defaultPage":1 + }, + { + "id":2, + "name":"TUTRIAL_GENERAL_TAB_2", + "defaultPage":9 + }, + { + "id":3, + "name":"TUTRIAL_GENERAL_TAB_3", + "defaultPage":12 + } + ], + "pages": + [ + { + "id":1, + "template": "text-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE1_TITLE", + "description":"TUTORIAL_PAGE1_TEXT" + } + + }, + { + "id":2, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE2_TITLE", + "description":"TUTORIAL_PAGE2_TEXT", + "imageClass":"sdc-tutorial-page-2-image" + } + }, + { + "id":3, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE3_TITLE", + "description":"TUTORIAL_PAGE3_TEXT", + "imageClass":"sdc-tutorial-page-3-image" + } + }, + { + "id":4, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE4_TITLE", + "description":"TUTORIAL_PAGE4_TEXT", + "imageClass":"sdc-tutorial-page-4-image" + } + }, + { + "id":5, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE5_TITLE", + "description":"TUTORIAL_PAGE5_TEXT", + "imageClass":"sdc-tutorial-page-5-image" + } + }, + { + "id":6, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE6_TITLE", + "description":"TUTORIAL_PAGE6_TEXT", + "imageClass":"sdc-tutorial-page-6-image" + } + }, + { + "id":7, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE7_TITLE", + "description":"TUTORIAL_PAGE7_TEXT", + "imageClass":"sdc-tutorial-page-7-image" + } + }, + { + "id":8, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE8_TITLE", + "description":"TUTORIAL_PAGE8_TEXT", + "imageClass":"sdc-tutorial-page-8-image" + } + }, + { + "id":9, + "template": "text-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE9_TITLE", + "description":"TUTORIAL_PAGE9_TEXT" + } + }, + { + "id":10, + "template": "image-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE10_TITLE", + "description":"TUTORIAL_PAGE10_TEXT", + "imageClass":"sdc-tutorial-page-10-image" + } + }, + { + "id":11, + "template": "image-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE11_TITLE", + "description":"TUTORIAL_PAGE11_TEXT", + "imageClass":"sdc-tutorial-page-11-image" + } + }, + { + "id":12, + "template": "text-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE12_TITLE", + "description":"TUTORIAL_PAGE12_TEXT" + } + }, + { + "id":13, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE13_TITLE", + "description":"TUTORIAL_PAGE13_TEXT", + "imageClass":"sdc-tutorial-page-13-image" + } + }, + { + "id":14, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE14_TITLE", + "description":"TUTORIAL_PAGE14_TEXT", + "imageClass":"sdc-tutorial-page-14-image" + } + }, + { + "id":15, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE15_TITLE", + "description":"TUTORIAL_PAGE15_TEXT", + "imageClass":"sdc-tutorial-page-15-image" + } + }, + { + "id":16, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE16_TITLE", + "description":"TUTORIAL_PAGE16_TEXT", + "imageClass":"sdc-tutorial-page-16-image" + } + }, + { + "id":17, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE17_TITLE", + "description":"TUTORIAL_PAGE17_TEXT", + "imageClass":"sdc-tutorial-page-17-image" + } + }, + { + "id":18, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE18_TITLE", + "description":"TUTORIAL_PAGE18_TEXT", + "imageClass":"sdc-tutorial-page-18-image" + } + }, + { + "id":19, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE19_TITLE", + "description":"TUTORIAL_PAGE19_TEXT", + "imageClass":"sdc-tutorial-page-19-image" + } + }, + { + "id":20, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE20_TITLE", + "description":"TUTORIAL_PAGE20_TEXT", + "imageClass":"sdc-tutorial-page-20-image" + } + }, + { + "id":21, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE21_TITLE", + "description":"TUTORIAL_PAGE21_TEXT", + "imageClass":"sdc-tutorial-page-21-image" + } + }, + { + "id":22, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE22_TITLE", + "description":"TUTORIAL_PAGE22_TEXT", + "imageClass":"sdc-tutorial-page-22-image" + } + }, + { + "id":23, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE23_TITLE", + "description":"TUTORIAL_PAGE23_TEXT", + "imageClass":"sdc-tutorial-page-23-image" + } + }, + { + "id":24, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE24_TITLE", + "description":"TUTORIAL_PAGE24_TEXT", + "imageClass":"sdc-tutorial-page-24-image" + } + }, + { + "id":25, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE25_TITLE", + "description":"TUTORIAL_PAGE25_TEXT", + "imageClass":"sdc-tutorial-page-25-image" + } + }, + { + "id":26, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE26_TITLE", + "description":"TUTORIAL_PAGE26_TEXT", + "imageClass":"sdc-tutorial-page-26-image" + } + }, + { + "id":27, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE27_TITLE", + "description":"TUTORIAL_PAGE27_TEXT", + "imageClass":"sdc-tutorial-page-27-image" + } + }, + { + "id":28, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE28_TITLE", + "description":"TUTORIAL_PAGE28_TEXT", + "imageClass":"sdc-tutorial-page-28-image" + } + }, + { + "id":29, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE29_TITLE", + "description":"TUTORIAL_PAGE29_TEXT", + "imageClass":"sdc-tutorial-page-29-image" + } + }, + { + "id":30, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE30_TITLE", + "description":"TUTORIAL_PAGE30_TEXT", + "imageClass":"sdc-tutorial-page-30-image" + } + } + + ] + } +}; + +module.exports = SDC_CONFIG;
\ No newline at end of file diff --git a/catalog-ui/configurations/dev.json b/catalog-ui/configurations/dev.json deleted file mode 100644 index 4cc09d3c31..0000000000 --- a/catalog-ui/configurations/dev.json +++ /dev/null @@ -1,430 +0,0 @@ -{ - "environment": "dev", - "api": { - "GET_component": "/v1/catalog/:type/:id", - "PUT_component": "/v1/catalog/:type/:id/metadata", - "GET_component_validate_name": "/v1/catalog/:type/validate-name/:name", - "POST_changeLifecycleState": "/v1/catalog/", - "component_api_root": "/v1/catalog/", - "welcome_page_video_url": "http://0.0.0.0:8282/moti/movie", - - "GET_user": "/v1/user/:id", - "GET_user_authorize": "/v1/user/authorize", - "GET_all_users": "/v1/user/users", - "POST_create_user": "/v1/user", - "DELETE_delete_user": "/v1/user/:id", - "POST_edit_user_role": "/v1/user/:id/role", - "GET_resource": "/v1/catalog/resources/:id", - "GET_resources_latestversion_notabstract":"/v1/catalog/:type/latestversion/notabstract/:id", - "GET_resources_certified_not_abstract": "/v1/catalog/resources/certified/notabstract/:id", - "GET_resources_certified_abstract": "/v1/catalog/resources/certified/abstract/:id", - "GET_resource_property": "/v1/catalog/:type/:entityId/properties/:id", - "PUT_resource": "/v1/catalog/resources/:id/metadata", - "GET_resource_artifact": "/v1/catalog/:type/:entityId/artifacts/:id", - "GET_download_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstances/:instanceId/artifacts/:id", - "POST_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstance/:instanceId/artifacts/:id", - "GET_resource_additional_information": "/v1/catalog/:type/:entityId/additionalinfo/:id", - "GET_service_artifact": "/v1/catalog/services/:serviceId/artifacts/:id", - "GET_resource_interface_artifact": "/v1/catalog/:type/:entityId/standard/:operation/artifacts/:id", - "GET_resource_api_artifact": "/v1/catalog/:type/:entityId/artifacts/api/:id", - "GET_configuration_ui": "/v1/configuration/ui", - "GET_resource_validate_name": "/v1/catalog/resources/validate-name/:name", - "GET_activity_log": "/v1/catalog/audit-records/:type/:id", - "GET_service": "/v1/catalog/services/:id", - "GET_service_validate_name": "/v1/catalog/services/validate-name/:name", - "GET_service_distributions":"/v1/catalog/services/:uuid/distribution", - "GET_service_distributions_components":"/v1/catalog/services/distribution/:distributionId", - "POST_service_distribution_deploy" : "/v1/catalog/services/:serviceId/distribution/:distributionId/markDeployed", - "GET_element": "/v1/followed", - "GET_catalog": "/v1/screen", - "GET_ecomp_menu_items": "/v1/user/:userId/functionalmenu", - "GET_resource_category": "/v1/resourceCategories", - "GET_service_category": "/v1/serviceCategories", - "resource_instance": "/v1/catalog/:entityType/:entityId/resourceInstance/:id", - "GET_resource_instance_property": "/v1/catalog/:type/:entityId/resourceInstance/:componentInstanceId/property/:propertyValueId", - "GET_relationship": "/v1/catalog/:entityType/:entityId/resourceInstance/:action", - "GET_lifecycle_state_resource": "/v1/catalog/:type/:id/lifecycleState/:action", - "GET_lifecycle_state_CHECKIN":"lifecycleState/CHECKIN", - "GET_lifecycle_state_CERTIFICATIONREQUEST":"lifecycleState/CERTIFICATIONREQUEST", - "GET_lifecycle_state_UNDOCHECKOUT":"lifecycleState/UNDOCHECKOUT", - "root": "http://feHost:8181/sdc1/feProxy/rest", - "PUT_service": "/v1/catalog/services/:id/metadata", - "GET_download_artifact": "/v1/catalog/", - "GET_SDC_Version": "/version", - "GET_categories": "/v1/categories/:types", - "POST_category": "/v1/category/:types/:categoryId", - "POST_subcategory": "/v1/category/:types/:categoryId/subCategory/:subCategoryId", - "POST_change_instance_version": "/v1/catalog/:entityType/:entityId/resourceInstance/:id/changeVersion", - "GET_requirements_capabilities": "/v1/catalog/requirmentsCapabilities/:type/:id", - "GET_resource_artifact_types": "/v1/artifactTypes", - "GET_product_catalog": "/v1/productScreen", - "GET_product_category": "/v1/productCategories", - "GET_product_category_temp": "/v1/artifactTypes", - "POST_product": "/v1/catalog/products/:id/metadata", - "GET_product_validate_name": "/v1/catalog/services/validate-name/:name", - "GET_product": "/v1/catalog/products/:id", - "GET_product_sub_category": "/v1/productSubCategories", - "GET_onboarding": "http://fehost:8181/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/packages", - "GET_component_from_csar_uuid": "/v1/catalog/resources/csar/:csar_uuid", - "kibana": "/sdc1/kibanaProxy/" - }, - "resourceTypesFilter":{ - "resource":["CP","VFC"], - "service":["CP","VF"], - "product":[] - }, - "logConfig": { - "minLogLevel": "debug", - "prefix": "sdcApp" - }, - "cookie": { - "junctionName": "IV_JCT", - "prefix": "AMWEBJCT!", - "userIdSuffix": "USER_ID", - "userFirstName": "HTTP_CSP_FIRSTNAME", - "userLastName": "HTTP_CSP_LASTNAME", - "userEmail": "HTTP_CSP_EMAIL", - "xEcompRequestId": " X-ECOMP-RequestID" - }, - "imagesPath": "", - "cpEndPointInstances" : ["cloudep","ossep","personep","premisesep"], - "toscaFileExtension":"yaml,yml", - "csarFileExtension":"csar", - "openSource": true, - "categories": {}, - "testers": { - "RESOURCE": { - "Network L2-3": "DL-ASDCL1-3ResourceCertificationTeam", - "Network L4+": "DL-ASDCL4-7ResourceCertificationTeam", - "Application L4+": "DL-ASDCL4-7ResourceCertificationTeam", - "default": "DL-ASDCL1-3ResourceCertificationTeam;DL-ASDCL4-7ResourceCertificationTeam" - }, - "SERVICE": { - "Network L1-3": "DL-ASDCL1-4ServiceCertificationTeam", - "Network L4+": "DL-ASDCL4-7ServiceCertificationTeam", - "default": "DL-ASDCL1-4ServiceCertificationTeam;DL-ASDCL4-7ServiceCertificationTeam" - } - }, - "roles": ["ADMIN", "TESTER", "GOVERNOR", "OPS", "DESIGNER", "PRODUCT_MANAGER", "PRODUCT_STRATEGIST"], - "tutorial": { - "tabs": [ - { - "id":1, - "name":"TUTRIAL_GENERAL_TAB_1", - "defaultPage":1 - }, - { - "id":2, - "name":"TUTRIAL_GENERAL_TAB_2", - "defaultPage":9 - }, - { - "id":3, - "name":"TUTRIAL_GENERAL_TAB_3", - "defaultPage":12 - } - ], - "pages": - [ - { - "id":1, - "template": "text-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE1_TITLE", - "description":"TUTORIAL_PAGE1_TEXT" - } - - }, - { - "id":2, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE2_TITLE", - "description":"TUTORIAL_PAGE2_TEXT", - "imageClass":"sdc-tutorial-page-2-image" - } - }, - { - "id":3, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE3_TITLE", - "description":"TUTORIAL_PAGE3_TEXT", - "imageClass":"sdc-tutorial-page-3-image" - } - }, - { - "id":4, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE4_TITLE", - "description":"TUTORIAL_PAGE4_TEXT", - "imageClass":"sdc-tutorial-page-4-image" - } - }, - { - "id":5, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE5_TITLE", - "description":"TUTORIAL_PAGE5_TEXT", - "imageClass":"sdc-tutorial-page-5-image" - } - }, - { - "id":6, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE6_TITLE", - "description":"TUTORIAL_PAGE6_TEXT", - "imageClass":"sdc-tutorial-page-6-image" - } - }, - { - "id":7, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE7_TITLE", - "description":"TUTORIAL_PAGE7_TEXT", - "imageClass":"sdc-tutorial-page-7-image" - } - }, - { - "id":8, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE8_TITLE", - "description":"TUTORIAL_PAGE8_TEXT", - "imageClass":"sdc-tutorial-page-8-image" - } - }, - { - "id":9, - "template": "text-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE9_TITLE", - "description":"TUTORIAL_PAGE9_TEXT" - } - }, - { - "id":10, - "template": "image-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE10_TITLE", - "description":"TUTORIAL_PAGE10_TEXT", - "imageClass":"sdc-tutorial-page-10-image" - } - }, - { - "id":11, - "template": "image-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE11_TITLE", - "description":"TUTORIAL_PAGE11_TEXT", - "imageClass":"sdc-tutorial-page-11-image" - } - }, - { - "id":12, - "template": "text-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE12_TITLE", - "description":"TUTORIAL_PAGE12_TEXT" - } - }, - { - "id":13, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE13_TITLE", - "description":"TUTORIAL_PAGE13_TEXT", - "imageClass":"sdc-tutorial-page-13-image" - } - }, - { - "id":14, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE14_TITLE", - "description":"TUTORIAL_PAGE14_TEXT", - "imageClass":"sdc-tutorial-page-14-image" - } - }, - { - "id":15, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE15_TITLE", - "description":"TUTORIAL_PAGE15_TEXT", - "imageClass":"sdc-tutorial-page-15-image" - } - }, - { - "id":16, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE16_TITLE", - "description":"TUTORIAL_PAGE16_TEXT", - "imageClass":"sdc-tutorial-page-16-image" - } - }, - { - "id":17, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE17_TITLE", - "description":"TUTORIAL_PAGE17_TEXT", - "imageClass":"sdc-tutorial-page-17-image" - } - }, - { - "id":18, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE18_TITLE", - "description":"TUTORIAL_PAGE18_TEXT", - "imageClass":"sdc-tutorial-page-18-image" - } - }, - { - "id":19, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE19_TITLE", - "description":"TUTORIAL_PAGE19_TEXT", - "imageClass":"sdc-tutorial-page-19-image" - } - }, - { - "id":20, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE20_TITLE", - "description":"TUTORIAL_PAGE20_TEXT", - "imageClass":"sdc-tutorial-page-20-image" - } - }, - { - "id":21, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE21_TITLE", - "description":"TUTORIAL_PAGE21_TEXT", - "imageClass":"sdc-tutorial-page-21-image" - } - }, - { - "id":22, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE22_TITLE", - "description":"TUTORIAL_PAGE22_TEXT", - "imageClass":"sdc-tutorial-page-22-image" - } - }, - { - "id":23, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE23_TITLE", - "description":"TUTORIAL_PAGE23_TEXT", - "imageClass":"sdc-tutorial-page-23-image" - } - }, - { - "id":24, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE24_TITLE", - "description":"TUTORIAL_PAGE24_TEXT", - "imageClass":"sdc-tutorial-page-24-image" - } - }, - { - "id":25, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE25_TITLE", - "description":"TUTORIAL_PAGE25_TEXT", - "imageClass":"sdc-tutorial-page-25-image" - } - }, - { - "id":26, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE26_TITLE", - "description":"TUTORIAL_PAGE26_TEXT", - "imageClass":"sdc-tutorial-page-26-image" - } - }, - { - "id":27, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE27_TITLE", - "description":"TUTORIAL_PAGE27_TEXT", - "imageClass":"sdc-tutorial-page-27-image" - } - }, - { - "id":28, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE28_TITLE", - "description":"TUTORIAL_PAGE28_TEXT", - "imageClass":"sdc-tutorial-page-28-image" - } - }, - { - "id":29, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE29_TITLE", - "description":"TUTORIAL_PAGE29_TEXT", - "imageClass":"sdc-tutorial-page-29-image" - } - }, - { - "id":30, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE30_TITLE", - "description":"TUTORIAL_PAGE30_TEXT", - "imageClass":"sdc-tutorial-page-30-image" - } - } - - ] - } -} diff --git a/catalog-ui/configurations/menu.json b/catalog-ui/configurations/menu.js index cd451e79f1..12dda2d78b 100644 --- a/catalog-ui/configurations/menu.json +++ b/catalog-ui/configurations/menu.js @@ -1,4 +1,4 @@ -{ +const SDC_MENU_CONFIG = { "roles":{ "ADMIN":{ "title": "Admin's Workspace", @@ -6,29 +6,24 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest" , "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest" , "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text": "View","action": "openViewerModal"} + {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } } @@ -54,29 +49,24 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text": "View","action": "openViewerModal"} + {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } }, @@ -103,27 +93,22 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "View","action": "openViewerModal"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } }, @@ -154,27 +139,22 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "View","action": "openViewerModal"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } }, @@ -207,13 +187,11 @@ "states": { "READY_FOR_CERTIFICATION":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"}, {"text":"Start Testing","action":"changeLifecycleState", "url":"lifecycleState/startCertification"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"}, {"text":"Accept","action":"changeLifecycleState", "url":"lifecycleState/certify", "confirmationModal": "lifecycleState/certify"}, {"text":"Reject","action":"changeLifecycleState", "url":"lifecycleState/failCertification", "confirmationModal": "lifecycleState/failCertification"}, {"text":"Cancel","action":"changeLifecycleState", "url":"lifecycleState/cancelCertification", "confirmationModal": "lifecycleState/cancel" } @@ -234,21 +212,19 @@ "showCreateNewProduct": false }, "changeLifecycleStateButtons":{ - "DISTRIBUTION_APPROVED":{ "distribute": {"text":"Distribute", "url":"distribution/PROD/activate"}, + "DISTRIBUTION_APPROVED":{ "distribute": {"text":"Distribute", "url":"distribution/PROD/activate", "conformanceLevelModal": { "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject" }}, "monitor": {"text":"Monitor", "disabled":true} }, - "DISTRIBUTED":{ "redistribute": {"text":"Redistribute", "url":"distribution/PROD/activate"}, + "DISTRIBUTED":{ "redistribute": {"text":"Redistribute", "url":"distribution/PROD/activate", "conformanceLevelModal": { "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject" }}, "monitor": {"text":"Monitor", "url":"distribution-state/monitor"} } }, "states": { "CERTIFIED": { "DISTRIBUTION_APPROVED": [ - {"text": "View","action": "openViewerModal"}, {"text": "Distribute","action":"changeLifecycleState", "url":"distribution/PROD/activate"} ], "DISTRIBUTED": [ - {"text": "View","action": "openViewerModal"}, {"text": "Monitor","action":"openDistributionModal", "url":"distribution-state/monitor"}, {"text": "Redistribute","action":"changeLifecycleState", "url":"distribution/PROD/activate"} ] @@ -268,33 +244,29 @@ "showCreateNewProduct": false }, "changeLifecycleStateButtons":{ - "DISTRIBUTION_NOT_APPROVED":{ "approve": {"text":"Approve", "url":"distribution-state/approve", "confirmationModal": "distribution-state/approve"}, + "DISTRIBUTION_NOT_APPROVED":{ "approve": {"text":"Approve", "url":"distribution-state/approve", "confirmationModal": "distribution-state/approve", "conformanceLevelModal": { "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject" }}, "reject": {"text":"Reject", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} }, "DISTRIBUTION_APPROVED":{ "reject": {"text":"Reject", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} }, "DISTRIBUTED": { "reject": {"text":"Reject", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} }, - "DISTRIBUTION_REJECTED": { "approve": {"text": "Approve", "url": "distribution-state/approve", "confirmationModal": "distribution-state/approve"} + "DISTRIBUTION_REJECTED": { "approve": {"text": "Approve", "url": "distribution-state/approve", "confirmationModal": "distribution-state/approve", "conformanceLevelModal": { "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject" }} } }, "states": { "CERTIFIED": { "DISTRIBUTION_NOT_APPROVED": [ - {"text": "View","action": "openViewerModal"}, {"text":"Approve","action":"changeLifecycleState", "url":"distribution-state/approve", "confirmationModal": "distribution-state/approve"}, {"text":"Reject","action":"changeLifecycleState", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} ], "DISTRIBUTION_APPROVED": [ - {"text": "View","action": "openViewerModal"}, {"text":"Reject","action":"changeLifecycleState", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} ], "DISTRIBUTED": [ - {"text": "View","action": "openViewerModal"}, {"text":"Reject","action":"changeLifecycleState", "url":"distribution-state/reject", "confirmationModal": "distribution-state/reject"} ], "DISTRIBUTION_REJECTED": [ - {"text": "View","action": "openViewerModal"}, {"text":"Approve","action":"changeLifecycleState", "url":"distribution-state/approve", "confirmationModal": "distribution-state/approve"} ] } @@ -311,7 +283,7 @@ "confirmationMessages": { "lifecycleState/CHECKIN": {"showComment":true, "title": "Check in confirmation", "message": "Please add comment and confirm the check in."}, "lifecycleState/CHECKOUT": {"showComment":true, "title": "Check out confirmation", "message": "Please add comment and confirm the check out."}, - "lifecycleState/certify": {"showComment":true, "title": "Distribution confirmation", "message": "Please add comment and confirm test results."}, + "lifecycleState/certify": {"showComment":true, "title": "Certification confirmation", "message": "Please add comment and confirm test results."}, "lifecycleState/cancel": {"showComment":true, "title": "Cancel test", "message": "Please add comment and cancel test."}, "lifecycleState/failCertification": {"showComment":true, "title": "Rejection confirmation", "message": "Please add comment and confirm test results."}, "lifecycleState/CERTIFICATIONREQUEST": {"showComment":true, "title": "Submit for testing", "message": "Please add comment and submit for testing."}, @@ -361,32 +333,26 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ], "NOT_OWNER":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"}, - {"text": "View","action": "openViewerModal"} + {"text": "Submit for Testing", "action": "changeLifecycleState", "url": "lifecycleState/certificationRequest", "emailModal": "lifecycleState/CERTIFICATIONREQUEST"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } @@ -396,30 +362,24 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ], "NOT_OWNER":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "View","action": "openViewerModal"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } }, @@ -443,30 +403,24 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ], "NOT_OWNER":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "NOT_CERTIFIED_CHECKIN": { "ANY": [ - {"text": "View","action": "openViewerModal"} ] }, "READY_FOR_CERTIFICATION": { "ANY":[ - {"text": "View","action": "openViewerModal"} ] }, "CERTIFICATION_IN_PROGRESS":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] }, "CERTIFIED":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } }, @@ -484,7 +438,6 @@ "states":{ "ANY":{ "ANY":[ - {"text":"View" ,"action":"openViewerModal"} ] } } @@ -513,6 +466,7 @@ "VFC":[ {"text":"General", "action":"onMenuItemPressed", "state": "workspace.general"}, {"text":"Icon", "action":"onMenuItemPressed", "state": "workspace.icons"}, + {"text":"Deployment Artifact", "action":"onMenuItemPressed", "state": "workspace.deployment_artifacts"}, {"text":"Information Artifact", "action":"onMenuItemPressed", "state": "workspace.information_artifacts"}, {"text":"TOSCA Artifacts", "action":"onMenuItemPressed", "state": "workspace.tosca_artifacts"}, {"text":"Properties", "action":"onMenuItemPressed", "state": "workspace.properties"}, @@ -523,6 +477,7 @@ "VL":[ {"text":"General", "action":"onMenuItemPressed", "state": "workspace.general"}, {"text":"Icon", "action":"onMenuItemPressed", "state": "workspace.icons"}, + {"text":"Deployment Artifact", "action":"onMenuItemPressed", "state": "workspace.deployment_artifacts"}, {"text":"Information Artifact", "action":"onMenuItemPressed", "state": "workspace.information_artifacts"}, {"text":"TOSCA Artifacts", "action":"onMenuItemPressed", "state": "workspace.tosca_artifacts"}, {"text":"Properties", "action":"onMenuItemPressed", "state": "workspace.properties"}, @@ -533,6 +488,7 @@ "CP":[ {"text":"General", "action":"onMenuItemPressed", "state": "workspace.general"}, {"text":"Icon", "action":"onMenuItemPressed", "state": "workspace.icons"}, + {"text":"Deployment Artifact", "action":"onMenuItemPressed", "state": "workspace.deployment_artifacts"}, {"text":"Information Artifact", "action":"onMenuItemPressed", "state": "workspace.information_artifacts"}, {"text":"TOSCA Artifacts", "action":"onMenuItemPressed", "state": "workspace.tosca_artifacts"}, {"text":"Properties", "action":"onMenuItemPressed", "state": "workspace.properties"}, @@ -546,11 +502,12 @@ {"text":"Deployment Artifact", "action":"onMenuItemPressed", "state": "workspace.deployment_artifacts"}, {"text":"Information Artifact", "action":"onMenuItemPressed", "state": "workspace.information_artifacts"}, {"text":"TOSCA Artifacts", "action":"onMenuItemPressed", "state": "workspace.tosca_artifacts"}, - {"text":"Properties", "action":"onMenuItemPressed", "state": "workspace.properties"}, + // {"text":"Properties", "action":"onMenuItemPressed", "state": "workspace.properties"}, {"text":"Composition", "action":"onMenuItemPressed", "state": "workspace.composition.details"}, {"text":"Activity Log", "action":"onMenuItemPressed", "state": "workspace.activity_log"}, {"text":"Deployment", "action":"onMenuItemPressed", "state": "workspace.deployment"}, - {"text":"Inputs", "action":"onMenuItemPressed", "state": "workspace.resource_inputs"} + // {"text":"Inputs", "action":"onMenuItemPressed", "state": "workspace.resource_inputs"}, + {"text":"Properties Assignment", "action":"onMenuItemPressed", "state": "workspace.properties_assignment"} ], "SERVICE":[ {"text":"General", "action":"onMenuItemPressed", "state": "workspace.general"}, @@ -562,7 +519,8 @@ {"text":"Network Call Flow ", "action":"onMenuItemPressed", "state": "workspace.network_call_flow"}, {"text":"Monitor ", "action":"onMenuItemPressed", "state": "workspace.distribution", "disabledRoles": ["ADMIN", "TESTER", "GOVERNOR", "DESIGNER", "PRODUCT_MANAGER", "PRODUCT_STRATEGIST"]}, {"text":"Deployment", "action":"onMenuItemPressed", "state": "workspace.deployment"}, - {"text":"Inputs", "action":"onMenuItemPressed", "state": "workspace.service_inputs"} + // {"text":"Inputs", "action":"onMenuItemPressed", "state": "workspace.service_inputs"}, + {"text":"Properties Assignment", "action":"onMenuItemPressed", "state": "workspace.properties_assignment"} ], "PRODUCT":[ {"text":"General", "action":"onMenuItemPressed", "state": "workspace.general"}, @@ -572,5 +530,6 @@ ] } - } + +module.exports = SDC_MENU_CONFIG; diff --git a/catalog-ui/configurations/mock.json b/catalog-ui/configurations/mock.json index 21836a837d..2abcbe0ce2 100644 --- a/catalog-ui/configurations/mock.json +++ b/catalog-ui/configurations/mock.json @@ -126,13 +126,11 @@ "states":{ "NOT_CERTIFIED_CHECKOUT":[ {"text":"Check in","action":"changeLifecycleState", "url":"CHECKIN"}, - {"text":"View" ,"action":"openViewerModal"}, {"text":"Edit" ,"action":"goToEntity"} ], "NOT_CERTIFIED_CHECKIN":[ {"text":"Check out","action":"changeLifecycleState", "url":"CHECKOUT"}, - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"} ], "READY_FOR_CERTIFICATION":[], @@ -147,22 +145,17 @@ "NOT_CERTIFIED_CHECKOUT":[ {"text":"Edit" ,"action":"goToEntity"}, {"text":"Check in","action":"changeLifecycleState", "url":"CHECKIN"}, - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"} ], "NOT_CERTIFIED_CHECKIN":[ {"text":"Check out","action":"changeLifecycleState", "url":"CHECKOUT"}, - {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"}, - {"text":"View" ,"action":"openViewerModal"} + {"text":"Submit for Testing","action":"changeLifecycleState", "url":"certificationRequest"} ], "READY_FOR_CERTIFICATION":[ - {"text":"View" ,"action":"openViewerModal"} ], "CERTIFICATION_IN_PROGRESS":[ - {"text":"View" ,"action":"openViewerModal"} ], "CERTIFIED":[ - {"text":"View" ,"action":"openViewerModal"} ] } diff --git a/catalog-ui/configurations/prod.js b/catalog-ui/configurations/prod.js new file mode 100644 index 0000000000..30cb3f2146 --- /dev/null +++ b/catalog-ui/configurations/prod.js @@ -0,0 +1,432 @@ +const SDC_CONFIG = { + "environment": "prod", + "api": { + "GET_component": "/v1/catalog/:type/:id", + "PUT_component": "/v1/catalog/:type/:id/metadata", + "GET_component_validate_name": "/v1/catalog/:type/validate-name/:name", + "POST_changeLifecycleState": "/v1/catalog/", + "component_api_root": "/v1/catalog/", + "GET_user": "/v1/user/:id", + "GET_user_authorize": "/v1/user/authorize", + "GET_all_users": "/v1/user/users", + "POST_create_user": "/v1/user", + "DELETE_delete_user": "/v1/user/:id", + "POST_edit_user_role": "/v1/user/:id/role", + "GET_resource": "/v1/catalog/resources/:id", + "GET_resources_latestversion_notabstract":"/v1/catalog/:type/latestversion/notabstract/:id", + "GET_resources_certified_not_abstract": "/v1/catalog/resources/certified/notabstract/:id", + "GET_resources_certified_abstract": "/v1/catalog/resources/certified/abstract/:id", + "GET_resource_property": "/v1/catalog/:type/:entityId/properties/:id", + "PUT_resource": "/v1/catalog/resources/:id/metadata", + "GET_resource_artifact": "/v1/catalog/:type/:entityId/artifacts/:id", + "GET_download_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstances/:instanceId/artifacts/:id", + "POST_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstance/:instanceId/artifacts/:id", + "GET_resource_additional_information": "/v1/catalog/:type/:entityId/additionalinfo/:id", + "GET_service_artifact": "/v1/catalog/services/:serviceId/artifacts/:id", + "GET_resource_interface_artifact": "/v1/catalog/:type/:entityId/standard/:operation/artifacts/:id", + "GET_resource_api_artifact": "/v1/catalog/:type/:entityId/artifacts/api/:id", + "GET_configuration_ui": "/v1/configuration/ui", + "GET_resource_validate_name": "/v1/catalog/resources/validate-name/:name", + "GET_activity_log": "/v1/catalog/audit-records/:type/:id", + "GET_service": "/v1/catalog/services/:id", + "GET_service_validate_name": "/v1/catalog/services/validate-name/:name", + "GET_service_distributions":"/v1/catalog/services/:uuid/distribution", + "GET_service_distributions_components":"/v1/catalog/services/distribution/:distributionId", + "POST_service_distribution_deploy" : "/v1/catalog/services/:serviceId/distribution/:distributionId/markDeployed", + "GET_element": "/v1/followed", + "GET_catalog": "/v1/screen", + "GET_ecomp_menu_items": "/v1/user/:userId/functionalmenu", + "GET_resource_category": "/v1/resourceCategories", + "GET_service_category": "/v1/serviceCategories", + "resource_instance": "/v1/catalog/:entityType/:entityId/resourceInstance/:id", + "GET_resource_instance_property": "/v1/catalog/:type/:entityId/resourceInstance/:componentInstanceId/property/:propertyValueId", + "GET_relationship": "/v1/catalog/:entityType/:entityId/resourceInstance/:action", + "GET_lifecycle_state_resource": "/v1/catalog/:type/:id/lifecycleState/:action", + "GET_lifecycle_state_CHECKIN":"lifecycleState/CHECKIN", + "GET_lifecycle_state_CERTIFICATIONREQUEST":"lifecycleState/CERTIFICATIONREQUEST", + "GET_lifecycle_state_UNDOCHECKOUT":"lifecycleState/UNDOCHECKOUT", + "root": "/sdc1/feProxy/rest", + "PUT_service": "/v1/catalog/services/:id/metadata", + "GET_download_artifact": "/v1/catalog/", + "GET_SDC_Version": "/version", + "GET_categories": "/v1/categories/:types", + "POST_category": "/v1/category/:types/:categoryId", + "POST_subcategory": "/v1/category/:types/:categoryId/subCategory/:subCategoryId", + "POST_change_instance_version": "/v1/catalog/:entityType/:entityId/resourceInstance/:id/changeVersion", + "GET_requirements_capabilities": "/v1/catalog/requirmentsCapabilities/:type/:id", + "GET_resource_artifact_types": "/v1/artifactTypes", + "GET_product_catalog": "/v1/productScreen", + "GET_product_category": "/v1/productCategories", + "GET_product_category_temp": "/v1/artifactTypes", + "POST_product": "/v1/catalog/products/:id/metadata", + "GET_product_validate_name": "/v1/catalog/services/validate-name/:name", + "GET_product": "/v1/catalog/products/:id", + "GET_product_sub_category": "/v1/productSubCategories", + "GET_onboarding": "/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/packages", + "GET_component_from_csar_uuid": "/v1/catalog/resources/csar/:csar_uuid", + "kibana": "/sdc1/kibanaProxy/" + }, + "resourceTypesFilter":{ + "resource":["CP","VFC","VL"], + "service":["CP","VF","VL"], + "product":[] + }, + "logConfig": { + "minLogLevel": "debug", + "prefix": "sdcApp" + }, + "cookie": { + "junctionName": "IV_JCT", + "prefix": "AMWEBJCT!", + "userIdSuffix": "USER_ID", + "userFirstName": "HTTP_CSP_FIRSTNAME", + "userLastName": "HTTP_CSP_LASTNAME", + "userEmail": "HTTP_CSP_EMAIL", + "xEcompRequestId": " X-ECOMP-RequestID" + }, + "imagesPath": "/sdc1", + "cpEndPointInstances" : ["cloudep","ossep","personep","premisesep"], + "toscaFileExtension":"yaml,yml", + "csarFileExtension":"csar", + "showOutlook": false, + "validationConfigPath":"sdc1/configurations/validation.json", + "categories": {}, + "testers": { + "RESOURCE": { + "Network L2-3": "DL-ASDCL1-3ResourceCertificationTeam", + "Network L4+": "DL-ASDCL4-7ResourceCertificationTeam", + "Application L4+": "DL-ASDCL4-7ResourceCertificationTeam", + "default": "DL-ASDCL1-3ResourceCertificationTeam;DL-ASDCL4-7ResourceCertificationTeam" + }, + "SERVICE": { + "Network L1-3": "DL-ASDCL1-4ServiceCertificationTeam", + "Network L4+": "DL-ASDCL4-7ServiceCertificationTeam", + "default": "DL-ASDCL1-4ServiceCertificationTeam;DL-ASDCL4-7ServiceCertificationTeam" + } + }, + "roles": ["ADMIN", "TESTER", "GOVERNOR", "OPS", "DESIGNER", "PRODUCT_MANAGER", "PRODUCT_STRATEGIST"], + "tutorial": { + "tabs": [ + { + "id":1, + "name":"TUTRIAL_GENERAL_TAB_1", + "defaultPage":1 + }, + { + "id":2, + "name":"TUTRIAL_GENERAL_TAB_2", + "defaultPage":9 + }, + { + "id":3, + "name":"TUTRIAL_GENERAL_TAB_3", + "defaultPage":12 + } + ], + "pages": + [ + { + "id":1, + "template": "text-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE1_TITLE", + "description":"TUTORIAL_PAGE1_TEXT" + } + + }, + { + "id":2, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE2_TITLE", + "description":"TUTORIAL_PAGE2_TEXT", + "imageClass":"sdc-tutorial-page-2-image" + } + }, + { + "id":3, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE3_TITLE", + "description":"TUTORIAL_PAGE3_TEXT", + "imageClass":"sdc-tutorial-page-3-image" + } + }, + { + "id":4, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE4_TITLE", + "description":"TUTORIAL_PAGE4_TEXT", + "imageClass":"sdc-tutorial-page-4-image" + } + }, + { + "id":5, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE5_TITLE", + "description":"TUTORIAL_PAGE5_TEXT", + "imageClass":"sdc-tutorial-page-5-image" + } + }, + { + "id":6, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE6_TITLE", + "description":"TUTORIAL_PAGE6_TEXT", + "imageClass":"sdc-tutorial-page-6-image" + } + }, + { + "id":7, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE7_TITLE", + "description":"TUTORIAL_PAGE7_TEXT", + "imageClass":"sdc-tutorial-page-7-image" + } + }, + { + "id":8, + "template": "image-template", + "tab": 1, + "data":{ + "title":"TUTORIAL_PAGE8_TITLE", + "description":"TUTORIAL_PAGE8_TEXT", + "imageClass":"sdc-tutorial-page-8-image" + } + }, + { + "id":9, + "template": "text-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE9_TITLE", + "description":"TUTORIAL_PAGE9_TEXT" + } + }, + { + "id":10, + "template": "image-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE10_TITLE", + "description":"TUTORIAL_PAGE10_TEXT", + "imageClass":"sdc-tutorial-page-10-image" + } + }, + { + "id":11, + "template": "image-template", + "tab": 2, + "data":{ + "title":"TUTORIAL_PAGE11_TITLE", + "description":"TUTORIAL_PAGE11_TEXT", + "imageClass":"sdc-tutorial-page-11-image" + } + }, + { + "id":12, + "template": "text-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE12_TITLE", + "description":"TUTORIAL_PAGE12_TEXT" + } + }, + { + "id":13, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE13_TITLE", + "description":"TUTORIAL_PAGE13_TEXT", + "imageClass":"sdc-tutorial-page-13-image" + } + }, + { + "id":14, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE14_TITLE", + "description":"TUTORIAL_PAGE14_TEXT", + "imageClass":"sdc-tutorial-page-14-image" + } + }, + { + "id":15, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE15_TITLE", + "description":"TUTORIAL_PAGE15_TEXT", + "imageClass":"sdc-tutorial-page-15-image" + } + }, + { + "id":16, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE16_TITLE", + "description":"TUTORIAL_PAGE16_TEXT", + "imageClass":"sdc-tutorial-page-16-image" + } + }, + { + "id":17, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE17_TITLE", + "description":"TUTORIAL_PAGE17_TEXT", + "imageClass":"sdc-tutorial-page-17-image" + } + }, + { + "id":18, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE18_TITLE", + "description":"TUTORIAL_PAGE18_TEXT", + "imageClass":"sdc-tutorial-page-18-image" + } + }, + { + "id":19, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE19_TITLE", + "description":"TUTORIAL_PAGE19_TEXT", + "imageClass":"sdc-tutorial-page-19-image" + } + }, + { + "id":20, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE20_TITLE", + "description":"TUTORIAL_PAGE20_TEXT", + "imageClass":"sdc-tutorial-page-20-image" + } + }, + { + "id":21, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE21_TITLE", + "description":"TUTORIAL_PAGE21_TEXT", + "imageClass":"sdc-tutorial-page-21-image" + } + }, + { + "id":22, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE22_TITLE", + "description":"TUTORIAL_PAGE22_TEXT", + "imageClass":"sdc-tutorial-page-22-image" + } + }, + { + "id":23, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE23_TITLE", + "description":"TUTORIAL_PAGE23_TEXT", + "imageClass":"sdc-tutorial-page-23-image" + } + }, + { + "id":24, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE24_TITLE", + "description":"TUTORIAL_PAGE24_TEXT", + "imageClass":"sdc-tutorial-page-24-image" + } + }, + { + "id":25, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE25_TITLE", + "description":"TUTORIAL_PAGE25_TEXT", + "imageClass":"sdc-tutorial-page-25-image" + } + }, + { + "id":26, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE26_TITLE", + "description":"TUTORIAL_PAGE26_TEXT", + "imageClass":"sdc-tutorial-page-26-image" + } + }, + { + "id":27, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE27_TITLE", + "description":"TUTORIAL_PAGE27_TEXT", + "imageClass":"sdc-tutorial-page-27-image" + } + }, + { + "id":28, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE28_TITLE", + "description":"TUTORIAL_PAGE28_TEXT", + "imageClass":"sdc-tutorial-page-28-image" + } + }, + { + "id":29, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE29_TITLE", + "description":"TUTORIAL_PAGE29_TEXT", + "imageClass":"sdc-tutorial-page-29-image" + } + }, + { + "id":30, + "template": "image-template", + "tab": 3, + "data":{ + "title":"TUTORIAL_PAGE30_TITLE", + "description":"TUTORIAL_PAGE30_TEXT", + "imageClass":"sdc-tutorial-page-30-image" + } + } + + ] + } + +}; + +module.exports = SDC_CONFIG; diff --git a/catalog-ui/configurations/prod.json b/catalog-ui/configurations/prod.json deleted file mode 100644 index cbe579c3e9..0000000000 --- a/catalog-ui/configurations/prod.json +++ /dev/null @@ -1,432 +0,0 @@ -{ - "environment": "prod", - "api": { - - "GET_component": "/v1/catalog/:type/:id", - "PUT_component": "/v1/catalog/:type/:id/metadata", - "GET_component_validate_name": "/v1/catalog/:type/validate-name/:name", - "POST_changeLifecycleState": "/v1/catalog/", - "component_api_root": "/v1/catalog/", - "welcome_page_video_url": "http://0.0.0.0:8282/moti/movie", - - "GET_user": "/v1/user/:id", - "GET_user_authorize": "/v1/user/authorize", - "GET_all_users": "/v1/user/users", - "POST_create_user": "/v1/user", - "DELETE_delete_user": "/v1/user/:id", - "POST_edit_user_role": "/v1/user/:id/role", - "GET_resource": "/v1/catalog/resources/:id", - "GET_resources_latestversion_notabstract":"/v1/catalog/:type/latestversion/notabstract/:id", - "GET_resources_certified_not_abstract": "/v1/catalog/resources/certified/notabstract/:id", - "GET_resources_certified_abstract": "/v1/catalog/resources/certified/abstract/:id", - "GET_resource_property": "/v1/catalog/:type/:entityId/properties/:id", - "PUT_resource": "/v1/catalog/resources/:id/metadata", - "GET_resource_artifact": "/v1/catalog/:type/:entityId/artifacts/:id", - "GET_download_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstances/:instanceId/artifacts/:id", - "POST_instance_artifact": "/v1/catalog/:type/:entityId/resourceInstance/:instanceId/artifacts/:id", - "GET_resource_additional_information": "/v1/catalog/:type/:entityId/additionalinfo/:id", - "GET_service_artifact": "/v1/catalog/services/:serviceId/artifacts/:id", - "GET_resource_interface_artifact": "/v1/catalog/:type/:entityId/standard/:operation/artifacts/:id", - "GET_resource_api_artifact": "/v1/catalog/:type/:entityId/artifacts/api/:id", - "GET_configuration_ui": "/v1/configuration/ui", - "GET_resource_validate_name": "/v1/catalog/resources/validate-name/:name", - "GET_activity_log": "/v1/catalog/audit-records/:type/:id", - "GET_service": "/v1/catalog/services/:id", - "GET_service_validate_name": "/v1/catalog/services/validate-name/:name", - "GET_service_distributions":"/v1/catalog/services/:uuid/distribution", - "GET_service_distributions_components":"/v1/catalog/services/distribution/:distributionId", - "POST_service_distribution_deploy" : "/v1/catalog/services/:serviceId/distribution/:distributionId/markDeployed", - "GET_element": "/v1/followed", - "GET_catalog": "/v1/screen", - "GET_ecomp_menu_items": "/v1/user/:userId/functionalmenu", - "GET_resource_category": "/v1/resourceCategories", - "GET_service_category": "/v1/serviceCategories", - "resource_instance": "/v1/catalog/:entityType/:entityId/resourceInstance/:id", - "GET_resource_instance_property": "/v1/catalog/:type/:entityId/resourceInstance/:componentInstanceId/property/:propertyValueId", - "GET_relationship": "/v1/catalog/:entityType/:entityId/resourceInstance/:action", - "GET_lifecycle_state_resource": "/v1/catalog/:type/:id/lifecycleState/:action", - "GET_lifecycle_state_CHECKIN":"lifecycleState/CHECKIN", - "GET_lifecycle_state_CERTIFICATIONREQUEST":"lifecycleState/CERTIFICATIONREQUEST", - "GET_lifecycle_state_UNDOCHECKOUT":"lifecycleState/UNDOCHECKOUT", - "root": "/sdc1/feProxy/rest", - "PUT_service": "/v1/catalog/services/:id/metadata", - "GET_download_artifact": "/v1/catalog/", - "GET_SDC_Version": "/version", - "GET_categories": "/v1/categories/:types", - "POST_category": "/v1/category/:types/:categoryId", - "POST_subcategory": "/v1/category/:types/:categoryId/subCategory/:subCategoryId", - "POST_change_instance_version": "/v1/catalog/:entityType/:entityId/resourceInstance/:id/changeVersion", - "GET_requirements_capabilities": "/v1/catalog/requirmentsCapabilities/:type/:id", - "GET_resource_artifact_types": "/v1/artifactTypes", - "GET_product_catalog": "/v1/productScreen", - "GET_product_category": "/v1/productCategories", - "GET_product_category_temp": "/v1/artifactTypes", - "POST_product": "/v1/catalog/products/:id/metadata", - "GET_product_validate_name": "/v1/catalog/services/validate-name/:name", - "GET_product": "/v1/catalog/products/:id", - "GET_product_sub_category": "/v1/productSubCategories", - "GET_onboarding": "/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/packages", - "GET_component_from_csar_uuid": "/v1/catalog/resources/csar/:csar_uuid", - "kibana": "/sdc1/kibanaProxy/" - }, - "resourceTypesFilter":{ - "resource":["CP","VFC"], - "service":["CP","VF"], - "product":[] - }, - "logConfig": { - "minLogLevel": "debug", - "prefix": "sdcApp" - }, - "cookie": { - "junctionName": "IV_JCT", - "prefix": "AMWEBJCT!", - "userIdSuffix": "USER_ID", - "userFirstName": "HTTP_CSP_FIRSTNAME", - "userLastName": "HTTP_CSP_LASTNAME", - "userEmail": "HTTP_CSP_EMAIL", - "xEcompRequestId": " X-ECOMP-RequestID" - }, - "imagesPath": "/sdc1", - "cpEndPointInstances" : ["cloudep","ossep","personep","premisesep"], - "toscaFileExtension":"yaml,yml", - "csarFileExtension":"csar", - "openSource": true, - "categories": {}, - "testers": { - "RESOURCE": { - "Network L2-3": "DL-ASDCL1-3ResourceCertificationTeam", - "Network L4+": "DL-ASDCL4-7ResourceCertificationTeam", - "Application L4+": "DL-ASDCL4-7ResourceCertificationTeam", - "default": "DL-ASDCL1-3ResourceCertificationTeam;DL-ASDCL4-7ResourceCertificationTeam" - }, - "SERVICE": { - "Network L1-3": "DL-ASDCL1-4ServiceCertificationTeam", - "Network L4+": "DL-ASDCL4-7ServiceCertificationTeam", - "default": "DL-ASDCL1-4ServiceCertificationTeam;DL-ASDCL4-7ServiceCertificationTeam" - } - }, - "roles": ["ADMIN", "TESTER", "GOVERNOR", "OPS", "DESIGNER", "PRODUCT_MANAGER", "PRODUCT_STRATEGIST"], - "tutorial": { - "tabs": [ - { - "id":1, - "name":"TUTRIAL_GENERAL_TAB_1", - "defaultPage":1 - }, - { - "id":2, - "name":"TUTRIAL_GENERAL_TAB_2", - "defaultPage":9 - }, - { - "id":3, - "name":"TUTRIAL_GENERAL_TAB_3", - "defaultPage":12 - } - ], - "pages": - [ - { - "id":1, - "template": "text-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE1_TITLE", - "description":"TUTORIAL_PAGE1_TEXT" - } - - }, - { - "id":2, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE2_TITLE", - "description":"TUTORIAL_PAGE2_TEXT", - "imageClass":"sdc-tutorial-page-2-image" - } - }, - { - "id":3, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE3_TITLE", - "description":"TUTORIAL_PAGE3_TEXT", - "imageClass":"sdc-tutorial-page-3-image" - } - }, - { - "id":4, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE4_TITLE", - "description":"TUTORIAL_PAGE4_TEXT", - "imageClass":"sdc-tutorial-page-4-image" - } - }, - { - "id":5, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE5_TITLE", - "description":"TUTORIAL_PAGE5_TEXT", - "imageClass":"sdc-tutorial-page-5-image" - } - }, - { - "id":6, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE6_TITLE", - "description":"TUTORIAL_PAGE6_TEXT", - "imageClass":"sdc-tutorial-page-6-image" - } - }, - { - "id":7, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE7_TITLE", - "description":"TUTORIAL_PAGE7_TEXT", - "imageClass":"sdc-tutorial-page-7-image" - } - }, - { - "id":8, - "template": "image-template", - "tab": 1, - "data":{ - "title":"TUTORIAL_PAGE8_TITLE", - "description":"TUTORIAL_PAGE8_TEXT", - "imageClass":"sdc-tutorial-page-8-image" - } - }, - { - "id":9, - "template": "text-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE9_TITLE", - "description":"TUTORIAL_PAGE9_TEXT" - } - }, - { - "id":10, - "template": "image-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE10_TITLE", - "description":"TUTORIAL_PAGE10_TEXT", - "imageClass":"sdc-tutorial-page-10-image" - } - }, - { - "id":11, - "template": "image-template", - "tab": 2, - "data":{ - "title":"TUTORIAL_PAGE11_TITLE", - "description":"TUTORIAL_PAGE11_TEXT", - "imageClass":"sdc-tutorial-page-11-image" - } - }, - { - "id":12, - "template": "text-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE12_TITLE", - "description":"TUTORIAL_PAGE12_TEXT" - } - }, - { - "id":13, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE13_TITLE", - "description":"TUTORIAL_PAGE13_TEXT", - "imageClass":"sdc-tutorial-page-13-image" - } - }, - { - "id":14, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE14_TITLE", - "description":"TUTORIAL_PAGE14_TEXT", - "imageClass":"sdc-tutorial-page-14-image" - } - }, - { - "id":15, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE15_TITLE", - "description":"TUTORIAL_PAGE15_TEXT", - "imageClass":"sdc-tutorial-page-15-image" - } - }, - { - "id":16, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE16_TITLE", - "description":"TUTORIAL_PAGE16_TEXT", - "imageClass":"sdc-tutorial-page-16-image" - } - }, - { - "id":17, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE17_TITLE", - "description":"TUTORIAL_PAGE17_TEXT", - "imageClass":"sdc-tutorial-page-17-image" - } - }, - { - "id":18, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE18_TITLE", - "description":"TUTORIAL_PAGE18_TEXT", - "imageClass":"sdc-tutorial-page-18-image" - } - }, - { - "id":19, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE19_TITLE", - "description":"TUTORIAL_PAGE19_TEXT", - "imageClass":"sdc-tutorial-page-19-image" - } - }, - { - "id":20, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE20_TITLE", - "description":"TUTORIAL_PAGE20_TEXT", - "imageClass":"sdc-tutorial-page-20-image" - } - }, - { - "id":21, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE21_TITLE", - "description":"TUTORIAL_PAGE21_TEXT", - "imageClass":"sdc-tutorial-page-21-image" - } - }, - { - "id":22, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE22_TITLE", - "description":"TUTORIAL_PAGE22_TEXT", - "imageClass":"sdc-tutorial-page-22-image" - } - }, - { - "id":23, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE23_TITLE", - "description":"TUTORIAL_PAGE23_TEXT", - "imageClass":"sdc-tutorial-page-23-image" - } - }, - { - "id":24, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE24_TITLE", - "description":"TUTORIAL_PAGE24_TEXT", - "imageClass":"sdc-tutorial-page-24-image" - } - }, - { - "id":25, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE25_TITLE", - "description":"TUTORIAL_PAGE25_TEXT", - "imageClass":"sdc-tutorial-page-25-image" - } - }, - { - "id":26, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE26_TITLE", - "description":"TUTORIAL_PAGE26_TEXT", - "imageClass":"sdc-tutorial-page-26-image" - } - }, - { - "id":27, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE27_TITLE", - "description":"TUTORIAL_PAGE27_TEXT", - "imageClass":"sdc-tutorial-page-27-image" - } - }, - { - "id":28, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE28_TITLE", - "description":"TUTORIAL_PAGE28_TEXT", - "imageClass":"sdc-tutorial-page-28-image" - } - }, - { - "id":29, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE29_TITLE", - "description":"TUTORIAL_PAGE29_TEXT", - "imageClass":"sdc-tutorial-page-29-image" - } - }, - { - "id":30, - "template": "image-template", - "tab": 3, - "data":{ - "title":"TUTORIAL_PAGE30_TITLE", - "description":"TUTORIAL_PAGE30_TEXT", - "imageClass":"sdc-tutorial-page-30-image" - } - } - - ] - } - -} diff --git a/catalog-ui/configurations/validation.json b/catalog-ui/configurations/validation.json new file mode 100644 index 0000000000..01b899d7bd --- /dev/null +++ b/catalog-ui/configurations/validation.json @@ -0,0 +1,12 @@ +{ + "propertyValue": { + "max": 2500, + "min": 0 + }, + + "validationPatterns": { + "string": "^[\\sa-zA-Z0-9+-]+$", + "comment": "^[\\u0000-\\u00BF]*$", + "integer": "^(([-+]?\\d+)|([-+]?0x[0-9a-fA-F]+))$" + } +} diff --git a/catalog-ui/docs/colors.jpg b/catalog-ui/docs/colors.jpg Binary files differdeleted file mode 100644 index edc038c0d2..0000000000 --- a/catalog-ui/docs/colors.jpg +++ /dev/null diff --git a/catalog-ui/e2e/app.e2e-spec.ts b/catalog-ui/e2e/app.e2e-spec.ts new file mode 100644 index 0000000000..914805e00c --- /dev/null +++ b/catalog-ui/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { CatalogUiPage } from './app.po'; + +describe('catalog-ui App', function() { + let page: CatalogUiPage; + + beforeEach(() => { + page = new CatalogUiPage(); + }); + + it('should display message saying app works', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('app works!'); + }); +}); diff --git a/catalog-ui/e2e/app.po.ts b/catalog-ui/e2e/app.po.ts new file mode 100644 index 0000000000..8084cae329 --- /dev/null +++ b/catalog-ui/e2e/app.po.ts @@ -0,0 +1,11 @@ +import { browser, element, by } from 'protractor'; + +export class CatalogUiPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/catalog-ui/e2e/tsconfig.json b/catalog-ui/e2e/tsconfig.json new file mode 100644 index 0000000000..656bdb14ff --- /dev/null +++ b/catalog-ui/e2e/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "module": "commonjs", + "moduleResolution": "node", + "outDir": "../dist/out-tsc-e2e", + "sourceMap": true, + "target": "es5", + "typeRoots": [ + "../node_modules/@types" + ] + } +} diff --git a/catalog-ui/karma.conf.js b/catalog-ui/karma.conf.js new file mode 100644 index 0000000000..1f2613a346 --- /dev/null +++ b/catalog-ui/karma.conf.js @@ -0,0 +1,43 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', 'angular-cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-remap-istanbul'), + require('angular-cli/plugins/karma') + ], + files: [ + { pattern: './src/test.ts', watched: false } + ], + preprocessors: { + './src/test.ts': ['angular-cli'] + }, + mime: { + 'text/x-typescript': ['ts','tsx'] + }, + remapIstanbulReporter: { + reports: { + html: 'coverage', + lcovonly: './coverage/coverage.lcov' + } + }, + angularCli: { + config: './angular-cli.json', + environment: 'dev' + }, + reporters: config.angularCli && config.angularCli.codeCoverage + ? ['progress', 'karma-remap-istanbul'] + : ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/README.md b/catalog-ui/non_bower_components/cytoscape.js-edge-editation/README.md deleted file mode 100644 index 909dcb06d1..0000000000 --- a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# cytoscape.js-edge-editation -Extension for Cytoscape.js, which adds handles to nodes and allows to create different types of edges - - -## Dependencies - -Extension was tested with these versions of libraries: - -* jQuery 2.1.1 -* Cytoscape.js 2.6.0 - -## Install - -Use git clone or direct zip download and unpack archive into your project. Then, simply insert \<script\> tag after -Cytoscape.js and jQuery: - -```html -<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script> -<script src="cytoscape.js"></script> -<script src="CytoscapeEdgeEditation.js"></script> -``` - -## How to use - -First, you need to initialize extension. After initializing Cytoscape.js: - -```js -var cy = cytoscape({...}); -var handles = new CytoscapeEdgeEditation; -handles.init(cy); -``` - -Then, you need to register handles to certain node types: - -```js -handles.registerHandle({ - positionX: "left", //horizontal position of the handle (left | center | right) - positionY: "center", //vertical position of the handle (top | center | bottom) - color: "#48FF00", //color of the handle - type: "some_type", //stored as data() attribute, can be used for styling - single: true, //wheter only one edge of this type can start from same node (default false) - nodeTypeNames: ["type2"] //which types of nodes will contain this handle - noMultigraph: false //whereter two nodes can't be connected with multiple edges (does not consider orientation) -}); - -handles.registerHandle({...}); -handles.registerHandle({...}); -``` - -Type of node is stored in data section: - -```js -cy.add({ - data: { id: 'n4', type: "type2"}, -}); -``` -![Screenshot](http://i.imgbox.com/drCuXQqu.png) -![Screenshot](http://i.imgbox.com/23jr7qPa.png) diff --git a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/index.html b/catalog-ui/non_bower_components/cytoscape.js-edge-editation/index.html deleted file mode 100644 index d19fd36c24..0000000000 --- a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/index.html +++ /dev/null @@ -1,169 +0,0 @@ -<!doctype html> -<html lang="cs"> -<head> - <meta charset="UTF-8"> - <title>CytoscapeEdgeEditation</title> - <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script> - <script src="bower_components/cytoscape/dist/cytoscape.js"></script> - <script src="CytoscapeEdgeEditation.js"></script> - <script> - $(function(){ - //INITIALIZATION - var domContainer = $(".cy"); - var cy = cytoscape({ - container: domContainer, - style: [ - { - selector: 'node[type="type1"]', - style: { - 'background-color': '#FFEB12', - } - }, - { - selector: 'node[type="type2"]', - style: { - 'background-color': '#2CE8F2', - } - }, - { - selector: 'edge', - style: { - 'width': 3, - 'target-arrow-shape': 'triangle' - } - }, - { - selector: 'edge[type="default"]', - style: { - 'line-color': 'green', - 'target-arrow-color': 'green', - } - }, - { - selector: 'edge[type="yes"]', - style: { - 'line-color': '#48FF00', - 'target-arrow-color': '#48FF00', - } - }, - { - selector: 'edge[type="no"]', - style: { - 'line-color': '#ED1000', - 'target-arrow-color': '#ED1000', - } - } - ] - }); - - - var handles = new CytoscapeEdgeEditation; - handles.init(cy); - - handles.registerHandle({ - positionX: "center", - positionY: "bottom", - color: "green", - type: "default", - single: false, - nodeTypeNames: ["type1"] - }); - - handles.registerHandle({ - positionX: "center", - positionY: "top", - color: "green", - type: "default", - single: false, - nodeTypeNames: ["type1"] - }); - - handles.registerHandle({ - positionX: "left", - positionY: "center", - color: "green", - type: "default", - single: false, - nodeTypeNames: ["type1"] - }); - - handles.registerHandle({ - positionX: "right", - positionY: "center", - color: "green", - type: "default", - single: false, - nodeTypeNames: ["type1"] - // noMultigraph: true - }); - - handles.registerHandle({ - positionX: "left", - positionY: "center", - color: "#48FF00", - type: "yes", - single: true, - nodeTypeNames: ["type2"] - }); - - handles.registerHandle({ - positionX: "right", - positionY: "center", - color: "#ED1000", - type: "no", - single: true, - nodeTypeNames: ["type2"] - }); - - - //ADD NODES - cy.add({ - data: { id: 'n1', type: "type1"}, - }); - - cy.add({ - data: { id: 'n2', type: "type1"}, - }); - - cy.add({ - data: { id: 'n3', type: "type1"}, - }); - - cy.add({ - data: { id: 'n4', type: "type2"}, - }); - - - //ADJUST HEIGHT - var resizeViewport = function(){ - $(".cy").height($(window).height()); - cy.resize(); - }; - - $(window).resize(resizeViewport); - resizeViewport(); - - //LAYOUT - cy.layout({ - name: 'random', - fit: true, - padding: 40, - boundingBox: {x1: -200, y1:-200, x2:300, y2: 200} - }); - }); - </script> - <style> - * { - padding: 0; - margin: 0; - } - .cy { - width: 100%; - height:100%; - } - </style> -</head> -<body> - <div class="cy"></div> -</body> -</html>
\ No newline at end of file diff --git a/catalog-ui/package.json b/catalog-ui/package.json index beb2af9996..075d059753 100644 --- a/catalog-ui/package.json +++ b/catalog-ui/package.json @@ -1,41 +1,45 @@ { "name": "catalog-ui", - "description": "ASDC Single page application", + "version": "1707.1.0", + "description": "SDC Single page application", + "main": "src/main.ts", + "author": "", "repository": { "type": "git", "url": "git@gitlab:root/D2-SDnC.git" }, + "scripts": { + "designer": "npm start -- --env.role designer", + "tester": "npm start -- --env.role tester", + "ops": "npm start -- --env.role ops", + "governor": "npm start -- --env.role governor", + "admin": "npm start -- --env.role admin", + "start": "webpack-dev-server", + "build": "webpack --config webpack.config.js", + "build:prod": "webpack --config webpack.production.js", + "test": "karma start ./karma.conf.js", + "lint": "ng lint", + "e2e": "protractor ./protractor.conf.js", + "pree2e": "webdriver-manager update --standalone false --gecko false --quiet" + }, "devDependencies": { "apache-server-configs": "^2.7.1", + "autoprefixer": "^6.5.3", + "copy-webpack-plugin": "^4.0.1", "cors": "2.7.1", - "grunt": "1.0.1", - "grunt-angular-templates": "1.1.0", - "grunt-autoprefixer": "3.0.4", - "grunt-concurrent": "0.5.0", - "grunt-contrib-clean": "1.0.0", - "grunt-contrib-concat": "1.0.1", - "grunt-contrib-connect": "0.10.1", - "grunt-contrib-copy": "1.0.0", - "grunt-contrib-cssmin": "0.10.0", - "grunt-contrib-htmlmin": "2.1.0", - "grunt-contrib-imagemin": "1.0.1", - "grunt-contrib-jshint": "1.1.0", - "grunt-contrib-uglify": "2.0.0", - "grunt-contrib-watch": "1.0.0", - "grunt-include-source": "1.0.0", - "grunt-karma": "2.0.0", - "grunt-mocha": "1.0.2", - "grunt-newer": "0.7.0", - "grunt-ng-constant": "1.1.0", - "grunt-rev": "0.1.0", - "grunt-svgmin": "4.0.0", - "grunt-text-replace": "0.4.0", - "grunt-tslint": "^3.3.0", - "grunt-usemin": "3.1.1", - "grunt-wiredep": "2.0.0", + "css-loader": "^0.26.1", + "cssnano": "^3.10.0", + "exports-loader": "^0.6.3", + "express": "^4.14.0", + "extract-text-webpack-plugin": "^2.1.0", + "file-loader": "^0.10.0", + "html-loader": "^0.4.5", + "html-webpack-plugin": "^2.28.0", "http-proxy-middleware": "^0.14.0", + "istanbul-instrumenter-loader": "^2.0.0", "jasmine-core": "2.5.2", "jshint-stylish": "2.2.1", + "json-loader": "^0.5.4", "karma": "1.4.0", "karma-chrome-launcher": "0.2.2", "karma-coverage": "1.1.1", @@ -45,23 +49,98 @@ "karma-ng-html2js-preprocessor": "1.0.0", "karma-ng-scenario": "1.0.0", "karma-phantomjs-launcher": "0.2.1", + + "karma-sourcemap-loader": "^0.3.7", + "less": "^2.7.2", + "less-loader": "^2.2.3", "load-grunt-tasks": "3.5.2", "phantomjs": "2.1.7", + "postcss-loader": "^0.13.0", + "postcss-url": "^5.1.2", + "raw-loader": "^0.5.1", + "sass-loader": "^4.1.1", + "script-loader": "^0.7.0", + "source-map-loader": "^0.1.5", + "style-loader": "^0.13.1", + "stylus-loader": "^2.4.0", "time-grunt": "1.4.0", - "tslint": "^3.15.1" + "url-loader": "^0.5.7", + "webpack-dev-middleware": "^1.10.1", + "webpack-dev-server": "~2.3.0" }, "engines": { "node": ">=6.9.4" }, "dependencies": { + "@angular/cli": "^1.0.0-rc.1", + "@angular/common": "^2.4.8", + "@angular/compiler": "^2.4.8", + "@angular/compiler-cli": "^2.4.8", + "@angular/core": "^2.4.8", + "@angular/forms": "^2.4.8", + "@angular/http": "^2.4.8", + "@angular/platform-browser": "^2.4.8", + "@angular/platform-browser-dynamic": "^2.4.8", + "@angular/router": "^3.4.8", + "@angular/upgrade": "^2.4.8", + "@types/core-js": "^0.9.35", + "@types/js-md5": "^0.4.0", + "@types/lodash": "^4.14.52", + "@types/node": "^7.0.5", + "@types/q": "0.0.32", + "angular": "^1.6.2", + "angular-base64": "^2.0.5", + "angular-base64-upload": "^0.1.19", + "angular-clipboard": "^1.5.0", + "angular-dragdrop": "github:dimkinv/angular-dragdrop", + "angular-filter": "^0.5.15", + "angular-resizable": "^1.2.0", + "angular-resource": "1.5.11", + "angular-sanitize": "^1.4.4", + "angular-tooltips": "0.1.23", + "angular-translate": "^2.15.1", + "angular-translate-loader-static-files": "^2.15.1", + "angular-ui-bootstrap": "1.3.3", + "angular-ui-notification": "^0.3.6", + "angular-ui-router": "^0.4.2", + "angular-uuid4": "^0.3.1", + "angular2-uuid": "^1.1.1", + "animate.css": "^3.5.2", + "awesome-typescript-loader": "^3.0.8", + "babel-core": "^6.23.1", + "babel-loader": "^6.3.2", + "bootstrap": "^3.3.7", + "checklist-model": "^0.11.0", + "class-transformer": "^0.1.6", + "clean-webpack-plugin": "^0.1.16", + "codelyzer": "^2.0.1", + "core-js": "^2.4.1", + "cytoscape": "^2.7.15", + "cytoscape-expand-collapse": "github:bardit/cytoscape.js-expand-collapse", + "cytoscape-qtip": "github:bardit/cytoscape.js-qtip", "cytoscape.js-undo-redo": "^1.0.1", "express": "4.14.0", - "grunt-asset-injector": "0.1.0", - "grunt-contrib-less": "1.4.0", - "grunt-express-server": "0.5.3", - "grunt-ts": "5.5.1", - "grunt-html2js": "0.3.6", + "jquery": "^2.2.4", + "jqueryui": "^1.11.1", + "js-md5": "^0.4.2", + "lodash": "^4.17.2", "multer": "1.2.1", - "ng-html2js": "2.0.0" + "ng-html2js": "2.0.0", + "ng-infinite-scroll": "^1.3.0", + "perfect-scrollbar": "^0.6.16", + "qtip2": "^3.0.3", + "reflect-metadata": "^0.1.10", + "restangular": "^1.6.1", + "rxjs": "^5.2.0", + "ts-helpers": "^1.1.2", + "ts-node": "^2.1.0", + "tslint": "^4.4.2", + "typescript": "^2.1.6", + "typings": "^2.1.0", + "underscore": "^1.8.3", + "webpack": "^2.2.1", + "webpack-dev-server": "^2.4.1", + "webpack-merge": "^4.0.0", + "zone.js": "^0.7.7" } } diff --git a/catalog-ui/pom.xml b/catalog-ui/pom.xml index 1825fd3f2c..9923a6bfa5 100644 --- a/catalog-ui/pom.xml +++ b/catalog-ui/pom.xml @@ -5,7 +5,7 @@ <groupId>org.openecomp.sdc</groupId> <artifactId>catalog-ui</artifactId> - <packaging>pom</packaging> + <packaging>pom</packaging> <parent> @@ -25,166 +25,36 @@ <plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.6.1</version> - <executions> - <execution> - <id>clean.fe.webapp.folder</id> - <phase>initialize</phase> - <goals> - <goal>clean</goal> - </goals> - <configuration> + <executions> + <execution> + <id>clean.fe.webapp.folder</id> + <phase>initialize</phase> + <goals> + <goal>clean</goal> + </goals> + <configuration> - <filesets> - <fileset> - <directory>${project.parent.basedir}/catalog-fe/src/main/webapp</directory> - <includes> - <include>**/*</include> - <include>*</include> - </includes> - <excludes> - <exclude>META-INF/*</exclude> - <exclude>WEB-INF/*</exclude> - </excludes> - <followSymlinks>false</followSymlinks> - </fileset> - </filesets> - </configuration> - </execution> - </executions> + <filesets> + <fileset> + <directory>${project.parent.basedir}/catalog-fe/src/main/webapp</directory> + <includes> + <include>**/*</include> + <include>*</include> + </includes> + <excludes> + <exclude>META-INF/*</exclude> + <exclude>WEB-INF/*</exclude> + </excludes> + <followSymlinks>false</followSymlinks> + </fileset> + </filesets> + </configuration> + </execution> + </executions> </plugin> <plugin> - <groupId>io.wcm.maven.plugins</groupId> - <artifactId>nodejs-maven-plugin</artifactId> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - <configuration> - <tasks> - <npmInstallTask> - <workingDirectory>${project.basedir}</workingDirectory> - </npmInstallTask> - <nodeJsTask> - <workingDirectory>${project.basedir}</workingDirectory> - <moduleName>bower</moduleName> - <arguments> - <argument>install</argument> - </arguments> - </nodeJsTask> - <nodeJsTask> - <workingDirectory>${project.basedir}</workingDirectory> - <moduleName>grunt</moduleName> - <arguments> - <argument>build</argument> - </arguments> - </nodeJsTask> - <!-- <npmInstallTask> - <workingDirectory>${project.basedir}</workingDirectory> - </npmInstallTask> - <nodeJsTask> - <workingDirectory>${project.basedir}</workingDirectory> - <moduleName>gulp</moduleName> - <arguments> - <argument>build</argument> - </arguments> - </nodeJsTask> --> - </tasks> - </configuration> - </plugin> - - - <!-- <plugin> - <groupId>com.github.eirslett</groupId> - <artifactId>frontend-maven-plugin</artifactId> - <version>1.3</version> - <configuration> - <nodeVersion>v7.5.0</nodeVersion> - <nodeDownloadRoot>https://nodejs.org/dist/</nodeDownloadRoot> - <npmDownloadRoot>https://nodejs.org/dist/npm/</npmDownloadRoot> - <installDirectory>./</installDirectory> - </configuration> - <executions> - <execution> - <id>install node and npm</id> - <goals> - <goal>install-node-and-npm</goal> - </goals> - <phase>generate-resources</phase> - </execution> - - <execution> - <id>npm install bower</id> - <goals> - <goal>npm</goal> - </goals> - - <phase>generate-resources</phase> - - <configuration> - <arguments>install bower</arguments> - </configuration> - </execution> - - <execution> - <id>npm install grunt-cli</id> - <goals> - <goal>npm</goal> - </goals> - - <phase>generate-resources</phase> - - <configuration> - <arguments>install grunt-cli</arguments> - </configuration> - </execution> - - <execution> - <id>npm install</id> - <goals> - <goal>npm</goal> - </goals> - - <phase>generate-resources</phase> - - <configuration> - <arguments>install</arguments> - </configuration> - </execution> - - <execution> - <id>bower install</id> - <goals> - <goal>bower</goal> - </goals> - - <configuration> - <arguments>install</arguments> - </configuration> - </execution> - - <execution> - <id>grunt build</id> - <goals> - <goal>grunt</goal> - </goals> - - <phase>generate-resources</phase> - - <configuration> - <arguments>build</arguments> - </configuration> - </execution> - - </executions> - </plugin> - --> - <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <executions> @@ -198,7 +68,7 @@ <outputDirectory>${project.parent.basedir}/catalog-fe/src/main/webapp</outputDirectory> <resources> <resource> - <directory>${project.basedir}/app/dist</directory> + <directory>${project.basedir}/dist</directory> <filtering>false</filtering> </resource> </resources> @@ -206,14 +76,56 @@ </execution> </executions> </plugin> + <plugin> + <groupId>com.github.eirslett</groupId> + <artifactId>frontend-maven-plugin</artifactId> + <version>1.4</version> + + <executions> + + <execution> + <id>install node and npm</id> + <goals> + <goal>install-node-and-npm</goal> + </goals> + <configuration> + <!-- See https://nodejs.org/en/download/ for latest node and npm (lts) versions --> + <nodeVersion>v6.9.5</nodeVersion> + <npmVersion>3.10.10</npmVersion> + </configuration> + </execution> + + <execution> + <id>npm install</id> + <goals> + <goal>npm</goal> + </goals> + <!-- Optional configuration which provides for running any npm command --> + <configuration> + <arguments>install</arguments> + </configuration> + </execution> + + <execution> + <id>npm run build</id> + <goals> + <goal>npm</goal> + </goals> + <configuration> + <arguments>run build:prod</arguments> + </configuration> + </execution> + </executions> + </plugin> + </plugins> </build> - <profiles> + <profiles> <profile> - <id>not-minified</id> + <id>CI</id> <activation> <activeByDefault>false</activeByDefault> </activation> @@ -230,27 +142,12 @@ <goals> <goal>copy-resources</goal> </goals> + <configuration> <outputDirectory>${project.parent.basedir}/catalog-fe/src/main/webapp</outputDirectory> <resources> <resource> - <directory>${project.basedir}/app</directory> - <includes> - <include>languages/**</include> - <include>scripts/**</include> - <include>styles/**</include> - <include>third-party/**</include> - <include>index.html</include> - <include>robots.txt</include> - <include>favicon.png</include> - </includes> - <filtering>false</filtering> - </resource> - <resource> - <directory>${project.basedir}</directory> - <includes> - <include>bower_components/**</include> - </includes> + <directory>${project.basedir}/dist</directory> <filtering>false</filtering> </resource> </resources> @@ -258,9 +155,146 @@ </execution> </executions> </plugin> + + + + <!-- ============================================= --> + <!-- Build the UI module node code --> + <!-- ============================================= --> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.4.0</version> + <executions> + + <!-- Set execution permissions for the build script --> + <execution> + <id>set.script.permissions</id> + <phase>generate-sources</phase> + <goals> + <goal>exec</goal> + </goals> + + <configuration> + <workingDirectory>${project.basedir}</workingDirectory> + <executable>/bin/chmod</executable> + <arguments> + <argument>755</argument> + <argument>./build_catalog_ui.sh</argument> + </arguments> + </configuration> + </execution> + + <!-- Run the build script --> + <execution> + <id>execute grant build</id> + <phase>generate-sources</phase> + <goals> + <goal>exec</goal> + </goals> + + <configuration> + <workingDirectory>${project.basedir}</workingDirectory> + <executable>./build_catalog_ui.sh</executable> + </configuration> + </execution> + + <!-- Undo checkout the build script --> + <execution> + <id>undo.checkout.script</id> + <phase>generate-sources</phase> + <goals> + <goal>exec</goal> + </goals> + + <configuration> + <workingDirectory>${project.basedir}</workingDirectory> + <executable>/usr/bin/git</executable> + <arguments> + <argument>checkout</argument> + <argument>--</argument> + <argument>./build_catalog_ui.sh</argument> + </arguments> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </profile> + + + <profile> + <id>Fortify</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + + <build> + <plugins> + <plugin> + <groupId>com.fortify.ps.maven.plugin</groupId> + <artifactId>sca-maven-plugin</artifactId> + <version>4.30</version> + <configuration> + <source>1.8</source> + <buildId>${project.parent.artifactId}</buildId> + <toplevelArtifactId>${project.parent.artifactId}</toplevelArtifactId> + </configuration> + </plugin> + </plugins> + </build> + </profile> + + <profile> + <id>not-minified</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + + <build> + <plugins> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <version>2.7</version> + <executions> + <execution> + <id>copy-resources</id> + <phase>package</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.parent.basedir}/catalog-fe/src/main/webapp</outputDirectory> + <resources> + <resource> + <directory>${project.basedir}/app</directory> + <includes> + <include>languages/**</include> + <include>scripts/**</include> + <include>styles/**</include> + <include>third-party/**</include> + <include>index.html</include> + <include>robots.txt</include> + <include>favicon.png</include> + </includes> + <filtering>false</filtering> + </resource> + <resource> + <directory>${project.basedir}</directory> + <includes> + <include>bower_components/**</include> + </includes> + <filtering>false</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> diff --git a/catalog-ui/protractor.conf.js b/catalog-ui/protractor.conf.js new file mode 100644 index 0000000000..ffded70180 --- /dev/null +++ b/catalog-ui/protractor.conf.js @@ -0,0 +1,32 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +/*global jasmine */ +var SpecReporter = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + useAllAngular2AppRoots: true, + beforeLaunch: function() { + require('ts-node').register({ + project: 'e2e' + }); + }, + onPrepare: function() { + jasmine.getEnv().addReporter(new SpecReporter()); + } +}; diff --git a/catalog-ui/server-mock/mock-data/artifact/artifact-types.json b/catalog-ui/server-mock/mock-data/artifact/artifact-types.json deleted file mode 100644 index b9cdabee51..0000000000 --- a/catalog-ui/server-mock/mock-data/artifact/artifact-types.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "name": "CHEF" - }, - { - "name": "PUPPET" - }, - { - "name": "SHELL" - }, - { - "name": "YANG" - }, - { - "name": "HEAT" - }, - { - "name": "BPEL" - }, - { - "name": "DG-XML" - } -] diff --git a/catalog-ui/server-mock/mock-data/category/category.json b/catalog-ui/server-mock/mock-data/category/category.json deleted file mode 100644 index 2dabb50ba6..0000000000 --- a/catalog-ui/server-mock/mock-data/category/category.json +++ /dev/null @@ -1,65 +0,0 @@ -[ - { - "name": "Infrastructure" - }, - { - "name": "Databases" - }, - { - "name": "Web Servers" - }, - { - "name": "Web Applications" - }, - { - "name": "Network Elements" - }, - { - "name": "VoIP" - }, - { - "name": "IMS" - }, - { - "name": "Security" - }, - { - "name": "Video" - }, - { - "name": "Mobility" - }, - { - "name": "IoT" - }, - { - "name": "Big Data" - }, - { - "name": "WAN Connectivity" - }, - { - "name": "LAN Connectivity" - }, - { - "name": "Compute as a Service" - }, - { - "name": "Platform as a Service" - }, - { - "name": "Storage as a Service" - }, - { - "name": "Call Control" - }, - { - "name": "Collaboration" - }, - { - "name": "Messaging" - }, - { - "name": "Abstract" - } -] diff --git a/catalog-ui/server-mock/mock-data/element/element.json b/catalog-ui/server-mock/mock-data/element/element.json deleted file mode 100644 index 181c0edcf2..0000000000 --- a/catalog-ui/server-mock/mock-data/element/element.json +++ /dev/null @@ -1,2915 +0,0 @@ -{ - "resources": [ - { - "uniqueId": "res_hgdgg.0.1", - "resourceName": "hgdgg", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1435825652946, - "lastUpdateDate": 1435825652946, - "description": "hfhdgfdgfh", - "icon": "icon-red2", - "tags": [ - "hgdgg" - ], - "category": "Call Control", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebApplication" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "app_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webapplication.1.0.app_endpoint", - "type": "tosca.capabilities.Endpoint" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.webapplication.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.WebServer", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "fhgghf", - "vendorRelease": "fggf", - "contactId": "hg1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_martin223.0.1", - "resourceName": "martin223", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1435842460057, - "lastUpdateDate": 1435842460057, - "description": "desc", - "icon": "icon-red2", - "tags": [ - "martin223", - "tag" - ], - "category": "Databases", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.5", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_mlrlv.0.1", - "resourceName": "mlrlv", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436079916172, - "lastUpdateDate": 1436079916172, - "description": "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", - "icon": "icon-red2", - "tags": [ - "mlrlvtag" - ], - "category": "Databases", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.4", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_%&+-.0.1", - "resourceName": "%&+-", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436079975445, - "lastUpdateDate": 1436079975445, - "description": "%&+-%&+-%&+-%&+-%&+-%&+-", - "icon": "icon-red2", - "tags": [ - "%&+-%&+-" - ], - "category": "Databases", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "%&+-", - "vendorRelease": "%&+-", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_1.0.1", - "resourceName": "1", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436080002091, - "lastUpdateDate": 1436080002091, - "description": "1", - "icon": "icon-red2", - "tags": [ - "11" - ], - "category": "Databases", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "1", - "vendorRelease": "1", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_jjjjjj.0.1", - "resourceName": "jjjjjj", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436080425475, - "lastUpdateDate": 1436080425475, - "description": "h", - "icon": "icon-red2", - "tags": [ - "jjjjjj" - ], - "category": "Collaboration", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - "10 numbers limit reached": { - "uniqueId": "res_jjjjjj.0.1.10 numbers limit reached", - "artifactType": "CHEF", - "artifactName": "10 numbers limit reached.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436081038417, - "lastUpdateDate": 1436081038417, - "esId": "res_jjjjjj.0.1:10 numbers limit reached.png", - "logicalName": "10 numbers limit reached", - "description": "dsfsdfs" - } - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "g", - "vendorRelease": "f", - "contactId": "aa1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_qfdsy.0.1", - "resourceName": "qfdsy", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436084743821, - "lastUpdateDate": 1436084743821, - "description": "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", - "icon": "icon-red2", - "tags": [ - "qfdsytag" - ], - "category": "Messaging", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.4", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_nqstw.0.1", - "resourceName": "nqstw", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436084798999, - "lastUpdateDate": 1436084798999, - "description": "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", - "icon": "icon-red2", - "tags": [ - "nqstwtag" - ], - "category": "WAN Connectivity", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.4", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_rfpjx.0.1", - "resourceName": "rfpjx", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436084844179, - "lastUpdateDate": 1436084844179, - "description": "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬-®¯°±²³´µ¶•¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", - "icon": "icon-red2", - "tags": [ - "rfpjxtag" - ], - "category": "Messaging", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.4", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_martin22.0.1", - "resourceName": "martin22", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436093847314, - "lastUpdateDate": 1436093847314, - "description": "desc", - "icon": "icon-red2", - "tags": [ - "martin22", - "martin22tag" - ], - "category": "Security", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - "gizmorambo": { - "uniqueId": "res_martin22.0.1.gizmorambo", - "artifactType": "YANG", - "artifactName": "gizmorambo.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436093856933, - "lastUpdateDate": 1436093856933, - "esId": "res_martin22.0.1:gizmorambo.jpg", - "logicalName": "gizmorambo", - "description": "BlaBla" - } - }, - "properties": { - "Test1": { - "uniqueId": "res_martin22.0.1.Test1", - "type": "string", - "required": false, - "defaultValue": "10", - "description": "BlaBla", - "constraints": [ - { - "rangeMinValue": "100", - "rangeMaxValue": "990" - } - ], - "definition": true, - "password": false - } - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.5", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_jkjk.0.1", - "resourceName": "jkjk", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436095288548, - "lastUpdateDate": 1436095288548, - "description": "jkjkj", - "icon": "icon-red2", - "tags": [ - "jkjk" - ], - "category": "Big Data", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Container.Runtime" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.container.runtime.1.0.host", - "type": "tosca.capabilities.Container" - }, - "scalable": { - "uniqueId": "capability.res_tosca.nodes.container.runtime.1.0.scalable", - "type": "tosca.capabilities.Scalable" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "gggg", - "vendorRelease": "fffff", - "contactId": "ff1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_bvbvcxb.0.1", - "resourceName": "bvbvcxb", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436164182890, - "lastUpdateDate": 1436164182890, - "description": "vcbcv", - "icon": "icon-red2", - "tags": [ - "bvbvcxb" - ], - "category": "Call Control", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "vcbxcvb", - "vendorRelease": "cvbvc", - "contactId": "qw1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_sd.0.1", - "resourceName": "sd", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436255440040, - "lastUpdateDate": 1436255440040, - "description": "de", - "icon": "icon-red3", - "tags": [ - "sdde" - ], - "category": "Call Control", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "ded", - "vendorRelease": "ede", - "contactId": "dd2222", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_martin221.0.1", - "resourceName": "martin221", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436275310912, - "lastUpdateDate": 1436275310912, - "description": "desc", - "icon": "icon-red2", - "tags": [ - "martin221", - "martin221tag" - ], - "category": "Security", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.5", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_gfnfgf.0.1", - "resourceName": "gfnfgf", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436275654252, - "lastUpdateDate": 1436275654252, - "description": "hfghfgh", - "icon": "icon-red2", - "tags": [ - "gfnfgf" - ], - "category": "Call Control", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "gfhgf", - "vendorRelease": "gfhgf", - "contactId": "gg1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_ddd.0.1", - "resourceName": "ddd", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436338105711, - "lastUpdateDate": 1436338105711, - "description": "dsff", - "icon": "icon-red1", - "tags": [ - "sddd" - ], - "category": "Big Data", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.SoftwareComponent" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "sadfasdf", - "vendorRelease": "adsfadsf", - "contactId": "ds200p", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_hhdfd.0.1", - "resourceName": "hhdfd", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436342424025, - "lastUpdateDate": 1436342424025, - "description": "fdhdffh", - "icon": "icon-red2", - "tags": [ - "hhdfd" - ], - "category": "Big Data", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "fdhfddfh", - "vendorRelease": "fdhdf", - "contactId": "fg1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_infobae.0.1", - "resourceName": "infobae", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436346185743, - "lastUpdateDate": 1436346185743, - "description": "es el", - "icon": "icon-red2", - "tags": [ - "infobae" - ], - "category": "Big Data", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebApplication" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "app_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webapplication.1.0.app_endpoint", - "type": "tosca.capabilities.Endpoint" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.webapplication.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.WebServer", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "ffff", - "vendorRelease": "ffff", - "contactId": "ss1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_df.0.1", - "resourceName": "df", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436352980564, - "lastUpdateDate": 1436352980564, - "description": "sdf", - "icon": "icon-red2", - "tags": [ - "dfsdf" - ], - "category": "Messaging", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "sdf", - "vendorRelease": "sdf", - "contactId": "jh7654", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_ddddd.0.1", - "resourceName": "ddddd", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436353021637, - "lastUpdateDate": 1436353021637, - "description": "ddsd", - "icon": "icon-red2", - "tags": [ - "ddddd" - ], - "category": "Compute as a Service", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.Root" - ], - "artifacts": { - "misdevices": { - "uniqueId": "res_ddddd.0.1.misdevices", - "artifactType": "PUPPET", - "artifactName": "misdevices.docx", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436353036161, - "lastUpdateDate": 1436353036161, - "esId": "res_ddddd.0.1:misdevices.docx", - "logicalName": "misdevices", - "description": "eeeeee" - } - }, - "interfaces": { - - }, - "capabilities": { - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - } - }, - "vendorName": "dfsd", - "vendorRelease": "ddddd", - "contactId": "ss1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_yo.0.1", - "resourceName": "yo", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436369145382, - "lastUpdateDate": 1436369145382, - "description": "dddd", - "icon": "icon-red2", - "tags": [ - "yo" - ], - "category": "Collaboration", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.WebServer" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.WebApplication" - ] - }, - "admin_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.admin_endpoint", - "type": "tosca.capabilities.Endpoint.Admin" - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - }, - "data_endpoint": { - "uniqueId": "capability.res_tosca.nodes.webserver.1.0.data_endpoint", - "type": "tosca.capabilities.Endpoint" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "dds", - "vendorRelease": "ssss", - "contactId": "ss1234", - "abstract": false, - "highestVersion": true - }, - { - "uniqueId": "res_martin2213.0.1", - "resourceName": "martin2213", - "resourceVersion": "0.1", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "creationDate": 1436369231581, - "lastUpdateDate": 1436369231581, - "description": "desc", - "icon": "icon-red2", - "tags": [ - "martin2213", - "martin2213tag" - ], - "category": "Messaging", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT", - "derivedFrom": [ - "tosca.nodes.DBMS" - ], - "artifacts": { - - }, - "interfaces": { - - }, - "capabilities": { - "host": { - "uniqueId": "capability.res_tosca.nodes.dbms.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.Database" - ] - }, - "feature": { - "uniqueId": "capability.res_tosca.nodes.root.1.0.feature", - "type": "tosca.capabilities.Node" - } - }, - "requirements": { - "dependency": { - "uniqueId": "res_tosca.nodes.root.1.0.dependency", - "capability": "tosca.capabilities.Node", - "node": "tosca.nodes.Root", - "relationship": "tosca.relationships.DependsOn" - }, - "host": { - "uniqueId": "res_tosca.nodes.softwarecomponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "relationship": "tosca.relationships.HostedOn" - } - }, - "vendorName": "Oracle", - "vendorRelease": "1.2.5", - "contactId": "Al1234", - "abstract": false, - "highestVersion": true - } - ], - "services": [ - { - "componentMetadataDefinition": { - "uniqueId": "svc_wduma.0.1", - "name": "wduma", - "version": "0.1", - "creationDate": 1436081587500, - "lastUpdateDate": 1436081587500, - "description": "BLa BLa", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "wduma", - "wdumatag" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Databases", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "wduma", - "creationDate": 1436081587500, - "icon": "network_l_4", - "version": "0.1", - "description": "BLa BLa", - "tags": [ - "wduma", - "wdumatag" - ], - "uniqueId": "svc_wduma.0.1", - "lastUpdateDate": 1436081587500, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_r.0.1", - "name": "r", - "version": "0.1", - "creationDate": 1436083434172, - "lastUpdateDate": 1436083434172, - "description": "r", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "rrrr" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "IoT", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "r", - "creationDate": 1436083434172, - "icon": "network_l_4", - "version": "0.1", - "description": "r", - "tags": [ - "rrrr" - ], - "uniqueId": "svc_r.0.1", - "lastUpdateDate": 1436083434172, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_otdiz.0.1", - "name": "otdiz", - "version": "0.1", - "creationDate": 1436094819610, - "lastUpdateDate": 1436094819610, - "description": "BLa BLa", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "otdiz", - "otdiztag" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Platform as a Service", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "otdiz", - "creationDate": 1436094819610, - "icon": "network_l_4", - "version": "0.1", - "description": "BLa BLa", - "tags": [ - "otdiz", - "otdiztag" - ], - "uniqueId": "svc_otdiz.0.1", - "lastUpdateDate": 1436094819610, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_gxkvl.0.1", - "name": "gxkvl", - "version": "0.1", - "creationDate": 1436094992972, - "lastUpdateDate": 1436094992972, - "description": "BLa BLa", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "gxkvl", - "gxkvltag" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Security", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "gxkvl", - "creationDate": 1436094992972, - "icon": "network_l_4", - "version": "0.1", - "description": "BLa BLa", - "tags": [ - "gxkvl", - "gxkvltag" - ], - "uniqueId": "svc_gxkvl.0.1", - "lastUpdateDate": 1436094992972, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_testservice.0.1", - "name": "testService", - "version": "0.1", - "creationDate": 1436098158942, - "lastUpdateDate": 1436098158942, - "description": "description", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "tag1" - ], - "icon": "myICON.jpg", - "highestVersion": true - }, - "artifacts": { - "install_apache": { - "uniqueId": "svc_testservice.0.1.install_apache", - "artifactType": "SHELL", - "artifactName": "install_apache.sh", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436098195328, - "lastUpdateDate": 1436098195328, - "esId": "svc_testservice.0.1:install_apache.sh", - "logicalName": "install_apache" - } - }, - "category": "Databases", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "testService", - "creationDate": 1436098158942, - "icon": "myICON.jpg", - "version": "0.1", - "description": "description", - "tags": [ - "tag1" - ], - "uniqueId": "svc_testservice.0.1", - "lastUpdateDate": 1436098158942, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_newtestservice5.0.1", - "name": "newTestService5", - "version": "0.1", - "creationDate": 1436111412660, - "lastUpdateDate": 1436111412660, - "description": "service Description", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "newTestService5", - "serviceTag" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Big Data", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "newTestService5", - "creationDate": 1436111412660, - "icon": "network_l_4", - "version": "0.1", - "description": "service Description", - "tags": [ - "newTestService5", - "serviceTag" - ], - "uniqueId": "svc_newtestservice5.0.1", - "lastUpdateDate": 1436111412660, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_newtestservice.0.1", - "name": "newTestService", - "version": "0.1", - "creationDate": 1436114463660, - "lastUpdateDate": 1436114463660, - "description": "service Description", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "serviceTag" - ], - "icon": "myIcon.jpg", - "vendorName": "Oracle", - "vendorRelease": "0.1", - "contactId": "al1976", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Big Data", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "newTestService", - "creationDate": 1436114463660, - "icon": "myIcon.jpg", - "version": "0.1", - "description": "service Description", - "tags": [ - "serviceTag" - ], - "uniqueId": "svc_newtestservice.0.1", - "lastUpdateDate": 1436114463660, - "contactId": "al1976", - "vendorName": "Oracle", - "vendorRelease": "0.1", - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_éø⦹.0.1", - "name": "éø¦¹", - "version": "0.1", - "creationDate": 1436168481712, - "lastUpdateDate": 1436168481712, - "description": "service Description", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "éø¦¹", - "éø¦¹serviceTag" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Big Data", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "éø¦¹", - "creationDate": 1436168481712, - "icon": "network_l_4", - "version": "0.1", - "description": "service Description", - "tags": [ - "éø¦¹", - "éø¦¹serviceTag" - ], - "uniqueId": "svc_éø⦹.0.1", - "lastUpdateDate": 1436168481712, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_mmmm.0.1", - "name": "mmmm", - "version": "0.1", - "creationDate": 1436175721980, - "lastUpdateDate": 1436175721980, - "description": "jjjj", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "mmmm" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "Subtitle": { - "uniqueId": "svc_mmmm.0.1.Subtitle", - "artifactType": "SHELL", - "artifactName": "Subtitle.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436180446882, - "lastUpdateDate": 1436180446882, - "esId": "svc_mmmm.0.1:Subtitle.png", - "logicalName": "Subtitle", - "description": "dfdssfsd" - }, - "10 numbers limit reached": { - "uniqueId": "svc_mmmm.0.1.10 numbers limit reached", - "artifactType": "SHELL", - "artifactName": "10 numbers limit reached.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436178322094, - "lastUpdateDate": 1436178322094, - "esId": "svc_mmmm.0.1:10 numbers limit reached.png", - "logicalName": "10 numbers limit reached", - "description": "hdfhdfhddf" - }, - "Screenshot_2014-09-08-13-07-49": { - "uniqueId": "svc_mmmm.0.1.Screenshot_2014-09-08-13-07-49", - "artifactType": "SHELL", - "artifactName": "Screenshot_2014-09-08-13-07-49.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436180394486, - "lastUpdateDate": 1436180394486, - "esId": "svc_mmmm.0.1:Screenshot_2014-09-08-13-07-49.png", - "logicalName": "Screenshot_2014-09-08-13-07-49", - "description": "fdgfdgfdg" - }, - "Slow upload ": { - "uniqueId": "svc_mmmm.0.1.Slow upload ", - "artifactType": "SHELL", - "artifactName": "Slow upload .png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436180490467, - "lastUpdateDate": 1436180490467, - "esId": "svc_mmmm.0.1:Slow upload .png", - "logicalName": "Slow upload ", - "description": "sdffdsfds" - }, - "img009": { - "uniqueId": "svc_mmmm.0.1.img009", - "artifactType": "PUPPET", - "artifactName": "img009.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436178135843, - "lastUpdateDate": 1436178135843, - "esId": "svc_mmmm.0.1:img009.jpg", - "logicalName": "img009", - "description": "hhhhh" - }, - "casa1": { - "uniqueId": "svc_mmmm.0.1.casa1", - "artifactType": "HEAT", - "artifactName": "casa1.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436180424159, - "lastUpdateDate": 1436180424159, - "esId": "svc_mmmm.0.1:casa1.JPG", - "logicalName": "casa1", - "description": "fgsdfsdsdf" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "mmmm", - "creationDate": 1436175721980, - "icon": "network_l_4", - "version": "0.1", - "description": "jjjj", - "tags": [ - "mmmm" - ], - "uniqueId": "svc_mmmm.0.1", - "lastUpdateDate": 1436175721980, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fgfdgdfg.0.1", - "name": "fgfdgdfg", - "version": "0.1", - "creationDate": 1436189750913, - "lastUpdateDate": 1436189750913, - "description": "fgdfgdf", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fgfdgdfg" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Databases", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fgfdgdfg", - "creationDate": 1436189750913, - "icon": "network_l_4", - "version": "0.1", - "description": "fgdfgdf", - "tags": [ - "fgfdgdfg" - ], - "uniqueId": "svc_fgfdgdfg.0.1", - "lastUpdateDate": 1436189750913, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_jujuy.0.1", - "name": "jujuy", - "version": "0.1", - "creationDate": 1436190515151, - "lastUpdateDate": 1436190515151, - "description": "gfhdf", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "jujuyggg" - ], - "icon": "network_l_1-3", - "highestVersion": true - }, - "artifacts": { - "ServicePanel": { - "uniqueId": "svc_jujuy.0.1.ServicePanel", - "artifactType": "SHELL", - "artifactName": "ServicePanel.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436191109314, - "lastUpdateDate": 1436191109314, - "esId": "svc_jujuy.0.1:ServicePanel.JPG", - "logicalName": "ServicePanel", - "description": "ddddddddddddddddddd" - }, - "IconEnd": { - "uniqueId": "svc_jujuy.0.1.IconEnd", - "artifactType": "PUPPET", - "artifactName": "IconEnd.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436190528852, - "lastUpdateDate": 1436190528852, - "esId": "svc_jujuy.0.1:IconEnd.JPG", - "logicalName": "IconEnd", - "description": "fffffff" - }, - "IconCenter": { - "uniqueId": "svc_jujuy.0.1.IconCenter", - "artifactType": "SHELL", - "artifactName": "IconCenter.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436190584441, - "lastUpdateDate": 1436190584441, - "esId": "svc_jujuy.0.1:IconCenter.JPG", - "logicalName": "IconCenter", - "description": "fffff" - }, - "udateresource": { - "uniqueId": "svc_jujuy.0.1.udateresource", - "artifactType": "YANG", - "artifactName": "udateresource.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436191131313, - "lastUpdateDate": 1436191131313, - "esId": "svc_jujuy.0.1:udateresource.JPG", - "logicalName": "udateresource", - "description": "dddd" - }, - "toobolar": { - "uniqueId": "svc_jujuy.0.1.toobolar", - "artifactType": "SHELL", - "artifactName": "toobolar.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436191146471, - "lastUpdateDate": 1436191146471, - "esId": "svc_jujuy.0.1:toobolar.JPG", - "logicalName": "toobolar", - "description": "sssssssssssssss" - } - }, - "category": "Collaboration", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "jujuy", - "creationDate": 1436190515151, - "icon": "network_l_1-3", - "version": "0.1", - "description": "gfhdf", - "tags": [ - "jujuyggg" - ], - "uniqueId": "svc_jujuy.0.1", - "lastUpdateDate": 1436190515151, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_martin39.0.1", - "name": "martin39", - "version": "0.1", - "creationDate": 1436252371041, - "lastUpdateDate": 1436252371041, - "description": "fffffff", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "martin39" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "toobolar": { - "uniqueId": "svc_martin39.0.1.toobolar", - "artifactType": "SHELL", - "artifactName": "toobolar.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436252434415, - "lastUpdateDate": 1436252434415, - "esId": "svc_martin39.0.1:toobolar.JPG", - "logicalName": "toobolar", - "description": "ffff" - } - }, - "category": "Compute as a Service", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "martin39", - "creationDate": 1436252371041, - "icon": "network_l_4", - "version": "0.1", - "description": "fffffff", - "tags": [ - "martin39" - ], - "uniqueId": "svc_martin39.0.1", - "lastUpdateDate": 1436252371041, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_asdasd.0.1", - "name": "asdasd", - "version": "0.1", - "creationDate": 1436253177668, - "lastUpdateDate": 1436253177668, - "description": "asdasd", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "asdasd" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Collaboration", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "asdasd", - "creationDate": 1436253177668, - "icon": "network_l_4", - "version": "0.1", - "description": "asdasd", - "tags": [ - "asdasd" - ], - "uniqueId": "svc_asdasd.0.1", - "lastUpdateDate": 1436253177668, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fgdfgfd.0.1", - "name": "fgdfgfd", - "version": "0.1", - "creationDate": 1436255258481, - "lastUpdateDate": 1436255258481, - "description": "dfgdfg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fgdfgfd" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Compute as a Service", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fgdfgfd", - "creationDate": 1436255258481, - "icon": "network_l_4", - "version": "0.1", - "description": "dfgdfg", - "tags": [ - "fgdfgfd" - ], - "uniqueId": "svc_fgdfgfd.0.1", - "lastUpdateDate": 1436255258481, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fdgd.0.1", - "name": "fdgd", - "version": "0.1", - "creationDate": 1436257427821, - "lastUpdateDate": 1436257427821, - "description": "fdg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fdgd" - ], - "icon": "call_controll", - "highestVersion": true - }, - "artifacts": { - "toobolar": { - "uniqueId": "svc_fdgd.0.1.toobolar", - "artifactType": "SHELL", - "artifactName": "toobolar.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436257614747, - "lastUpdateDate": 1436257614747, - "esId": "svc_fdgd.0.1:toobolar.JPG", - "logicalName": "toobolar", - "description": "dfsdfsd" - } - }, - "category": "Compute as a Service", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fdgd", - "creationDate": 1436257427821, - "icon": "call_controll", - "version": "0.1", - "description": "fdg", - "tags": [ - "fdgd" - ], - "uniqueId": "svc_fdgd.0.1", - "lastUpdateDate": 1436257427821, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fdgdfgfd.0.1", - "name": "fdgdfgfd", - "version": "0.1", - "creationDate": 1436266653797, - "lastUpdateDate": 1436266653797, - "description": "fdfdgf", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fdgdfgfd" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "IMG_20141222_072027": { - "uniqueId": "svc_fdgdfgfd.0.1.IMG_20141222_072027", - "artifactType": "SHELL", - "artifactName": "IMG_20141222_072027.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436267970999, - "lastUpdateDate": 1436267970999, - "esId": "svc_fdgdfgfd.0.1:IMG_20141222_072027.jpg", - "logicalName": "IMG_20141222_072027", - "description": "FEDF" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fdgdfgfd", - "creationDate": 1436266653797, - "icon": "network_l_4", - "version": "0.1", - "description": "fdfdgf", - "tags": [ - "fdgdfgfd" - ], - "uniqueId": "svc_fdgdfgfd.0.1", - "lastUpdateDate": 1436266653797, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fbgvdfb.0.1", - "name": "fbgvdfb", - "version": "0.1", - "creationDate": 1436267394596, - "lastUpdateDate": 1436267394596, - "description": "sdbdbs", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fbgvdfb" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "IMG_20140413_185621": { - "uniqueId": "svc_fbgvdfb.0.1.IMG_20140413_185621", - "artifactType": "YANG", - "artifactName": "IMG_20140413_185621.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436267701461, - "lastUpdateDate": 1436267701461, - "esId": "svc_fbgvdfb.0.1:IMG_20140413_185621.jpg", - "logicalName": "IMG_20140413_185621", - "description": "ACSCA" - }, - "IMG_20140413_185643": { - "uniqueId": "svc_fbgvdfb.0.1.IMG_20140413_185643", - "artifactType": "CHEF", - "artifactName": "IMG_20140413_185643.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436267871628, - "lastUpdateDate": 1436267871628, - "esId": "svc_fbgvdfb.0.1:IMG_20140413_185643.jpg", - "logicalName": "IMG_20140413_185643", - "description": "ASDFAWSE" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fbgvdfb", - "creationDate": 1436267394596, - "icon": "network_l_4", - "version": "0.1", - "description": "sdbdbs", - "tags": [ - "fbgvdfb" - ], - "uniqueId": "svc_fbgvdfb.0.1", - "lastUpdateDate": 1436267394596, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_asdasds.0.1", - "name": "asdasds", - "version": "0.1", - "creationDate": 1436268972057, - "lastUpdateDate": 1436268972057, - "description": "asdasdasd", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "asdasds" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Collaboration", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "asdasds", - "creationDate": 1436268972057, - "icon": "network_l_4", - "version": "0.1", - "description": "asdasdasd", - "tags": [ - "asdasds" - ], - "uniqueId": "svc_asdasds.0.1", - "lastUpdateDate": 1436268972057, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_kkkkk.0.1", - "name": "kkkkk", - "version": "0.1", - "creationDate": 1436271848416, - "lastUpdateDate": 1436271848416, - "description": "hggh", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "kkkkk" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "dessaper": { - "uniqueId": "svc_kkkkk.0.1.dessaper", - "artifactType": "SHELL", - "artifactName": "dessaper.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436271866025, - "lastUpdateDate": 1436271866025, - "esId": "svc_kkkkk.0.1:dessaper.JPG", - "logicalName": "dessaper", - "description": "fgdf" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "kkkkk", - "creationDate": 1436271848416, - "icon": "network_l_4", - "version": "0.1", - "description": "hggh", - "tags": [ - "kkkkk" - ], - "uniqueId": "svc_kkkkk.0.1", - "lastUpdateDate": 1436271848416, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_alex.0.1", - "name": "alex", - "version": "0.1", - "creationDate": 1436276482974, - "lastUpdateDate": 1436276482974, - "description": "Bla Bla", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "alex", - "ddd" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "pencil": { - "uniqueId": "svc_alex.0.1.pencil", - "artifactType": "CHEF", - "artifactName": "pencil.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436276810898, - "lastUpdateDate": 1436276810898, - "esId": "svc_alex.0.1:pencil.JPG", - "logicalName": "pencil", - "description": "nk" - }, - "Web Accessibility": { - "uniqueId": "svc_alex.0.1.Web Accessibility", - "artifactType": "HEAT", - "artifactName": "Web Accessibility.pptx", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436276689984, - "lastUpdateDate": 1436276689984, - "esId": "svc_alex.0.1:Web Accessibility.pptx", - "logicalName": "Web Accessibility", - "description": "dfhgf" - }, - "toobolar": { - "uniqueId": "svc_alex.0.1.toobolar", - "artifactType": "CHEF", - "artifactName": "toobolar.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436276821186, - "lastUpdateDate": 1436276821186, - "esId": "svc_alex.0.1:toobolar.JPG", - "logicalName": "toobolar", - "description": "dgrt" - } - }, - "category": "IoT", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "alex", - "creationDate": 1436276482974, - "icon": "network_l_4", - "version": "0.1", - "description": "Bla Bla", - "tags": [ - "alex", - "ddd" - ], - "uniqueId": "svc_alex.0.1", - "lastUpdateDate": 1436276482974, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_martin392.0.1", - "name": "martin392", - "version": "0.1", - "creationDate": 1436276986104, - "lastUpdateDate": 1436276986104, - "description": "ddddd", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "martin392" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Collaboration", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "martin392", - "creationDate": 1436276986104, - "icon": "network_l_4", - "version": "0.1", - "description": "ddddd", - "tags": [ - "martin392" - ], - "uniqueId": "svc_martin392.0.1", - "lastUpdateDate": 1436276986104, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_alex1.0.1", - "name": "Alex1", - "version": "0.1", - "creationDate": 1436277034499, - "lastUpdateDate": 1436277034499, - "description": "vvg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "Alex1" - ], - "icon": "network_l_1-3", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "IoT", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "Alex1", - "creationDate": 1436277034499, - "icon": "network_l_1-3", - "version": "0.1", - "description": "vvg", - "tags": [ - "Alex1" - ], - "uniqueId": "svc_alex1.0.1", - "lastUpdateDate": 1436277034499, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_alex2.0.1", - "name": "Alex2", - "version": "0.1", - "creationDate": 1436277071235, - "lastUpdateDate": 1436277071235, - "description": "sas", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "Alex2" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Big Data", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "Alex2", - "creationDate": 1436277071235, - "icon": "network_l_4", - "version": "0.1", - "description": "sas", - "tags": [ - "Alex2" - ], - "uniqueId": "svc_alex2.0.1", - "lastUpdateDate": 1436277071235, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_gfhgfhfg.0.1", - "name": "gfhgfhfg", - "version": "0.1", - "creationDate": 1436337425800, - "lastUpdateDate": 1436337425800, - "description": "fghg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "gfhgfhgfgfhfg" - ], - "icon": "network_l_1-3", - "highestVersion": true - }, - "artifacts": { - "Footer_menu": { - "uniqueId": "svc_gfhgfhfg.0.1.Footer_menu", - "artifactType": "SHELL", - "artifactName": "Footer_menu.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436337460108, - "lastUpdateDate": 1436337460108, - "esId": "svc_gfhgfhfg.0.1:Footer_menu.JPG", - "logicalName": "Footer_menu", - "description": "gfhgfh" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "gfhgfhfg", - "creationDate": 1436337425800, - "icon": "network_l_1-3", - "version": "0.1", - "description": "fghg", - "tags": [ - "gfhgfhgfgfhfg" - ], - "uniqueId": "svc_gfhgfhfg.0.1", - "lastUpdateDate": 1436337425800, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fffffdd.0.1", - "name": "fffffdd", - "version": "0.1", - "creationDate": 1436342516321, - "lastUpdateDate": 1436342516321, - "description": "fdgg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fffffdd" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fffffdd", - "creationDate": 1436342516321, - "icon": "network_l_4", - "version": "0.1", - "description": "fdgg", - "tags": [ - "fffffdd" - ], - "uniqueId": "svc_fffffdd.0.1", - "lastUpdateDate": 1436342516321, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_martin.0.1", - "name": "martin", - "version": "0.1", - "creationDate": 1436342857036, - "lastUpdateDate": 1436342857036, - "description": "gggg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "martin" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "martin", - "creationDate": 1436342857036, - "icon": "network_l_4", - "version": "0.1", - "description": "gggg", - "tags": [ - "martin" - ], - "uniqueId": "svc_martin.0.1", - "lastUpdateDate": 1436342857036, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_fghj.0.1", - "name": "fghj", - "version": "0.1", - "creationDate": 1436343201655, - "lastUpdateDate": 1436343201655, - "description": "fghjfhj", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "fghj" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Big Data", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "fghj", - "creationDate": 1436343201655, - "icon": "network_l_4", - "version": "0.1", - "description": "fghjfhj", - "tags": [ - "fghj" - ], - "uniqueId": "svc_fghj.0.1", - "lastUpdateDate": 1436343201655, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_lol.0.1", - "name": "lol", - "version": "0.1", - "creationDate": 1436343380208, - "lastUpdateDate": 1436343380208, - "description": "ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggddddddddddddddddddddddddddddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssss", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "lol" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "10 numbers limit reached": { - "uniqueId": "svc_lol.0.1.10 numbers limit reached", - "artifactType": "SHELL", - "artifactName": "10 numbers limit reached.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436344950166, - "lastUpdateDate": 1436344950166, - "esId": "svc_lol.0.1:10 numbers limit reached.png", - "logicalName": "10 numbers limit reached", - "description": "yyyyyyy" - }, - "Addproperty": { - "uniqueId": "svc_lol.0.1.Addproperty", - "artifactType": "PUPPET", - "artifactName": "Addproperty.JPG", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436344939800, - "lastUpdateDate": 1436344939800, - "esId": "svc_lol.0.1:Addproperty.JPG", - "logicalName": "Addproperty", - "description": "hhhhhhh" - }, - "IMG_20140418_142614": { - "uniqueId": "svc_lol.0.1.IMG_20140418_142614", - "artifactType": "SHELL", - "artifactName": "IMG_20140418_142614.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436344895625, - "lastUpdateDate": 1436344895625, - "esId": "svc_lol.0.1:IMG_20140418_142614.jpg", - "logicalName": "IMG_20140418_142614", - "description": "bbbbbb" - }, - "IMG_20140618_195014": { - "uniqueId": "svc_lol.0.1.IMG_20140618_195014", - "artifactType": "CHEF", - "artifactName": "IMG_20140618_195014.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436344912378, - "lastUpdateDate": 1436344912378, - "esId": "svc_lol.0.1:IMG_20140618_195014.jpg", - "logicalName": "IMG_20140618_195014", - "description": "bbbbb" - }, - "IMG_20161213_222041": { - "uniqueId": "svc_lol.0.1.IMG_20161213_222041", - "artifactType": "HEAT", - "artifactName": "IMG_20161213_222041.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436343693049, - "lastUpdateDate": 1436343693049, - "esId": "svc_lol.0.1:IMG_20161213_222041.jpg", - "logicalName": "IMG_20161213_222041", - "description": "jjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjjjjjjjjjjjjjjjjjjdfjjjjjjj4444444444444444444444444444444444444444444444444444444444444444444" - }, - "IMG_20140418_142634": { - "uniqueId": "svc_lol.0.1.IMG_20140418_142634", - "artifactType": "PUPPET", - "artifactName": "IMG_20140418_142634.jpg", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436344878280, - "lastUpdateDate": 1436344878280, - "esId": "svc_lol.0.1:IMG_20140418_142634.jpg", - "logicalName": "IMG_20140418_142634", - "description": "bbbbbb" - } - }, - "category": "Web Servers", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "lol", - "creationDate": 1436343380208, - "icon": "network_l_4", - "version": "0.1", - "description": "ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggddddddddddddddddddddddddddddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssssssssssswwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwpopopoddddssssssssss", - "tags": [ - "lol" - ], - "uniqueId": "svc_lol.0.1", - "lastUpdateDate": 1436343380208, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_clarin.0.1", - "name": "clarin", - "version": "0.1", - "creationDate": 1436346144421, - "lastUpdateDate": 1436346144421, - "description": "soy yo", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "clarin" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Infrastructure", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "clarin", - "creationDate": 1436346144421, - "icon": "network_l_4", - "version": "0.1", - "description": "soy yo", - "tags": [ - "clarin" - ], - "uniqueId": "svc_clarin.0.1", - "lastUpdateDate": 1436346144421, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_jkhkjh.0.1", - "name": "jkhkjh", - "version": "0.1", - "creationDate": 1436356292329, - "lastUpdateDate": 1436356292329, - "description": "kjhlk", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "jkhkjh" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - "Screenshot_1": { - "uniqueId": "svc_jkhkjh.0.1.Screenshot_1", - "artifactType": "PUPPET", - "artifactName": "Screenshot_1.png", - "userIdLastUpdater": "cs0008", - "creatorFullName": "Carlos Santana", - "updaterFullName": "Carlos Santana", - "creationDate": 1436356484212, - "lastUpdateDate": 1436356484212, - "esId": "svc_jkhkjh.0.1:Screenshot_1.png", - "logicalName": "Screenshot_1", - "description": "zfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdhzfvbgsadfgsdhsdghsdhdsghsdh" - } - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "resourceInstances": [ - { - "uniqueId": "svc_jkhkjh.0.1.res_tosca.nodes.compute.1.0.compute_1", - "name": "compute_1", - "resourceUid": "res_tosca.nodes.compute.1.0", - "creationTime": 1436356602608, - "modificationTime": 1436356602608, - "description": "Represents a real or virtual machine or server. Information specified on the Compute\r\t node will be used to find the machine that fits the given requirements in the cloud\r\t available machines. If no sizing information are specified the cloud provider default\r\t machine will be used. It is strongly recommended to specify the required CPUs and memory\r\t at least.", - "posX": "781", - "posY": "241", - "icon": "defaulticon" - }, - { - "uniqueId": "svc_jkhkjh.0.1.res_tosca.nodes.compute.1.0.compute_2", - "name": "compute_2", - "resourceUid": "res_tosca.nodes.compute.1.0", - "creationTime": 1436356789445, - "modificationTime": 1436356789445, - "description": "Represents a real or virtual machine or server. Information specified on the Compute\r\t node will be used to find the machine that fits the given requirements in the cloud\r\t available machines. If no sizing information are specified the cloud provider default\r\t machine will be used. It is strongly recommended to specify the required CPUs and memory\r\t at least.", - "posX": "695", - "posY": "204", - "icon": "defaulticon" - }, - { - "uniqueId": "svc_jkhkjh.0.1.res_tosca.nodes.network.network.1.0.network_3", - "name": "network_3", - "resourceUid": "res_tosca.nodes.network.network.1.0", - "creationTime": 1436356792215, - "modificationTime": 1436356792215, - "description": "Represents a simple , logical network service.", - "posX": "706", - "posY": "381", - "icon": "defaulticon" - }, - { - "uniqueId": "svc_jkhkjh.0.1.res_tosca.nodes.network.port.1.0.port_4", - "name": "port_4", - "resourceUid": "res_tosca.nodes.network.port.1.0", - "creationTime": 1436356793840, - "modificationTime": 1436356793840, - "description": "Represents a logical entity that associates between Compute and Network normative types.", - "posX": "662", - "posY": "552", - "icon": "defaulticon" - } - ], - "resourceInstancesRelations": [ - - ], - "serviceName": "jkhkjh", - "creationDate": 1436356292329, - "icon": "network_l_4", - "version": "0.1", - "description": "kjhlk", - "tags": [ - "jkhkjh" - ], - "uniqueId": "svc_jkhkjh.0.1", - "lastUpdateDate": 1436356292329, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_resrw.0.1", - "name": "resrw", - "version": "0.1", - "creationDate": 1436358721893, - "lastUpdateDate": 1436358721893, - "description": "rer", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "resrwrer", - "lklkl" - ], - "icon": "network_l_1-3", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "resourceInstances": [ - { - "uniqueId": "svc_resrw.0.1.res_tosca.nodes.compute.1.0.compute_1", - "name": "compute_1", - "resourceUid": "res_tosca.nodes.compute.1.0", - "creationTime": 1436358725759, - "modificationTime": 1436358725759, - "description": "Represents a real or virtual machine or server. Information specified on the Compute\r\t node will be used to find the machine that fits the given requirements in the cloud\r\t available machines. If no sizing information are specified the cloud provider default\r\t machine will be used. It is strongly recommended to specify the required CPUs and memory\r\t at least.", - "posX": "221", - "posY": "251", - "icon": "defaulticon" - }, - { - "uniqueId": "svc_resrw.0.1.res_tosca.nodes.network.network.1.0.network_2", - "name": "network_2", - "resourceUid": "res_tosca.nodes.network.network.1.0", - "creationTime": 1436358727329, - "modificationTime": 1436358727329, - "description": "Represents a simple , logical network service.", - "posX": "626", - "posY": "340", - "icon": "defaulticon" - }, - { - "uniqueId": "svc_resrw.0.1.res_tosca.nodes.network.port.1.0.port_3", - "name": "port_3", - "resourceUid": "res_tosca.nodes.network.port.1.0", - "creationTime": 1436358729466, - "modificationTime": 1436358729466, - "description": "Represents a logical entity that associates between Compute and Network normative types.", - "posX": "558", - "posY": "275", - "icon": "defaulticon" - } - ], - "resourceInstancesRelations": [ - - ], - "serviceName": "resrw", - "creationDate": 1436358721893, - "icon": "network_l_1-3", - "version": "0.1", - "description": "rer", - "tags": [ - "resrwrer", - "lklkl" - ], - "uniqueId": "svc_resrw.0.1", - "lastUpdateDate": 1436358721893, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_coco.0.1", - "name": "coco", - "version": "0.1", - "creationDate": 1436362653722, - "lastUpdateDate": 1436362653722, - "description": "hhh", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "coco" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "coco", - "creationDate": 1436362653722, - "icon": "network_l_4", - "version": "0.1", - "description": "hhh", - "tags": [ - "coco" - ], - "uniqueId": "svc_coco.0.1", - "lastUpdateDate": 1436362653722, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_nermartin.0.1", - "name": "nerMartin", - "version": "0.1", - "creationDate": 1436366670488, - "lastUpdateDate": 1436366670488, - "description": "gggggggggg", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "nerMartin" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "IMS", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "nerMartin", - "creationDate": 1436366670488, - "icon": "network_l_4", - "version": "0.1", - "description": "gggggggggg", - "tags": [ - "nerMartin" - ], - "uniqueId": "svc_nermartin.0.1", - "lastUpdateDate": 1436366670488, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - }, - { - "componentMetadataDefinition": { - "uniqueId": "svc_susana.0.1", - "name": "susana", - "version": "0.1", - "creationDate": 1436367239625, - "lastUpdateDate": 1436367239625, - "description": "fff", - "state": "NOT_CERTIFIED_CHECKOUT", - "tags": [ - "susana" - ], - "icon": "network_l_4", - "highestVersion": true - }, - "artifacts": { - - }, - "category": "Call Control", - "creatorUserId": "cs0008", - "creatorFullName": "Carlos Santana", - "lastUpdaterUserId": "cs0008", - "lastUpdaterFullName": "Carlos Santana", - "serviceName": "susana", - "creationDate": 1436367239625, - "icon": "network_l_4", - "version": "0.1", - "description": "fff", - "tags": [ - "susana" - ], - "uniqueId": "svc_susana.0.1", - "lastUpdateDate": 1436367239625, - "lifecycleState": "NOT_CERTIFIED_CHECKOUT" - } - ] -} diff --git a/catalog-ui/server-mock/mock-data/resource/properties.json b/catalog-ui/server-mock/mock-data/resource/properties.json deleted file mode 100644 index 8ed7e78970..0000000000 --- a/catalog-ui/server-mock/mock-data/resource/properties.json +++ /dev/null @@ -1,35 +0,0 @@ -[ - { - "uniqueId": "uniqueId_1", - "name": "disk_size", - "type": "integer", - "required": false, - "defaultValue": "10", - "description": "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.", - "constraints": [ - { - "inRange": [ - "100" - ] - } - ], - "isPassword": false - }, - { - "uniqueId": "uniqueId_2", - "name": "num_cpus", - "type": "integer", - "required": false, - "defaultValue": "2", - "description": "Number of (actual or virtual) CPUs associated with the Compute node.", - "constraints": [ - { - "inRange": [ - "1", - "4" - ] - } - ], - "isPassword": false - } -] diff --git a/catalog-ui/server-mock/mock-data/resource/resource.json b/catalog-ui/server-mock/mock-data/resource/resource.json deleted file mode 100644 index bc04f40730..0000000000 --- a/catalog-ui/server-mock/mock-data/resource/resource.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "uniqueId": "my-resource.1.0.0", - "isAbstract": false, - "resourceName": "my-resource", - "resourceVersion": "1.0.0", - "isHighestVersion": false, - "vendorName": "vendorName", - "vendorRelease": "vendorRelease", - "contactId": "contactId", - "olderVersions": [ - "bla" - ], - "resourceIconSrc": "images/resource-icons/firewall.png", - "icon":"icon-red2", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh000322", - "lastUpdaterFullName": "JHaval Jimmy Hendrix", - "creationDate": 1431525184379, - "lastUpdateDate": 1431525184394, - "description": "Description bla bla", - "tags": [ - "some tag", - "tag2", - "tag3", - "tag4" - ], - "category": "Infrastructure", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "template1" - ], - "artifacts": { - "db_content": { - "uniqueId": "my-resource.1.0.0.db_content", - "artifactType": "puppet", - "artifactRef": "http://swift OR CATALOG FE /myfile", - "artifactName": "some Artifact Name1", - "artifactRepository": "SWIFT", - "artifactData": "base 64 dajfvsd fsdfsfs s==", - "artifactChecksum": "base 64 dsdsd==", - "userIdCreator": "jh0003", - "userIdLastUpdater": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "updaterFullName": "Jimmy Hendrix", - "creationDate": 1431525184377, - "lastUpdateDate": 1431525184377 - }, - "db_content_2": { - "uniqueId": "my-resource.1.0.0.db_content_2", - "artifactType": "puppet", - "artifactRef": "http://swift OR CATALOG FE /myfile", - "artifactName": "some Artifact Name2", - "artifactRepository": "SWIFT", - "artifactData": "base 64 dajfvsd fsdfsfs s==", - "artifactChecksum": "base 64 dsdsd==", - "userIdCreator": "jh0003", - "userIdLastUpdater": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "updaterFullName": "Jimmy Hendrix", - "creationDate": 1431525184377, - "lastUpdateDate": 1431525184377 - }, - "db_content_3": { - "uniqueId": "my-resource.1.0.0.db_content_3", - "artifactType": "puppet", - "artifactRef": "http://swift OR CATALOG FE /myfile", - "artifactName": "some Artifact Name3", - "artifactRepository": "SWIFT", - "artifactData": "base 64 dajfvsd fsdfsfs s==", - "artifactChecksum": "base 64 dsdsd==", - "userIdCreator": "jh0003", - "userIdLastUpdater": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "updaterFullName": "Jimmy Hendrix", - "creationDate": 1431525184377, - "lastUpdateDate": 1431525184377 - } - }, - "properties": { - "disk_size": { - "uniqueId": "uniqueId_1", - "type": "integer", - "required": false, - "defaultValue": "10", - "description": "Size of the local disk, in Gigabytes (GB), available to applications running on the Compute node.", - "constraints": [ - { - "inRange": [ - "100" - ] - } - ], - "isPassword": false - }, - "num_cpus": { - "uniqueId": "uniqueId_2", - "type": "integer", - "required": false, - "defaultValue": "2", - "description": "Number of (actual or virtual) CPUs associated with the Compute node.", - "constraints": [ - { - "inRange": [ - "1", - "4" - ] - } - ], - "isPassword": false - } - }, - "attributes": { - "tmp": {} - }, - "interfaces": { - "tmp": { - "operations": {} - } - }, - "capabilities": { - "host": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "host": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - }, - "defaultCapabilities": [ - "defaultCapabilities" - ] -} diff --git a/catalog-ui/server-mock/mock-data/resources/resourcesAbstract.json b/catalog-ui/server-mock/mock-data/resources/resourcesAbstract.json deleted file mode 100644 index b678ea9b6b..0000000000 --- a/catalog-ui/server-mock/mock-data/resources/resourcesAbstract.json +++ /dev/null @@ -1,284 +0,0 @@ -[ - { - "uniqueId": "tosca.nodes.root.1.0", - "resourceName": "tosca.nodes.root", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412546396, - "lastUpdateDate": 1433412546396, - "description": "Represents a generic software component that can be managed and run by a Compute Node Type.", - "icon": "icon-red1", - "tags": [ - "Root" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.softwarecomponent.1.0", - "resourceName": "tosca.nodes.softwarecomponent", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412547841, - "lastUpdateDate": 1433412547841, - "description": "Represents a generic software component that can be managed and run by a Compute Node Type.", - "icon": "icon-red2", - "tags": [ - "Software Component" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "component_version": { - "uniqueId": "tosca.nodes.softwarecomponent.1.0.component_version", - "type": "version", - "required": false, - "definition": true, - "password": false - }, - "admin_credential": { - "uniqueId": "tosca.nodes.softwarecomponent.1.0.admin_credential", - "type": "tosca.datatypes.Credential", - "required": false, - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.webserver.1.0", - "resourceName": "tosca.nodes.webserver", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412548140, - "lastUpdateDate": 1433412548140, - "description": "Represents an abstract software component or service that is capable of hosting and providing management operations for one or more Web Application nodes.", - "icon": "icon-red1", - "tags": [ - "Web Server" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.softwarecomponent" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.webapplication.1.0", - "resourceName": "tosca.nodes.webapplication", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412548382, - "lastUpdateDate": 1433412548382, - "description": "Represents a software application that can be managed and run by a Web Server node. Specific types of web applications such as Java, etc. could be derived from this type.", - "icon": "icon-red3", - "tags": [ - "Web Application" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "context_root": { - "uniqueId": "tosca.nodes.webapplication.1.0.context_root", - "type": "string", - "required": false, - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.dbms.1.0", - "resourceName": "tosca.nodes.dbms", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412548607, - "lastUpdateDate": 1433412548607, - "description": "Represents a typical relational, SQL Database Management System software component or service.", - "icon": "icon-red4", - "tags": [ - "DBMS" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.softwarecomponent" - ], - "properties": { - "port": { - "uniqueId": "tosca.nodes.dbms.1.0.port", - "type": "integer", - "required": false, - "description": "the port the DBMS service will listen to for data and requests", - "definition": true, - "password": false - }, - "root_password": { - "uniqueId": "tosca.nodes.dbms.1.0.root_password", - "type": "string", - "required": false, - "description": "the optional root password for the DBMS service", - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.database.1.0", - "resourceName": "tosca.nodes.database", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412548836, - "lastUpdateDate": 1433412548836, - "description": "Represents a logical database that can be managed and hosted by a DBMS node.", - "icon": "icon-red3", - "tags": [ - "Database" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "port": { - "uniqueId": "tosca.nodes.database.1.0.port", - "type": "integer", - "required": false, - "description": "the port the underlying database service will listen to for data", - "definition": true, - "password": false - }, - "name": { - "uniqueId": "tosca.nodes.database.1.0.name", - "type": "string", - "required": false, - "description": "the logical name of the database", - "definition": true, - "password": false - }, - "user": { - "uniqueId": "tosca.nodes.database.1.0.user", - "type": "string", - "required": false, - "description": "the optional user account name for DB administration", - "definition": true, - "password": false - }, - "password": { - "uniqueId": "tosca.nodes.database.1.0.password", - "type": "string", - "required": false, - "description": "the optional password for the DB user account", - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.container.runtime.1.0", - "resourceName": "tosca.nodes.container.runtime", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412549532, - "lastUpdateDate": 1433412549532, - "description": "Represents operating system-level virtualization technology used to run multiple application services on a single Compute host.", - "icon": "icon-red12", - "tags": [ - "Container" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.softwarecomponent" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - }, - { - "uniqueId": "tosca.nodes.container.application.1.0", - "resourceName": "tosca.nodes.container.application", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412549709, - "lastUpdateDate": 1433412549709, - "description": "Represents an application that requires Container-level virtualization technology.", - "icon": "icon-red4", - "tags": [ - "Container Application" - ], - "category": "Abstract", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": true, - "highestVersion": false - } -] diff --git a/catalog-ui/server-mock/mock-data/resources/resourcesNotAbstract.json b/catalog-ui/server-mock/mock-data/resources/resourcesNotAbstract.json deleted file mode 100644 index eab325c9cf..0000000000 --- a/catalog-ui/server-mock/mock-data/resources/resourcesNotAbstract.json +++ /dev/null @@ -1,510 +0,0 @@ -[ - { - "uniqueId": "tosca.nodes.compute.1.0", - "resourceName": "tosca.nodes.compute", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412547566, - "lastUpdateDate": 1433412547566, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Represents a real or virtual machine or server. Information specified on the Compute\t node will be used to find the machine that fits the given requirements in the cloud\t available machines. If no sizing information are specified the cloud provider default\t machine will be used. It is strongly recommended to specify the required CPUs and memory\t at least.", - "icon": "icon-red2", - "tags": [ - "Compute" - ], - "category": "Infrastructure", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db1": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux1": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "host": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - }, - { - "uniqueId": "tosca.nodes.objectstorage.1.0", - "resourceName": "tosca.nodes.objectstorage", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412549091, - "lastUpdateDate": 1433412549091, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Represents storage that provides the ability to store data as objects (or BLOBs of data) without consideration for the underlying filesystem or devices.", - "icon": "icon-red1", - "tags": [ - "ObjectStorage" - ], - "category": "Infrastructure", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "maxsize": { - "uniqueId": "tosca.nodes.objectstorage.1.0.maxsize", - "type": "scalar-unit.size", - "required": false, - "constraints": [ - { - - } - ], - "definition": true, - "password": false - }, - "name": { - "uniqueId": "tosca.nodes.objectstorage.1.0.name", - "type": "string", - "required": false, - "definition": true, - "password": false - }, - "size": { - "uniqueId": "tosca.nodes.objectstorage.1.0.size", - "type": "scalar-unit.size", - "required": false, - "constraints": [ - { - - } - ], - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host2": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux2": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "db": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - }, - { - "uniqueId": "tosca.nodes.blockstorage.1.0", - "resourceName": "tosca.nodes.blockstorage", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412549327, - "lastUpdateDate": 1433412549327, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Represents a server-local block storage device (i.e., not shared) offering evenly sized blocks of data from which raw storage volumes can be created.", - "icon": "icon-red3", - "tags": [ - "BlockStorage" - ], - "category": "Infrastructure", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "volume_id": { - "uniqueId": "tosca.nodes.blockstorage.1.0.volume_id", - "type": "string", - "required": false, - "definition": true, - "password": false - }, - "snapshot_id": { - "uniqueId": "tosca.nodes.blockstorage.1.0.snapshot_id", - "type": "string", - "required": false, - "definition": true, - "password": false - }, - "size": { - "uniqueId": "tosca.nodes.blockstorage.1.0.size", - "type": "scalar-unit.size", - "required": false, - "constraints": [ - { - - } - ], - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host3": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db3": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "linux": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - }, - { - "uniqueId": "tosca.nodes.loadbalancer.1.0", - "resourceName": "tosca.nodes.loadbalancer", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412549878, - "lastUpdateDate": 1433412549878, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Represents logical function that be used in conjunction with a Floating Address to distribute an application’s traffic (load) across a number of instances of the application (e.g., for a clustered or scaled application).", - "icon": "icon-red4", - "tags": [ - "Load Balancer" - ], - "category": "Infrastructure", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "properties": { - "algorithm": { - "uniqueId": "tosca.nodes.loadbalancer.1.0.algorithm", - "type": "string", - "required": false, - "definition": true, - "password": false - } - }, - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db4": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux4": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "linux": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - }, - { - "uniqueId": "tosca.nodes.titan.1.0", - "resourceName": "tosca.nodes.titan", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412550046, - "lastUpdateDate": 1433412550046, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Titan is a scalable graph database optimized for storing and querying graphs containing hundreds of billions of vertices and edges distributed across a multi-machine cluster. Titan is a transactional database that can support thousands of concurrent users executing complex graph traversals in real time.", - "icon": "icon-red4", - "tags": [ - "Titan" - ], - "category": "Big Data", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host5": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux5": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "linux": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - }, - { - "uniqueId": "tosca.nodes.tas.1.0", - "resourceName": "tosca.nodes.tas", - "resourceVersion": "1.0", - "creatorUserId": "jh0003", - "creatorFullName": "Jimmy Hendrix", - "lastUpdaterUserId": "jh0003", - "lastUpdaterFullName": "Jimmy Hendrix", - "creationDate": 1433412550197, - "lastUpdateDate": 1433412550197, - "coordinates": { - "x":150, - "y":250 - }, - "description": "Telephony application server.", - "icon": "icon-red1", - "tags": [ - "TAS" - ], - "category": "VoIP", - "lifecycleState": "CERTIFIED", - "derivedFrom": [ - "tosca.nodes.root" - ], - "vendorName": "ATT (Tosca)", - "vendorRelease": "1.0.0.wd03", - "contactId": "jh0003", - "abstract": false, - "highestVersion": false, - "capabilities": { - "host": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "db6": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - }, - "linux6": { - "uniqueId": "capability.tosca.nodes.Compute.1.0.host", - "type": "tosca.capabilities.Container", - "validSourceTypes": [ - "tosca.nodes.SC" - ] - } - }, - "requirements": { - "db": { - "uniqueId": "tosca.nodes.SoftwareComponent.1.0.host", - "capability": "tosca.capabilities.Container", - "node": "tosca.nodes.Compute", - "requirementImpl": { - "uniqueId": "requirementImpl.my-resource.1.0.host", - "nodeId": "tosca.nodes.Compute.1.0", - "requirementProperties": { - "host": { - "uniqueId": "capabilityInst.requirementImpl.my-resource.1.0.host.host", - "properties": { - "disk_size": "10", - "num_cpus": "2" - } - } - } - } - } - } - } -] diff --git a/catalog-ui/server-mock/mock-data/template/template.json b/catalog-ui/server-mock/mock-data/template/template.json deleted file mode 100644 index 2747491c0e..0000000000 --- a/catalog-ui/server-mock/mock-data/template/template.json +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "uniqueId": "1", - "resourceName": "template1", - "description":"description description description description description " - }, - { - "uniqueId": "2", - "resourceName": "template2", - "description":"description description description description description " - }, - { - "uniqueId": "3", - "resourceName": "template3", - "description":"description description description description description " - }, - { - "uniqueId": "4", - "resourceName": "template4", - "description":"description description description description description " - }, - { - "uniqueId": "5", - "resourceName": "template5", - "description":"description description description description description " - }, - { - "uniqueId": "6", - "resourceName": "template6", - "description":"description description description description description " - }, - { - "uniqueId": "7", - "resourceName": "template7", - "description":"description description description description description " - } - ] diff --git a/catalog-ui/server-mock/mock-data/user/user.json b/catalog-ui/server-mock/mock-data/user/user.json deleted file mode 100644 index 5e793db6c6..0000000000 --- a/catalog-ui/server-mock/mock-data/user/user.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "firstName": "James", - "lastName": "Brown", - "userId": "jb1234u", - "email": "jb1234u@sdc.com", - "role": "ADMIN" -} diff --git a/catalog-ui/server-mock/mock-server.js b/catalog-ui/server-mock/mock-server.js deleted file mode 100644 index 6f4c88a62d..0000000000 --- a/catalog-ui/server-mock/mock-server.js +++ /dev/null @@ -1,140 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var mockApis = require('../configurations/mock.json').sdcConfig; -//var mockUris = require('../configurations/mock.json'); -var cors = require('cors'); -var multer = require('multer') -var basePathToMockData = './mock-data/'; -var app = express(); - -var allowedHeaders = 'Content-Type,Authorization,If-Modified-Since,'; -allowedHeaders += mockApis.cookie.userIdSuffix; -allowedHeaders += ','+mockApis.cookie.userEmail; -allowedHeaders += ','+mockApis.cookie.userFirstName; -allowedHeaders += ','+mockApis.cookie.userLastName; -allowedHeaders += ','+mockApis.cookie.xEcompRequestId; - - - -app.use(cors({ - // origin: '*', - origin: function(origin, callback) { - callback(null, true); - }, - methods: 'GET, POST, PUT, DELETE', - allowedHeaders: allowedHeaders, - credentials: true -})); - -//set cookie middleware -app.use(function(req, res, next) { - - res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || mockApis.userTypes.designer.userId ); - res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || mockApis.userTypes.designer.email); - res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || mockApis.userTypes.designer.firstName); - res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || mockApis.userTypes.designer.lastName); - res.cookie(mockApis.cookie.xEcompRequestId, req.headers[mockApis.cookie.xEcompRequestId] || mockApis.userTypes.designer.lastName); - next(); -}); - -var userRoutes = require('./routes/user'); -app.use('/v1/user', userRoutes); -var resourceRoutes = require('./routes/resource'); -app.use('/v1/resource', resourceRoutes); -var templateRoutes = require('./routes/template'); -app.use('/v1/template', templateRoutes); -var propertyRoutes = require('./routes/property'); -app.use('/v1/resource/:resourceId/property', propertyRoutes); -var resourcesRoutes = require('./routes/resources'); -app.use('/v1/catalog/resources', resourcesRoutes); - -/******************************************* MOCKS ENPOINTS *************************************************/ -/* get user details */ -// app.get(mockApis.api.GET_user, function (req, res) { -// var user = require(basePathToMockData+'user/user.json'); -// res.send(user); -// }); - -/* get elements */ -app.get(mockApis.api.GET_element, function (req, res) { - - var element = require(basePathToMockData+'element/element.json'); - res.send(element); -}); - -/* get elements */ -app.get(mockApis.api.GET_catalog, function (req, res) { - - var element = require(basePathToMockData+'element/element.json'); - res.send(element); -}); - -/* get categories */ -app.get(mockApis.api.GET_category, function (req, res) { - - var categories = require(basePathToMockData+'category/category.json'); - res.send(categories); -}); - - -/* get categories */ -app.get(mockApis.api.GET_configuration_ui, function (req, res) { - - var categories = require(basePathToMockData+'artifact/artifact-types.json'); - res.send(categories); -}); - - - - - - - - -//upload artifact file -app.use(multer({ dest: './uploads/', - rename: function (fieldname, filename) { - return filename+Date.now(); - }, - onFileUploadStart: function (file) { - console.log(file.originalname + ' is starting ...') - }, - onFileUploadComplete: function (file) { - console.log(file.fieldname + ' uploaded to ' + file.path) - done=true; - } -})); - -var done=false; -app.post(mockApis.api.GET_resource_artifact,function(req,res){ - if(done==true){ - console.log(req.files); - res.end("File uploaded."); - } -}); - - -/**************************************************** *******************************************************/ - -var server = app.listen(9999, function () { - console.log('mock server listening on port %d', server.address().port); -}); diff --git a/catalog-ui/server-mock/routes/property.js b/catalog-ui/server-mock/routes/property.js deleted file mode 100644 index 2756018035..0000000000 --- a/catalog-ui/server-mock/routes/property.js +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var properties = require('../mock-data/resource/properties.json'); - -var router = express.Router(); - -router.get('/', function (req, res) { - console.log('query'); - res.send(properties); -}); - -router.post('/:id', function (req, res) { - console.log("post /:id", req); - res.send(properties[0]); -}); - -router.get('/:id', function (req, res) { - res.send(properties[0]); -}); - - -router.post('/', function (req, res) { - console.log("post ", req); - res.send(properties[0]); -}); -module.exports= router; diff --git a/catalog-ui/server-mock/routes/resource.js b/catalog-ui/server-mock/routes/resource.js deleted file mode 100644 index f02b6227e8..0000000000 --- a/catalog-ui/server-mock/routes/resource.js +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var resource = require('../mock-data/resource/resource.json'); - -var router = express.Router(); - -router.get('/', function (req, res) { - console.log('query'); - res.send([resource]); -}); - -router.post('/:id', function (req, res) { - console.log("post /:id"); - res.send(resource); -}); - -router.get('/:id', function (req, res) { - console.log("post "); - res.send(resource); -}); - - -router.post('/', function (req, res) { - console.log("post "); - res.send(resource); -}); - -router.get('/validate-name/:name', function (req, res) { - - var name = req.params.name; - var response = {'isValid':true}; - if (name==='exist'){ - response = {'isValid':false}; - } - res.send(response); - -}); - - - -module.exports= router; diff --git a/catalog-ui/server-mock/routes/resources.js b/catalog-ui/server-mock/routes/resources.js deleted file mode 100644 index 589848981c..0000000000 --- a/catalog-ui/server-mock/routes/resources.js +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var resourcesNotAbstract = require('../mock-data/resources/resourcesNotAbstract.json'); -var resourcesAbstract = require('../mock-data/resources/resourcesAbstract.json'); - -var router = express.Router(); - -router.get('/certified/notabstract', function (req, res) { - res.send(resourcesNotAbstract); -}); - - -router.get('/certified/abstract', function (req, res) { - res.send(resourcesAbstract); -}); - - - -module.exports= router; diff --git a/catalog-ui/server-mock/routes/template.js b/catalog-ui/server-mock/routes/template.js deleted file mode 100644 index 3b7653967e..0000000000 --- a/catalog-ui/server-mock/routes/template.js +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var templates = require('../mock-data/template/template.json'); - -var router = express.Router(); - -router.get('/', function (req, res) { - console.log('query'); - res.send(templates); -}); - -router.post('/:id', function (req, res) { - console.log("post /:id", req); - res.send(templates[0]); -}); - -router.get('/:id', function (req, res) { - res.send(templates[0]); -}); - - -router.post('/', function (req, res) { - console.log("post ", req); - res.send(templates[0]); -}); -module.exports= router; diff --git a/catalog-ui/server-mock/routes/user.js b/catalog-ui/server-mock/routes/user.js deleted file mode 100644 index d01f4397e9..0000000000 --- a/catalog-ui/server-mock/routes/user.js +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -var express = require('express'); -var user = require('../mock-data/user/user.json'); - -var router = express.Router(); - -router.get('/', function (req, res) { - console.log('query'); - res.send([user]); -}); - -router.post('/:id', function (req, res) { - console.log("post /:id", req); - res.send(user); -}); - -router.get('/:id', function (req, res) { - res.send(user); -}); - - -router.post('/', function (req, res) { - console.log("post ", req); - res.send(user); -}); -module.exports= router; diff --git a/catalog-ui/app/_favicon.png b/catalog-ui/src/app/_favicon.png Binary files differindex 6e9f04df69..6e9f04df69 100644 --- a/catalog-ui/app/_favicon.png +++ b/catalog-ui/src/app/_favicon.png diff --git a/catalog-ui/src/app/app.ts b/catalog-ui/src/app/app.ts new file mode 100644 index 0000000000..7f85bb9eb3 --- /dev/null +++ b/catalog-ui/src/app/app.ts @@ -0,0 +1,837 @@ +'use strict'; + +//import 'restangular'; +//import 'angular-ui-router'; +import "reflect-metadata"; +import 'ng-infinite-scroll'; +import './modules/filters.ts'; +import './modules/utils.ts'; +import './modules/directive-module.ts'; +import './modules/service-module'; +import './modules/view-model-module.ts'; + +import { + IUserResourceClass, + DataTypesService, + LeftPaletteLoaderService, + EcompHeaderService, + CookieService, + ConfigurationUiService, + CacheService, + IUserResource, + SdcVersionService, + ICategoryResourceClass, + EntityService +} from "./services"; +import {forwardRef} from '@angular/core'; +import {UpgradeAdapter} from '@angular/upgrade'; +import {CHANGE_COMPONENT_CSAR_VERSION_FLAG, States} from "./utils"; +import {IAppConfigurtaion, IAppMenu, IMainCategory, Resource, IHostedApplication} from "./models"; +import {ComponentFactory} from "./utils/component-factory"; +import {ModalsHandler} from "./utils/modals-handler"; +import {downgradeComponent} from "@angular/upgrade/static"; + +import {AppModule} from './ng2/app.module'; +import {PropertiesAssignmentComponent} from "./ng2/pages/properties-assignment/properties-assignment.page.component"; +import {Component} from "./models/components/component"; +import {ComponentServiceNg2} from "./ng2/services/component-services/component.service"; +import {ComponentMetadata} from "./models/component-metadata"; +import {Categories} from "./models/categories"; + + +let moduleName:string = 'sdcApp'; +let viewModelsModuleName:string = 'Sdc.ViewModels'; +let directivesModuleName:string = 'Sdc.Directives'; +let servicesModuleName:string = 'Sdc.Services'; +let filtersModuleName:string = 'Sdc.Filters'; +let utilsModuleName:string = 'Sdc.Utils'; + +// Load configuration according to environment. +declare var __ENV__:string; +let sdcConfig:IAppConfigurtaion; +let sdcMenu:IAppMenu; +let pathPrefix:string = ''; +if (__ENV__ === 'dev') { + sdcConfig = require('./../../configurations/dev.js'); +} else if (__ENV__ === 'prod') { + sdcConfig = require('./../../configurations/prod.js'); + pathPrefix = 'sdc1/'; +} else { + console.log("ERROR: Environment configuration not found!"); +} +sdcMenu = require('./../../configurations/menu.js'); + +let dependentModules:Array<string> = [ + 'ui.router', + 'ui.bootstrap', + 'ui.bootstrap.tpls', + 'ngDragDrop', + 'ui-notification', + 'ngResource', + 'ngSanitize', + 'naif.base64', + 'base64', + 'uuid4', + 'checklist-model', + 'angular.filter', + 'pascalprecht.translate', + '720kb.tooltips', + 'restangular', + 'angular-clipboard', + 'angularResizable', + 'infinite-scroll', + viewModelsModuleName, + directivesModuleName, + servicesModuleName, + filtersModuleName, + utilsModuleName +]; + +// ===================== Hosted applications section ==================== +// Define here new hosted apps +let hostedApplications:Array<IHostedApplication> = [ + { + "moduleName": "dcaeApp", + "navTitle": "DCAE", + "defaultState": 'dcae.app.home', + "state": { + "name": "dcae", + "url": "/dcae", + "relativeHtmlPath": 'dcae-app/dcae-app-view.html', + "controllerName": '.DcaeAppViewModel' + } + } +]; + +// Check if module exists (in case the javascript was not loaded). +let isModuleExists = (moduleName:string):boolean => { + try { + angular.module(moduleName); + dependentModules.push(moduleName); + return true; + } catch (e) { + console.log('Module ' + moduleName + ' does not exists'); + return false; + } +}; + +// Check which hosted applications exists +_.each(hostedApplications, (hostedApp)=> { + if (isModuleExists(hostedApp.moduleName)) { + hostedApp['exists'] = true; + } +}); +// ===================== Hosted applications section ==================== + +export const ng1appModule:ng.IModule = angular.module(moduleName, dependentModules); +angular.module('sdcApp').directive('propertiesAssignment', downgradeComponent({component: PropertiesAssignmentComponent}) as angular.IDirectiveFactory); + +ng1appModule.config([ + '$stateProvider', + '$translateProvider', + '$urlRouterProvider', + '$httpProvider', + 'tooltipsConfigProvider', + 'NotificationProvider', + ($stateProvider:any, + $translateProvider:any, + $urlRouterProvider:ng.ui.IUrlRouterProvider, + $httpProvider:ng.IHttpProvider, + tooltipsConfigProvider:any, + NotificationProvider:any):void => { + + NotificationProvider.setOptions({ + delay: 10000, + startTop: 10, + startRight: 10, + closeOnClick: true, + verticalSpacing: 20, + horizontalSpacing: 20, + positionX: 'right', + positionY: 'top' + }); + + $translateProvider.useStaticFilesLoader({ + prefix: pathPrefix + 'assets/languages/', + langKey: '', + suffix: '.json?d=' + (new Date()).getTime() + }); + $translateProvider.useSanitizeValueStrategy('escaped'); + $translateProvider.preferredLanguage('en_US'); + + $httpProvider.interceptors.push('Sdc.Services.HeaderInterceptor'); + $httpProvider.interceptors.push('Sdc.Services.HttpErrorInterceptor'); + $urlRouterProvider.otherwise('welcome'); + + $stateProvider.state( + 'dashboard', { + url: '/dashboard?show&folder', + templateUrl: "./view-models/dashboard/dashboard-view.html", + controller: viewModelsModuleName + '.DashboardViewModel', + } + ); + + $stateProvider.state( + 'welcome', { + url: '/welcome', + templateUrl: "./view-models/welcome/welcome-view.html", + controller: viewModelsModuleName + '.WelcomeViewModel' + } + ); + + let componentsParam:Array<any> = ['$stateParams', 'Sdc.Services.EntityService', 'Sdc.Services.CacheService', ($stateParams:any, EntityService:EntityService, cacheService:CacheService) => { + if (cacheService.get('breadcrumbsComponents')) { + return cacheService.get('breadcrumbsComponents'); + } else { + return EntityService.getCatalog(); + } + }]; + + $stateProvider.state( + 'workspace', { + url: '/workspace/:id/:type/', + params: {'importedFile': null, 'componentCsar': null, 'resourceType': null, 'disableButtons': null}, + templateUrl: './view-models/workspace/workspace-view.html', + controller: viewModelsModuleName + '.WorkspaceViewModel', + resolve: { + injectComponent: ['$stateParams', 'ComponentFactory', 'ComponentServiceNg2', function ($stateParams, ComponentFactory:ComponentFactory, ComponentServiceNg2:ComponentServiceNg2) { + if ($stateParams.id) { + return ComponentFactory.getComponentWithMetadataFromServer($stateParams.type.toUpperCase(), $stateParams.id); + } else if ($stateParams.componentCsar && $stateParams.componentCsar.csarUUID) { + return $stateParams.componentCsar; + } else { + let emptyComponent = ComponentFactory.createEmptyComponent($stateParams.type.toUpperCase()); + if (emptyComponent.isResource() && $stateParams.resourceType) { + // Set the resource type + (<Resource>emptyComponent).resourceType = $stateParams.resourceType; + } + if ($stateParams.importedFile) { + (<Resource>emptyComponent).importedFile = $stateParams.importedFile; + } + return emptyComponent; + } + }], + components: componentsParam + } + } + ); + + $stateProvider.state( + States.WORKSPACE_GENERAL, { + url: 'general', + parent: 'workspace', + controller: viewModelsModuleName + '.GeneralViewModel', + templateUrl: './view-models/workspace/tabs/general/general-view.html', + data: {unsavedChanges: false, bodyClass: 'general'} + } + ); + // + $stateProvider.state( + States.WORKSPACE_ICONS, { + url: 'icons', + parent: 'workspace', + controller: viewModelsModuleName + '.IconsViewModel', + templateUrl: './view-models/workspace/tabs/icons/icons-view.html', + data: {unsavedChanges: false, bodyClass: 'icons'} + + } + ); + + $stateProvider.state( + States.WORKSPACE_ACTIVITY_LOG, { + url: 'activity_log', + parent: 'workspace', + controller: viewModelsModuleName + '.ActivityLogViewModel', + templateUrl: './view-models/workspace/tabs/activity-log/activity-log.html', + data: {unsavedChanges: false} + } + ); + + $stateProvider.state( + States.WORKSPACE_DEPLOYMENT_ARTIFACTS, { + url: 'deployment_artifacts', + parent: 'workspace', + controller: viewModelsModuleName + '.DeploymentArtifactsViewModel', + templateUrl: './view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html', + data: { + bodyClass: 'deployment_artifacts' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_HIERARCHY, { + url: 'hierarchy', + parent: 'workspace', + controller: viewModelsModuleName + '.ProductHierarchyViewModel', + templateUrl: './view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html', + data: {unsavedChanges: false} + + } + ); + + $stateProvider.state( + States.WORKSPACE_INFORMATION_ARTIFACTS, { + url: 'information_artifacts', + parent: 'workspace', + controller: viewModelsModuleName + '.InformationArtifactsViewModel', + templateUrl: './view-models/workspace/tabs/information-artifacts/information-artifacts-view.html', + data: { + bodyClass: 'information_artifacts' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_TOSCA_ARTIFACTS, { + url: 'tosca_artifacts', + parent: 'workspace', + controller: viewModelsModuleName + '.ToscaArtifactsViewModel', + templateUrl: './view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view.html', + data: { + bodyClass: 'tosca_artifacts' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_PROPERTIES, { + url: 'properties', + parent: 'workspace', + controller: viewModelsModuleName + '.PropertiesViewModel', + templateUrl: './view-models/workspace/tabs/properties/properties-view.html', + data: { + bodyClass: 'properties' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_SERVICE_INPUTS, { + url: 'service_inputs', + parent: 'workspace', + controller: viewModelsModuleName + '.ServiceInputsViewModel', + templateUrl: './view-models/workspace/tabs/inputs/service-input/service-inputs-view.html', + data: { + bodyClass: 'workspace-inputs' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_PROPERTIES_ASSIGNMENT, { + url: 'properties_assignment', + params: {'component': null}, + template: '<properties-assignment></properties-assignment>', + parent: 'workspace', + resolve: { + componentData: ['injectComponent', '$stateParams', function (injectComponent:Component, $stateParams) { + //injectComponent.componentService = null; // this is for not passing the service so no one will use old api and start using new api + $stateParams.component = injectComponent; + return injectComponent; + }], + }, + data: { + bodyClass: 'properties-assignment' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_RESOURCE_INPUTS, { + url: 'resource_inputs', + parent: 'workspace', + controller: viewModelsModuleName + '.ResourceInputsViewModel', + templateUrl: './view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html', + data: { + bodyClass: 'workspace-inputs' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_ATTRIBUTES, { + url: 'attributes', + parent: 'workspace', + controller: viewModelsModuleName + '.AttributesViewModel', + templateUrl: './view-models/workspace/tabs/attributes/attributes-view.html', + data: { + bodyClass: 'attributes' + } + } + ); + + $stateProvider.state( + States.WORKSPACE_REQUIREMENTS_AND_CAPABILITIES, { + url: 'req_and_capabilities', + parent: 'workspace', + controller: viewModelsModuleName + '.ReqAndCapabilitiesViewModel', + templateUrl: './view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view.html', + data: { + bodyClass: 'attributes' + } + } + ); + + + $stateProvider.state( + States.WORKSPACE_MANAGEMENT_WORKFLOW, { + parent: 'workspace', + url: 'management_workflow', + templateUrl: './view-models/workspace/tabs/management-workflow/management-workflow-view.html', + controller: viewModelsModuleName + '.ManagementWorkflowViewModel' + } + ); + + $stateProvider.state( + States.WORKSPACE_NETWORK_CALL_FLOW, { + parent: 'workspace', + url: 'network_call_flow', + templateUrl: './view-models/workspace/tabs/network-call-flow/network-call-flow-view.html', + controller: viewModelsModuleName + '.NetworkCallFlowViewModel' + } + ); + + $stateProvider.state( + States.WORKSPACE_DISTRIBUTION, { + parent: 'workspace', + url: 'distribution', + templateUrl: './view-models/workspace/tabs/distribution/distribution-view.html', + controller: viewModelsModuleName + '.DistributionViewModel' + } + ); + + $stateProvider.state( + States.WORKSPACE_COMPOSITION, { + url: 'composition/', + parent: 'workspace', + controller: viewModelsModuleName + '.CompositionViewModel', + templateUrl: './view-models/workspace/tabs/composition/composition-view.html', + data: { + bodyClass: 'composition' + } + } + ); + + // $stateProvider.state( + // States.WORKSPACE_NG2, { + // url: 'ng2/', + // component: downgradeComponent({component: NG2Example2Component}), //viewModelsModuleName + '.NG2Example', + // templateUrl: './ng2/view-ng2/ng2.example2/ng2.example2.component.html' + // } + // ); + + $stateProvider.state( + States.WORKSPACE_DEPLOYMENT, { + url: 'deployment/', + parent: 'workspace', + templateUrl: './view-models/workspace/tabs/deployment/deployment-view.html', + controller: viewModelsModuleName + '.DeploymentViewModel', + data: { + bodyClass: 'composition' + } + } + ); + + $stateProvider.state( + 'workspace.composition.details', { + url: 'details', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/details/details-view.html', + controller: viewModelsModuleName + '.DetailsViewModel' + } + ); + + $stateProvider.state( + 'workspace.composition.properties', { + url: 'properties', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html', + controller: viewModelsModuleName + '.ResourcePropertiesViewModel' + } + ); + + $stateProvider.state( + 'workspace.composition.artifacts', { + url: 'artifacts', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html', + controller: viewModelsModuleName + '.ResourceArtifactsViewModel' + } + ); + + $stateProvider.state( + 'workspace.composition.relations', { + url: 'relations', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/relations/relations-view.html', + controller: viewModelsModuleName + '.RelationsViewModel' + } + ); + + $stateProvider.state( + 'workspace.composition.structure', { + url: 'structure', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/structure/structure-view.html', + controller: viewModelsModuleName + '.StructureViewModel' + } + ); + $stateProvider.state( + 'workspace.composition.lifecycle', { + url: 'lifecycle', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html', + controller: viewModelsModuleName + '.ResourceArtifactsViewModel' + } + ); + + $stateProvider.state( + 'workspace.composition.api', { + url: 'api', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html', + controller: viewModelsModuleName + '.ResourceArtifactsViewModel' + } + ); + $stateProvider.state( + 'workspace.composition.deployment', { + url: 'deployment', + parent: 'workspace.composition', + templateUrl: './view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html', + controller: viewModelsModuleName + '.ResourceArtifactsViewModel' + } + ); + + $stateProvider.state( + 'adminDashboard', { + url: '/adminDashboard', + templateUrl: './view-models/admin-dashboard/admin-dashboard-view.html', + controller: viewModelsModuleName + '.AdminDashboardViewModel', + permissions: ['ADMIN'] + } + ); + + $stateProvider.state( + 'onboardVendor', { + url: '/onboardVendor', + templateUrl: './view-models/onboard-vendor/onboard-vendor-view.html', + controller: viewModelsModuleName + '.OnboardVendorViewModel'//, + } + ); + + // Build the states for all hosted apps dynamically + _.each(hostedApplications, (hostedApp)=> { + if (hostedApp.exists) { + $stateProvider.state( + hostedApp.state.name, { + url: hostedApp.state.url, + templateUrl: './view-models/dcae-app/dcae-app-view.html', + controller: viewModelsModuleName + hostedApp.state.controllerName + } + ); + } + }); + + $stateProvider.state( + 'catalog', { + url: '/catalog', + templateUrl: './view-models/catalog/catalog-view.html', + controller: viewModelsModuleName + '.CatalogViewModel', + resolve: { + auth: ["$q", "Sdc.Services.UserResourceService", ($q:any, userResourceService:IUserResourceClass) => { + let userInfo:IUserResource = userResourceService.getLoggedinUser(); + if (userInfo) { + return $q.when(userInfo); + } else { + return $q.reject({authenticated: false}); + } + }] + } + } + ); + + $stateProvider.state( + 'support', { + url: '/support', + templateUrl: './view-models/support/support-view.html', + controller: viewModelsModuleName + '.SupportViewModel' + } + ); + + $stateProvider.state( + 'error-403', { + url: '/error-403', + templateUrl: "./view-models/modals/error-modal/error-403-view.html", + controller: viewModelsModuleName + '.ErrorViewModel' + } + ); + + tooltipsConfigProvider.options({ + side: 'bottom', + delay: '600', + class: 'tooltip-custom', + lazy: 0, + try: 0 + }); + + } +]); + +ng1appModule.value('ValidationPattern', /^[\s\w\&_.:-]{1,1024}$/); +ng1appModule.value('ComponentNameValidationPattern', /^(?=.*[^. ])[\s\w\&_.:-]{1,1024}$/); //DE250513 - same as ValidationPattern above, plus requirement that name not consist of dots and/or spaces alone. +ng1appModule.value('PropertyNameValidationPattern', /^[a-zA-Z0-9_:-]{1,50}$/);// DE210977 +ng1appModule.value('TagValidationPattern', /^[\s\w_.-]{1,50}$/); +ng1appModule.value('VendorValidationPattern', /^[\x20-\x21\x23-\x29\x2B-\x2E\x30-\x39\x3B\x3D\x40-\x5B\x5D-\x7B\x7D-\xFF]{1,25}$/); +ng1appModule.value('ContactIdValidationPattern', /^[\s\w-]{1,50}$/); +ng1appModule.value('UserIdValidationPattern', /^[\s\w-]{1,50}$/); +ng1appModule.value('ProjectCodeValidationPattern', /^[\s\w-]{5,50}$/); +ng1appModule.value('LabelValidationPattern', /^[\sa-zA-Z0-9+-]{1,25}$/); +ng1appModule.value('UrlValidationPattern', /^(https?|ftp):\/\/(((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([A-Za-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([A-Za-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([A-Za-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([A-Za-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/); +ng1appModule.value('IntegerValidationPattern', /^(([-+]?\d+)|([-+]?0x[0-9a-fA-F]+))$/); +ng1appModule.value('IntegerNoLeadingZeroValidationPattern', /^(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)$/); +ng1appModule.value('FloatValidationPattern', /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?$/); +ng1appModule.value('NumberValidationPattern', /^((([-+]?\d+)|([-+]?0x[0-9a-fA-F]+))|([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?))$/); +ng1appModule.value('KeyValidationPattern', /^[\s\w-]{1,50}$/); +ng1appModule.value('CommentValidationPattern', /^[\u0000-\u00BF]*$/); +ng1appModule.value('BooleanValidationPattern', /^([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])$/); +ng1appModule.value('MapKeyValidationPattern', /^[\w]{1,50}$/); + +ng1appModule.constant('sdcConfig', sdcConfig); +ng1appModule.constant('sdcMenu', sdcMenu); + +ng1appModule.run([ + '$http', + 'Sdc.Services.CacheService', + 'Sdc.Services.CookieService', + 'Sdc.Services.ConfigurationUiService', + 'Sdc.Services.UserResourceService', + 'Sdc.Services.CategoryResourceService', + 'Sdc.Services.SdcVersionService', + '$state', + '$rootScope', + '$location', + 'sdcMenu', + 'ModalsHandler', + 'Sdc.Services.EcompHeaderService', + 'LeftPaletteLoaderService', + 'Sdc.Services.DataTypesService', + 'AngularJSBridge', + ($http:ng.IHttpService, + cacheService:CacheService, + cookieService:CookieService, + ConfigurationUi:ConfigurationUiService, + UserResourceClass:IUserResourceClass, + categoryResourceService:ICategoryResourceClass, + sdcVersionService:SdcVersionService, + $state:ng.ui.IStateService, + $rootScope:ng.IRootScopeService, + $location:ng.ILocationService, + sdcMenu:IAppMenu, + ModalsHandler:ModalsHandler, + ecompHeaderService:EcompHeaderService, + LeftPaletteLoaderService:LeftPaletteLoaderService, + DataTypesService:DataTypesService, + AngularJSBridge):void => { + + //handle cache data - version + let initAsdcVersion:Function = ():void => { + + let onFailed = (response) => { + console.info('onFailed initAsdcVersion', response); + cacheService.set('version', 'N/A'); + }; + + let onSuccess = (version:any) => { + let tmpVerArray = version.version.split("."); + let ver = tmpVerArray[0] + "." + tmpVerArray[1] + "." + tmpVerArray[2]; + cacheService.set('version', ver); + }; + + sdcVersionService.getVersion().then(onSuccess, onFailed); + + }; + + let initEcompMenu:Function = (user):void => { + ecompHeaderService.getMenuItems(user.userId).then((data)=> { + $rootScope['menuItems'] = data; + }); + }; + + let initConfigurationUi:Function = ():void => { + ConfigurationUi + .getConfigurationUi() + .then((configurationUi:any) => { + cacheService.set('UIConfiguration', configurationUi); + }); + }; + + let initCategories:Function = ():void => { + let onError = ():void => { + console.log('Failed to init categories'); + }; + + categoryResourceService.getAllCategories((categories: Categories):void => { + cacheService.set('serviceCategories', categories.serviceCategories); + cacheService.set('resourceCategories', categories.resourceCategories); + cacheService.set('productCategories', categories.productCategories); + }, onError); + }; + + // Add hosted applications to sdcConfig + sdcConfig.hostedApplications = hostedApplications; + + //handle http config + $http.defaults.withCredentials = true; + $http.defaults.headers.common.Authorization = 'Basic YmVlcDpib29w'; + $http.defaults.headers.common[cookieService.getUserIdSuffix()] = cookieService.getUserId(); + + initAsdcVersion(); + initConfigurationUi(); + // initLeftPalette(); + DataTypesService.initDataTypes(); + + //handle stateChangeStart + let internalDeregisterStateChangeStartWatcher:Function = ():void => { + if (deregisterStateChangeStartWatcher) { + deregisterStateChangeStartWatcher(); + deregisterStateChangeStartWatcher = null; + } + }; + + let removeLoader:Function = ():void => { + $(".sdc-loading-page .main-loader").addClass("animated fadeOut"); + $(".sdc-loading-page .caption1").addClass("animated fadeOut"); + $(".sdc-loading-page .caption2").addClass("animated fadeOut"); + window.setTimeout(():void=> { + $(".sdc-loading-page .main-loader").css("display", "none"); + $(".sdc-loading-page .caption1").css("display", "none"); + $(".sdc-loading-page .caption2").css("display", "none"); + $(".sdc-loading-page").addClass("animated fadeOut"); + }, 1000); + }; + + let onNavigateOut:Function = (toState, toParams):void => { + let onOk = ():void => { + $state.current.data.unsavedChanges = false; + $state.go(toState.name, toParams); + }; + + let data = sdcMenu.alertMessages.exitWithoutSaving; + //open notify to user if changes are not saved + ModalsHandler.openAlertModal(data.title, data.message).then(onOk); + }; + + let onStateChangeStart:Function = (event, toState, toParams, fromState, fromParams):void => { + console.info((new Date()).getTime()); + console.info('$stateChangeStart', toState.name); + //set body class + $rootScope['bodyClass'] = 'default-class'; + if (toState.data && toState.data.bodyClass) { + $rootScope['bodyClass'] = toState.data.bodyClass; + } + + // Workaround in case we are entering other state then workspace (user move to catalog) + // remove the changeComponentCsarVersion, user should open again the VSP list and select one for update. + if (toState.name.indexOf('workspace') === -1) { + if (cacheService.contains(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { + cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + } + } + + //saving last state to params , for breadcrumbs + if (['dashboard', 'catalog', 'onboardVendor'].indexOf(fromState.name) > -1) { + toParams.previousState = fromState.name; + } else { + toParams.previousState = fromParams.previousState; + } + + if (toState.name !== 'error-403' && !UserResourceClass.getLoggedinUser()) { + internalDeregisterStateChangeStartWatcher(); + event.preventDefault(); + + UserResourceClass.authorize().$promise.then((user:IUserResource) => { + if (!doesUserHasAccess(toState, user)) { + $state.go('error-403'); + console.info('User has no permissions'); + registerStateChangeStartWatcher(); + return; + } + UserResourceClass.setLoggedinUser(user); + cacheService.set('user', user); + initCategories(); + // initEcompMenu(user); + setTimeout(function () { + + removeLoader(); + + // initCategories(); + if (UserResourceClass.getLoggedinUser().role === 'ADMIN') { + // toState.name = "adminDashboard"; + $state.go("adminDashboard", toParams); + registerStateChangeStartWatcher(); + return; + } + + // After user authorized init categories + window.setTimeout(():void=> { + if ($state.current.name === '') { + $state.go(toState.name, toParams); + } + + console.log("------$state.current.name=" + $state.current.name); + console.info('-----registerStateChangeStartWatcher authorize $stateChangeStart'); + registerStateChangeStartWatcher(); + + }, 1000); + + }, 0); + + }, () => { + $state.go('error-403'); + + console.info('registerStateChangeStartWatcher error-403 $stateChangeStart'); + registerStateChangeStartWatcher(); + }); + } + else if (UserResourceClass.getLoggedinUser()) { + internalDeregisterStateChangeStartWatcher(); + if (!doesUserHasAccess(toState, UserResourceClass.getLoggedinUser())) { + event.preventDefault(); + $state.go('error-403'); + console.info('User has no permissions'); + } + if (toState.name === "welcome") { + $state.go("dashboard"); + } + registerStateChangeStartWatcher(); + //if form is dirty and not save - notify to user + if (fromState.data && fromState.data.unsavedChanges && fromParams.id != toParams.id) { + event.preventDefault(); + onNavigateOut(toState, toParams); + } + } + + }; + + let doesUserHasAccess:Function = (toState, user):boolean => { + + let isUserHasAccess = true; + if (toState.permissions && toState.permissions.length > 0) { + isUserHasAccess = _.includes(toState.permissions, user.role); + } + return isUserHasAccess; + }; + let deregisterStateChangeStartWatcher:Function; + + let registerStateChangeStartWatcher:Function = ():void => { + internalDeregisterStateChangeStartWatcher(); + console.info('registerStateChangeStartWatcher $stateChangeStart'); + deregisterStateChangeStartWatcher = $rootScope.$on('$stateChangeStart', (event, toState, toParams, fromState, fromParams):void => { + onStateChangeStart(event, toState, toParams, fromState, fromParams); + }); + }; + + registerStateChangeStartWatcher(); + }]); + diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations.less b/catalog-ui/src/app/directives/capabilities-and-requirements/capabilities-requirements-list.less index 212b9785e9..0860261b97 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/relations/relations.less +++ b/catalog-ui/src/app/directives/capabilities-and-requirements/capabilities-requirements-list.less @@ -1,14 +1,15 @@ -.w-sdc-designer-sidebar-tab-content.relations { +.i-sdc-designer-sidebar-capabilities-requirements { - .w-sdc-designer-sidebar-section-content { - padding: 0; - } + .b_7; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; - .w-sdc-designer-sidebar-section-title { - &.expanded { - margin-bottom: 0; + &.description { + margin-top: 28px; + white-space: normal; + word-wrap: break-word; } - } .i-sdc-designer-sidebar-section-content-item-relations { border-bottom: 1px solid @color_e; @@ -28,15 +29,13 @@ display: block; } - } - } + .w-sdc-designer-sidebar-section-relations:not(:last-child) .i-sdc-designer-sidebar-section-content-item-relations-group:last-child .i-sdc-designer-sidebar-section-content-item-relations:last-child { border-bottom: none; } - .i-sdc-designer-sidebar-section-content-item-relations.hand { .hand; } @@ -65,16 +64,16 @@ .i-sdc-designer-sidebar-section-content-item-relations-details-ownerName { .b_13; - font-weight:400; + font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - &:before{ - .sprite; - .arrow-left; - content: ''; - } + &:before { + .sprite; + .arrow-left; + content: ''; + } } .i-sdc-designer-sidebar-section-content-item-relations-details-desc { @@ -82,8 +81,9 @@ line-height: 14px; word-wrap: break-word; white-space: normal; + max-width: 265px; - .i-sdc-designer-sidebar-section-content-item-relations-details-indent-box{ + .i-sdc-designer-sidebar-section-content-item-relations-details-indent-box { border-left: 1px #848586 solid; height: 40px; margin-left: 2px; @@ -92,7 +92,7 @@ width: 25px; float: left; } - .i-sdc-designer-sidebar-section-content-item-relations-details-child{ + .i-sdc-designer-sidebar-section-content-item-relations-details-child { margin-top: 30px; float: left; padding-left: 10px; @@ -110,7 +110,4 @@ top: 22px; display: none; } - } - - diff --git a/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-directive.ts b/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-directive.ts new file mode 100644 index 0000000000..e71478fa4d --- /dev/null +++ b/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-directive.ts @@ -0,0 +1,40 @@ +/** + * Created by ob0695 on 5/9/2017. + */ +/** + * Created by obarda on 1/8/2017. + */ +'use strict'; +import {CapabilitiesGroup} from "app/models"; + +export interface ICapabilitiesListScope extends ng.IScope { + capabilities:CapabilitiesGroup; +} + + +export class CapabilitiesListDirective implements ng.IDirective { + + constructor() { + + } + + scope = { + capabilities: '=', + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./capabilities-list-view.html'); + }; + + link = (scope:ICapabilitiesListScope, element:any, $attr:any) => { + + }; + + public static factory = ()=> { + return new CapabilitiesListDirective(); + }; +} + +CapabilitiesListDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-view.html b/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-view.html new file mode 100644 index 0000000000..c86a6df785 --- /dev/null +++ b/catalog-ui/src/app/directives/capabilities-and-requirements/capability/capabilities-list-view.html @@ -0,0 +1,14 @@ +<div class="i-sdc-designer-sidebar-capabilities-requirements"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-group"> + <div class="i-sdc-designer-sidebar-section-content-item-relations" + data-ng-repeat="capability in capabilities track by $index"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{capability.name}} </div> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-desc" sdc-smart-tooltip> + {{capability.type}} + </div> + </div> + </div> + </div> +</div> + diff --git a/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-directive.ts b/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-directive.ts new file mode 100644 index 0000000000..9863b5d271 --- /dev/null +++ b/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-directive.ts @@ -0,0 +1,71 @@ +/** + * Created by ob0695 on 5/9/2017. + */ +/** + * Created by ob0695 on 5/9/2017. + */ +/** + * Created by obarda on 1/8/2017. + */ +'use strict'; +import {RequirementsGroup, Component} from "app/models"; + +export interface IRequirementsListScope extends ng.IScope { + + requirements:RequirementsGroup; + currentComponent: Component; +} + + +export class RequirementsListDirective implements ng.IDirective { + + constructor(private $filter: ng.IFilterService) { + + } + + scope = { + requirements: '=', + component: '=' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./requirements-list-view.html'); + }; + + link = (scope:IRequirementsListScope) => { + + scope.isInstanceSelected = () : boolean => { + return scope.component && scope.component.selectedInstance != undefined && scope.component.selectedInstance != null; + } + + scope.getRelation = (requirement:any):any => { + if (scope.isInstanceSelected() && scope.component.componentInstancesRelations) { + let relationItem = _.filter(scope.component.componentInstancesRelations, (relation:any) => { + return relation.fromNode === scope.component.selectedInstance.uniqueId && + _.some(relation.relationships, { + 'requirement': requirement.name, + 'requirementOwnerId': requirement.ownerId + }); + }); + + if (relationItem && relationItem.length) { + return { + type: requirement.relationship.split('.').pop(), + requirementName: this.$filter('resourceName')(scope.component.componentInstances[_.map + (scope.component.componentInstances, "uniqueId").indexOf(relationItem[0].toNode)].name) + }; + } + } + return null; + }; + + }; + + public static factory = ($filter: ng.IFilterService)=> { + return new RequirementsListDirective($filter); + }; +} + +RequirementsListDirective.factory.$inject = ['$filter']; diff --git a/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-view.html b/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-view.html new file mode 100644 index 0000000000..a6487fe72a --- /dev/null +++ b/catalog-ui/src/app/directives/capabilities-and-requirements/requirement/requirements-list-view.html @@ -0,0 +1,19 @@ +<div class="i-sdc-designer-sidebar-capabilities-requirements"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-group"> + <div class="i-sdc-designer-sidebar-section-content-item-relations" + data-ng-repeat="requirement in requirements track by $index"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{requirement.name}} </div> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-desc">{{requirement.node}} + <div data-ng-if="getRelation(requirement) != null"> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-indent-box"></div> + <div class="i-sdc-designer-sidebar-section-content-item-relations-details-child"> + <span class="i-sdc-designer-sidebar-section-content-item-relations-details-desc">{{getRelation(requirement).type}} <br/></span> + <span class="i-sdc-designer-sidebar-section-content-item-relations-details-name">{{getRelation(requirement).requirementName}}</span> + </div> + </div> + </div> + </div> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/directives/clicked-outside/clicked-outside-directive.ts b/catalog-ui/src/app/directives/clicked-outside/clicked-outside-directive.ts new file mode 100644 index 0000000000..009e104740 --- /dev/null +++ b/catalog-ui/src/app/directives/clicked-outside/clicked-outside-directive.ts @@ -0,0 +1,110 @@ +class ClickedOutsideModel { + + private clickedOutsideContainerSelector:string; + private onClickedOutsideGetter:Function; + private clickedOutsideEnableGetter:Function; + + constructor(clickedOutsideData:any) { + this.clickedOutsideContainerSelector = clickedOutsideData.clickedOutsideContainerSelector; + this.onClickedOutsideGetter = clickedOutsideData.onClickedOutsideGetter; + this.clickedOutsideEnableGetter = clickedOutsideData.clickedOutsideEnableGetter; + } + + public getClickedOutsideContainerSelector = ():string => { + return this.clickedOutsideContainerSelector; + } + + public getOnClickedOutsideGetter = ():Function => { + return this.onClickedOutsideGetter; + } + + public getClickedOutsideEnableGetter = ():Function => { + return this.clickedOutsideEnableGetter; + } +} + +export interface IClickedOutsideDirectiveScope extends ng.IScope { +} + +export class ClickedOutsideDirective implements ng.IDirective { + + constructor(private $document:JQuery, private $parse:ng.IParseService) { + } + + restrict = 'A'; + + link = (scope:IClickedOutsideDirectiveScope, element:JQuery, attrs) => { + + let container:HTMLElement; + let attrsAfterEval = scope.$eval(attrs.clickedOutside); + attrsAfterEval.onClickedOutsideGetter = this.$parse(attrsAfterEval.onClickedOutside); + attrsAfterEval.clickedOutsideEnableGetter = this.$parse(attrsAfterEval.clickedOutsideEnable); + + let clickedOutsideModel:ClickedOutsideModel = new ClickedOutsideModel(attrsAfterEval); + + + let getContainer:Function = ():HTMLElement => { + if (!container) { + let clickedOutsideContainerSelector:string = clickedOutsideModel.getClickedOutsideContainerSelector(); + if (!angular.isUndefined(clickedOutsideContainerSelector) && clickedOutsideContainerSelector !== '') { + container = element.parents(clickedOutsideContainerSelector + ':first')[0]; + if (!container) { + container = element[0]; + } + } else { + container = element[0]; + } + } + return container; + }; + + + let onClickedOutside = (event:JQueryEventObject) => { + let containerDomElement:HTMLElement = getContainer(); + let targetDomElementJq:JQuery = angular.element(event.target); + if (targetDomElementJq.hasClass('tooltip') || targetDomElementJq.parents('.tooltip:first').length) { + return; + } + let targetDomElement:HTMLElement = targetDomElementJq[0]; + if (!containerDomElement.contains(targetDomElement)) { + scope.$apply(() => { + let onClickedOutsideGetter:Function = clickedOutsideModel.getOnClickedOutsideGetter(); + onClickedOutsideGetter(scope); + }); + } + }; + + let attachDomEvents:Function = () => { + this.$document.on('mousedown', onClickedOutside); + }; + + let detachDomEvents:Function = () => { + this.$document.off('mousedown', onClickedOutside); + }; + + // + scope.$on('$destroy', () => { + detachDomEvents(); + }); + + + scope.$watch(() => { + let clickedOutsideEnableGetter:Function = clickedOutsideModel.getClickedOutsideEnableGetter(); + return clickedOutsideEnableGetter(scope); + }, (newValue:boolean) => { + if (newValue) { + attachDomEvents(); + return; + } + detachDomEvents(); + }); + + + } + + public static factory = ($document:JQuery, $parse:ng.IParseService) => { + return new ClickedOutsideDirective($document, $parse); + } +} + +ClickedOutsideDirective.factory.$inject = ['$document', '$parse']; diff --git a/catalog-ui/src/app/directives/custom-validation/custom-validation.ts b/catalog-ui/src/app/directives/custom-validation/custom-validation.ts new file mode 100644 index 0000000000..e35a747e1b --- /dev/null +++ b/catalog-ui/src/app/directives/custom-validation/custom-validation.ts @@ -0,0 +1,32 @@ +'use strict'; +export interface ICustomValidationScope extends ng.IScope { + validationFunc:Function; +} + +export class CustomValidationDirective implements ng.IDirective { + + constructor() { + } + + require = 'ngModel'; + restrict = 'A'; + + scope = { + validationFunc: '=' + }; + + link = (scope:ICustomValidationScope, elem, attrs, ngModel) => { + + ngModel.$validators.customValidation = (modelValue, viewValue):boolean => { + return scope.validationFunc(viewValue); + }; + + }; + + public static factory = ()=> { + return new CustomValidationDirective(); + }; + +} + +CustomValidationDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/download-artifact/download-artifact.ts b/catalog-ui/src/app/directives/download-artifact/download-artifact.ts new file mode 100644 index 0000000000..7c817935cf --- /dev/null +++ b/catalog-ui/src/app/directives/download-artifact/download-artifact.ts @@ -0,0 +1,125 @@ +'use strict'; +import {IFileDownload, Component, ArtifactModel} from "app/models"; +import {EventListenerService, CacheService} from "app/services"; +import {EVENTS, FileUtils} from "app/utils"; + +export class DOWNLOAD_CSS_CLASSES { + static DOWNLOAD_ICON = "table-download-btn tosca"; + static LOADER_ICON = "tlv-loader small loader"; +} + +export interface IDownloadArtifactScope extends ng.IScope { + $window:any; + artifact:ArtifactModel; + component:Component; + instance:boolean; + download:Function; + showLoader:boolean; + downloadIconClass:string; + updateDownloadIcon:Function; +} + +export class DownloadArtifactDirective implements ng.IDirective { + + constructor(private $window:any, private cacheService:CacheService, private EventListenerService:EventListenerService, private fileUtils:FileUtils) { + } + + scope = { + artifact: '=', + component: '=', + instance: '=', + showLoader: '=', + downloadIconClass: '@' + }; + restrict = 'EA'; + + link = (scope:IDownloadArtifactScope, element:any) => { + scope.$window = this.$window; + + element.on("click", function () { + scope.download(scope.artifact); + }); + + + let initDownloadLoader = ()=> { + //if the artifact is in a middle of download progress register form callBack & change icon from download to loader + if (scope.showLoader && this.cacheService.get(scope.artifact.uniqueId)) { + this.EventListenerService.registerObserverCallback(EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId, scope.updateDownloadIcon); + window.setTimeout(():void => { + if (this.cacheService.get(scope.artifact.uniqueId)) { + element[0].className = DOWNLOAD_CSS_CLASSES.LOADER_ICON; + } + }, 1000); + + } + }; + + let setDownloadedFileLoader = ()=> { + if (scope.showLoader) { + //set in cache service thet the artifact is in download progress + this.cacheService.set(scope.artifact.uniqueId, true); + initDownloadLoader(); + } + }; + + let removeDownloadedFileLoader = ()=> { + if (scope.showLoader) { + this.cacheService.set(scope.artifact.uniqueId, false); + this.EventListenerService.notifyObservers(EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId); + } + }; + + + //replace the loader to download icon + scope.updateDownloadIcon = () => { + element[0].className = scope.downloadIconClass || DOWNLOAD_CSS_CLASSES.DOWNLOAD_ICON; + }; + + + initDownloadLoader(); + + scope.download = (artifact:ArtifactModel):void => { + + let onFaild = (response):void => { + console.info('onFaild', response); + removeDownloadedFileLoader(); + }; + + let onSuccess = (data:IFileDownload):void => { + downloadFile(data); + removeDownloadedFileLoader(); + }; + + setDownloadedFileLoader(); + + if (scope.instance) { + scope.component.downloadInstanceArtifact(artifact.uniqueId).then(onSuccess, onFaild); + } else { + scope.component.downloadArtifact(artifact.uniqueId).then(onSuccess, onFaild); + } + }; + + let downloadFile = (file:IFileDownload):void => { + if (file) { + let blob = this.fileUtils.base64toBlob(file.base64Contents, ''); + let fileName = file.artifactName; + this.fileUtils.downloadFile(blob, fileName); + } + }; + + element.on('$destroy', ()=> { + //remove listener of download event + if (scope.artifact && scope.artifact.uniqueId) { + this.EventListenerService.unRegisterObserver(EVENTS.DOWNLOAD_ARTIFACT_FINISH_EVENT + scope.artifact.uniqueId); + } + }); + + }; + + public static factory = ($window:any, cacheService:CacheService, EventListenerService:EventListenerService, fileUtils:FileUtils)=> { + return new DownloadArtifactDirective($window, cacheService, EventListenerService, fileUtils); + }; + +} + +DownloadArtifactDirective.factory.$inject = ['$window', 'Sdc.Services.CacheService', 'EventListenerService', 'FileUtils']; diff --git a/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.html b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.html new file mode 100644 index 0000000000..a50731443d --- /dev/null +++ b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.html @@ -0,0 +1,8 @@ +<div class="footer-wrapper"> + <div class="divider-footer-bottom"> + <div class="footer-copyright-text"> + <p> + </p> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.less b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.less new file mode 100644 index 0000000000..4c54a11fec --- /dev/null +++ b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.less @@ -0,0 +1,47 @@ + +.footer-wrapper { + position: fixed; + bottom: 0px; + left: 0px; + width: 100%; + background-color: #222222; + color: #ffffff; + font-family: "Arial"; + font-size: 11px; + height: @footer_height; +} + +.footer-wrapper a { + color: #ffffff; + margin: 0; + padding: 0; + text-decoration: underline; +} + +.divider-footer-bottom { + margin: 0 auto; + width: 1020px; +} + +.footer-copyright-text { + display: inline-block; + width:612px; + margin-top: 18px; + margin-left: 50px; + text-align: left; + vertical-align: top; +} + +.footer-logo1 { + display: inline-block; + margin-top: 20px; + margin-left: 124px; +} + +.footer-logo2 { + margin-top: 22px; + margin-left: 9px; + display: inline-block; + font-size: 24px; + vertical-align: top; +} diff --git a/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.ts b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.ts new file mode 100644 index 0000000000..f104926fc6 --- /dev/null +++ b/catalog-ui/src/app/directives/ecomp-footer/ecomp-footer.ts @@ -0,0 +1,33 @@ +'use strict'; +import {IAppConfigurtaion} from "app/models"; + +export interface IEcompFooterDirectiveScope extends ng.IScope { + +} + +export class EcompFooterDirective implements ng.IDirective { + + constructor(private sdcConfig:IAppConfigurtaion) { + + } + + public replace = true; + public restrict = 'E'; + + public scope = {}; + + template = ():string => { + return require('./ecomp-footer.html'); + }; + + link = (scope:IEcompFooterDirectiveScope, $elem:JQuery, attr:any) => { + + }; + + public static factory = (sdcConfig:IAppConfigurtaion)=> { + return new EcompFooterDirective(sdcConfig); + }; + +} + +EcompFooterDirective.factory.$inject = ['sdcConfig']; diff --git a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.html b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.html index e86f9df8b0..67799420f4 100644 --- a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.html +++ b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.html @@ -3,8 +3,8 @@ <div class="sdc-ecomp-header"> <div class="sdc-ecomp-logo-wrapper"> - <a class="sdc-ecomp-header-title" data-ng-if="clickableLogo==='true'" data-ui-sref="dashboard"><span class="sdc-ecomp-logo"></span>ASDC</a> - <a class="sdc-ecomp-header-title" data-ng-if="clickableLogo==='false'"><span class="sdc-ecomp-logo"></span>ASDC</a> + <a class="sdc-ecomp-header-title" data-ng-if="clickableLogo==='true'" data-ui-sref="dashboard" translate="PROJECT_TITLE"><span class="sdc-ecomp-logo"></span></a> + <a class="sdc-ecomp-header-title" data-ng-if="clickableLogo==='false'"><span class="sdc-ecomp-logo" translate="PROJECT_TITLE"></span></a> <div class="sdc-ecomp-header-version"> v.{{version}}</div> </div> diff --git a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.less b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.less index a6f7e9b5a2..8fa80c4237 100644 --- a/catalog-ui/app/scripts/directives/ecomp-header/ecomp-header.less +++ b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.less @@ -214,7 +214,7 @@ position: relative; .sdc-ecomp-logo { - background-image: url("images/att_logo_white.png"); + background-image: url("/assets/styles/images/att_logo_white.png"); background-repeat: no-repeat; display: inline-block; vertical-align: middle; diff --git a/catalog-ui/src/app/directives/ecomp-header/ecomp-header.ts b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.ts new file mode 100644 index 0000000000..ba96e80484 --- /dev/null +++ b/catalog-ui/src/app/directives/ecomp-header/ecomp-header.ts @@ -0,0 +1,217 @@ +'use strict'; +import {IAppConfigurtaion, User, IUser} from "app/models"; +import {IUserResourceClass, IUserResource} from "app/services"; + +export class MenuItem { + menuId:number; + column:number; + text:string; + parentMenuId:number; + url:string; + children:Array<MenuItem> +} + +export interface IEcompHeaderDirectiveScope extends ng.IScope { + menuData:Array<MenuItem>; + version:string; + clickableLogo:string; + contactUsUrl:string; + getAccessUrl:string; + megaMenuDataObjectTemp:Array<any>; + megaMenuDataObject:Array<any>; + + selectedTopMenu:MenuItem; + selectedSubMenu:MenuItem; + + firstMenuLevelClick:Function; + subMenuEnterAction:Function; + subMenuLeaveAction:Function; + + memuItemClick:Function; + user:IUser; +} + +export class EcompHeaderDirective implements ng.IDirective { + + constructor(private $http:ng.IHttpService, + private sdcConfig:IAppConfigurtaion, + private UserResourceClass:IUserResourceClass) { + + } + + scope = { + menuData: '=', + version: '@', + clickableLogo: '@?' + }; + + public replace = true; + public restrict = 'E'; + public controller = EcompHeaderController; + + template = ():string => { + return 'src/app/directives/ecomp-header/ecomp-header.html'; + }; + + link = ($scope:IEcompHeaderDirectiveScope, $elem:JQuery, attr:any) => { + + if (!$scope.clickableLogo) { + $scope.clickableLogo = "true"; + } + + let findMenuItemById = (menuId):MenuItem => { + let selectedMenuItem:MenuItem = _.find($scope.menuData, (item:MenuItem)=> { + if (item.menuId === menuId) { + return item; + } + }); + return selectedMenuItem; + }; + + let initUser = ():void => { + let defaultUserId:string; + let user:IUserResource = this.UserResourceClass.getLoggedinUser(); + if (!user) { + defaultUserId = this.$http.defaults.headers.common[this.sdcConfig.cookie.userIdSuffix]; + user = this.UserResourceClass.get({id: defaultUserId}, ():void => { + $scope.user = new User(user); + }); + } else { + $scope.user = new User(user); + } + }; + + $scope.firstMenuLevelClick = (menuId:number):void => { + let selectedMenuItem:MenuItem = _.find($scope.megaMenuDataObjectTemp, (item:MenuItem)=> { + if (item.menuId === menuId) { + return item; + } + }); + if (selectedMenuItem) { + $scope.selectedTopMenu = selectedMenuItem; + //console.log("Selected menu item: " + selectedMenuItem.text); + } + }; + + $scope.subMenuEnterAction = (menuId:number):void => { + $scope.selectedSubMenu = findMenuItemById(menuId); + }; + + $scope.subMenuLeaveAction = (menuId:number):void => { + $scope.selectedTopMenu = undefined; + }; + + $scope.memuItemClick = (menuItem:MenuItem):void => { + if (menuItem.url) { + window.location.href = menuItem.url; + } else { + console.log("Menu item: " + menuItem.text + " does not have defined URL!"); + } + }; + + initUser(); + + }; + + public static factory = ($http:ng.IHttpService, + sdcConfig:IAppConfigurtaion, + UserResourceClass:IUserResourceClass)=> { + return new EcompHeaderDirective($http, sdcConfig, UserResourceClass); + }; + +} + +export class EcompHeaderController { + + messages:any; + getAttachId:Function; + render:any; + reRender:Function; + register:Function; + deregister:Function; + head:any; + + static '$inject' = [ + '$element', + '$scope', + '$attrs', + '$animate' + ]; + + constructor(private $element:JQuery, + private $scope:IEcompHeaderDirectiveScope, + private $attrs:ng.IAttributes, + private $animate:any) { + + this.$scope = $scope; + + this.$scope.$watch('menuData', (newVal, oldVal) => { + if (newVal) { + this.init(); + } + }); + + } + + init = ():void => { + + this.$scope.contactUsUrl = "https://wiki.web.att.com/display/EcompPortal/ECOMP+Portal+Home"; + this.$scope.getAccessUrl = "http://ecomp-tlv-dev2.uccentral.att.com:8080/ecompportal/get_access"; + + let unflatten = (array, parent?, tree?) => { + tree = typeof tree !== 'undefined' ? tree : []; + parent = typeof parent !== 'undefined' ? parent : {menuId: null}; + let children = _.filter(array, function (child) { + return child["parentMenuId"] == parent.menuId; + }); + if (!_.isEmpty(children)) { + if (parent.menuId === null) { + tree = children; + } else { + parent['children'] = children + } + _.each(children, function (child) { + unflatten(array, child) + }); + } + return tree; + }; + + let menuStructureConvert = (menuItems) => { + console.log(menuItems); + this.$scope.megaMenuDataObjectTemp = [ + { + menuId: 1001, + text: "ECOMP", + children: menuItems + }, + { + menuId: 1002, + text: "Help", + children: [ + { + text: "Contact Us", + url: this.$scope.contactUsUrl + }] + } + ]; + + /*{ + text:"Get Access", + url: this.$scope.getAccessUrl + }*/ + return this.$scope.megaMenuDataObjectTemp; + }; + + let a = unflatten(this.$scope.menuData); + this.$scope.megaMenuDataObject = menuStructureConvert(a); + //console.log(this.$scope.megaMenuDataObject); + }; +} + +EcompHeaderDirective.factory.$inject = ['$http', 'sdcConfig', 'Sdc.Services.UserResourceService']; + + + + + diff --git a/catalog-ui/app/scripts/directives/edit-name-popover/edit-module-name-popover.html b/catalog-ui/src/app/directives/edit-name-popover/edit-module-name-popover.html index d90c52d9a6..d90c52d9a6 100644 --- a/catalog-ui/app/scripts/directives/edit-name-popover/edit-module-name-popover.html +++ b/catalog-ui/src/app/directives/edit-name-popover/edit-module-name-popover.html diff --git a/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-directive.ts b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-directive.ts new file mode 100644 index 0000000000..b99f11fcf9 --- /dev/null +++ b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-directive.ts @@ -0,0 +1,77 @@ +'use strict'; + +export interface IEditNamePopoverDirectiveScope extends ng.IScope { + isOpen:boolean; + templateUrl:string; + module:any; + direction:string; + header:string; + heatNameValidationPattern:RegExp; + originalName:string; + onSave:any; + + closePopover(isCancel:boolean):void; + validateField(field:any, originalName:string):boolean; + updateHeatName(heatName:string):void; + onInit():void; +} + +export class EditNamePopoverDirective implements ng.IDirective { + + constructor(private ValidationPattern:RegExp,private $templateCache:ng.ITemplateCacheService) { + } + + scope = { + direction: "@?", + module: "=", + header: "@?", + onSave: "&" + }; + + link = (scope:IEditNamePopoverDirectiveScope) => { + if (!scope.direction) { + scope.direction = 'top'; + } + + scope.originalName = ''; + this.$templateCache.put("edit-module-name-popover.html", require('./edit-module-name-popover.html')); + scope.templateUrl = "edit-module-name-popover.html"; + scope.isOpen = false; + + scope.closePopover = (isCancel:boolean = true) => { + scope.isOpen = !scope.isOpen; + + if (isCancel) { + scope.module.heatName = scope.originalName; + } + }; + + scope.onInit = () => { + scope.originalName = scope.module.heatName; + }; + + scope.validateField = (field:any):boolean => { + return !!(field && field.$dirty && field.$invalid); + }; + + scope.heatNameValidationPattern = this.ValidationPattern; + + scope.updateHeatName = () => { + scope.closePopover(false); + scope.onSave(); + } + + }; + + replace = true; + restrict = 'E'; + template = ():string => { + return require('./edit-name-popover-view.html'); + }; + + public static factory = (ValidationPattern:RegExp,$templateCache:ng.ITemplateCacheService)=> { + return new EditNamePopoverDirective(ValidationPattern,$templateCache); + } +} + +EditNamePopoverDirective.factory.$inject = ['ValidationPattern','$templateCache']; diff --git a/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-view.html b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-view.html new file mode 100644 index 0000000000..23340ccee2 --- /dev/null +++ b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover-view.html @@ -0,0 +1 @@ +<div uib-popover-template="templateUrl" popover-class="edit-name-popover" popover-title="{{header}}" popover-placement="{{direction}}" popover-is-open="isOpen" popover-append-to-body="true"></div> diff --git a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover.less b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover.less index 3d76a352ce..55dcd80a27 100644 --- a/catalog-ui/app/scripts/directives/edit-name-popover/edit-name-popover.less +++ b/catalog-ui/src/app/directives/edit-name-popover/edit-name-popover.less @@ -1,9 +1,18 @@ -.popover { +.edit-name-popover{ max-width: none; width: 310px; left: initial !important; right: 10px; z-index: 100; + + .arrow { + left: 95% !important; + border-width: 7px; + bottom: -8px !important; + } +} + +.popover { border-radius: 0; .top > .arrow { @@ -20,12 +29,6 @@ font-weight: bold; } - .arrow { - left: 95% !important; - border-width: 7px; - bottom: -8px !important; - } - .popover-content { width: inherit; padding: 9px 20px; diff --git a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.html b/catalog-ui/src/app/directives/elements/checkbox/checkbox.html index daf2a89ac2..1e25408188 100644 --- a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.html +++ b/catalog-ui/src/app/directives/elements/checkbox/checkbox.html @@ -7,6 +7,7 @@ ng-disabled="disabled" checklist-model="sdcChecklistModel" checklist-value="sdcChecklistValue" + checklist-change="sdcChecklistChange()" /> <span sdc-smart-tooltip class="tlv-checkbox-label" data-tests-id="{{elemId}}">{{text}}</span> diff --git a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.less b/catalog-ui/src/app/directives/elements/checkbox/checkbox.less index 0747a680a9..0747a680a9 100644 --- a/catalog-ui/app/scripts/directives/elements/checkbox/checkbox.less +++ b/catalog-ui/src/app/directives/elements/checkbox/checkbox.less diff --git a/catalog-ui/src/app/directives/elements/checkbox/checkbox.ts b/catalog-ui/src/app/directives/elements/checkbox/checkbox.ts new file mode 100644 index 0000000000..ec0be8ab07 --- /dev/null +++ b/catalog-ui/src/app/directives/elements/checkbox/checkbox.ts @@ -0,0 +1,43 @@ +'use strict'; + +export interface ICheckboxElementScope extends ng.IScope { + elemId:string; + text:string; + sdcChecklistModel:any; + sdcChecklistValue:string; + disabled:boolean; +} + +export class CheckboxElementDirective implements ng.IDirective { + + constructor(private $filter:ng.IFilterService) { + } + + public replace = true; + public restrict = 'E'; + public transclude = false; + + scope = { + elemId: '@', + text: '@', + disabled: '=', + sdcChecklistModel: '=', + sdcChecklistValue: '=', + sdcChecklistChange: '&' + }; + + template = ():string => { + return require('./checkbox.html'); + }; + + public link = (scope:ICheckboxElementScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + + }; + + public static factory = ($filter:ng.IFilterService)=> { + return new CheckboxElementDirective($filter); + }; + +} + +CheckboxElementDirective.factory.$inject = ['$filter']; diff --git a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.html b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.html index b31fae5d73..b31fae5d73 100644 --- a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.html +++ b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.html diff --git a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.less b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.less index e69de29bb2..e69de29bb2 100644 --- a/catalog-ui/app/scripts/directives/elements/radiobutton/radiobutton.less +++ b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.less diff --git a/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.ts b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.ts new file mode 100644 index 0000000000..1384a82674 --- /dev/null +++ b/catalog-ui/src/app/directives/elements/radiobutton/radiobutton.ts @@ -0,0 +1,48 @@ +import INgModelController = angular.INgModelController; +'use strict'; + +export interface IRadiobuttonElementScope extends ng.IScope { + elemId:string; + elemName:string; + text:string; + sdcModel:any; + value:any; + disabled:boolean; + onValueChange:Function; +} + +export class RadiobuttonElementDirective implements ng.IDirective { + + constructor(private $filter:ng.IFilterService) { + } + + public replace = true; + public restrict = 'E'; + public transclude = false; + + scope = { + elemId: '@', + elemName: '@', + text: '@', + sdcModel: '=', + value: '@', + disabled: '=', + onValueChange: '&' + }; + + template = ():string => { + return require('./radiobutton.html'); + }; + + public link = (scope:IRadiobuttonElementScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + //$elem.removeAttr("id") + //console.log(scope.sdcChecklistValue); + }; + + public static factory = ($filter:ng.IFilterService)=> { + return new RadiobuttonElementDirective($filter); + }; + +} + +RadiobuttonElementDirective.factory.$inject = ['$filter']; diff --git a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.html b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.html index 31fa06adda..31fa06adda 100644 --- a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.html +++ b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.html diff --git a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.less b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.less index d8dfdbb73b..d8dfdbb73b 100644 --- a/catalog-ui/app/scripts/directives/ellipsis/ellipsis-directive.less +++ b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.less diff --git a/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.ts b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.ts new file mode 100644 index 0000000000..8fbbd4d486 --- /dev/null +++ b/catalog-ui/src/app/directives/ellipsis/ellipsis-directive.ts @@ -0,0 +1,57 @@ +'use strict'; +export interface IEllipsisScope extends ng.IScope { + ellipsis:string; + maxChars:number; + toggleText():void; + collapsed:boolean; + actualText:string; + +} + +export class EllipsisDirective implements ng.IDirective { + + constructor() { + } + + scope = { + ellipsis: '=', + moreClass: '@', + maxChars: '=' + }; + + replace = false; + restrict = 'A'; + template = ():string => { + return require('./ellipsis-directive.html'); + }; + + link = (scope:IEllipsisScope, $elem:any) => { + + + scope.collapsed = true; + + scope.toggleText = ():void => { + if (scope.ellipsis && scope.collapsed) { + scope.actualText = scope.ellipsis.substr(0, scope.maxChars); + scope.actualText += scope.ellipsis.length > scope.maxChars ? '...' : ''; + } + else { + scope.actualText = scope.ellipsis; + } + }; + + scope.$watch("ellipsis", function () { + scope.collapsed = true; + scope.toggleText(); + }); + + + }; + + public static factory = ()=> { + return new EllipsisDirective(); + }; + +} + +EllipsisDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/events/on-last-repeat/on-last-repeat.ts b/catalog-ui/src/app/directives/events/on-last-repeat/on-last-repeat.ts new file mode 100644 index 0000000000..84014159f0 --- /dev/null +++ b/catalog-ui/src/app/directives/events/on-last-repeat/on-last-repeat.ts @@ -0,0 +1,40 @@ +'use strict'; + +/** + * Usage: + * In data-ng-repeat html: <ol ng-repeat="record in records" on-last-repeat> + * In the controller, catch the last repeat: + * $scope.$on('onRepeatLast', function(scope, element, attrs){ + * //work your magic + * }); + */ +export interface IOnLastRepeatDirectiveScope extends ng.IScope { + $last:any; +} + +export class OnLastRepeatDirective implements ng.IDirective { + + constructor() { + } + + scope = {}; + + restrict = 'AE'; + replace = true; + + link = (scope:IOnLastRepeatDirectiveScope, element:any, attrs:any) => { + let s:any = scope.$parent; // repeat scope + if (s.$last) { + setTimeout(function () { + s.$emit('onRepeatLast', element, attrs); + }, 1); + } + }; + + public static factory = ()=> { + return new OnLastRepeatDirective(); + }; + +} + +OnLastRepeatDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.html b/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.html new file mode 100644 index 0000000000..55696b33fa --- /dev/null +++ b/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.html @@ -0,0 +1,7 @@ +<span data-ng-click="export()" + class="sprite-new download-btn hand" + uib-tooltip="Download" + tooltip-class="uib-custom-tooltip" + tooltip-placement="bottom" + data-tests-id="download-excel"></span> + diff --git a/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.ts b/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.ts new file mode 100644 index 0000000000..deb1c94936 --- /dev/null +++ b/catalog-ui/src/app/directives/export-json-to-excel/export-json-to-excel.ts @@ -0,0 +1,61 @@ +'use strict'; +import {FileUtils} from "app/utils"; + +export interface IJsonExportExcelScope extends ng.IScope { + initExportExcelData:Function; + export:()=>void; +} + +export class JsonExportExcelDirective implements ng.IDirective { + + constructor(private fileUtils:FileUtils) { + } + + scope = { + initExportExcelData: '&'//get function that init and returns Models.ExportExcel + }; + + public restrict = 'E'; + replace = true; + template = ():string => { + return require('./export-json-to-excel.html'); + }; + + private jsonToTableText = (headers:string, dataObj:Array<Object>):string=> { + let tableText = headers + "\n"; + _.each(dataObj, (rowData:any) => { + tableText += _.values(rowData).join() + "\n"; + }); + return tableText; + }; + + link = (scope:IJsonExportExcelScope, $elem:any) => { + scope.export = ():void => { + let exportExcelData = scope.initExportExcelData(); + exportExcelData.fileName = !!exportExcelData.fileName ? exportExcelData.fileName : 'export-excel'; + + let headers = exportExcelData.tableHeaders.join(","); + let tableData = ""; + if (exportExcelData.groupByField) { + _.each(_.groupBy(exportExcelData.dataObj, exportExcelData.groupByField), (groupData:Array<Object>) => { + tableData += this.jsonToTableText(headers, groupData); + tableData += '\n'; + }); + } else { + tableData = this.jsonToTableText(headers, exportExcelData.dataObj); + } + + let blob = new Blob([exportExcelData.metaData.join('\n\n') + '\n\n' + tableData], {type: "text/csv;charset=utf-8"}); + + return this.fileUtils.downloadFile(blob, exportExcelData.fileName + '.csv'); + }; + + }; + + public static factory = (fileUtils:FileUtils)=> { + return new JsonExportExcelDirective( fileUtils); + }; + +} + +JsonExportExcelDirective.factory.$inject = ['FileUtils']; diff --git a/catalog-ui/app/scripts/directives/file-opener/file-opener.html b/catalog-ui/src/app/directives/file-opener/file-opener.html index 38f82554e9..38f82554e9 100644 --- a/catalog-ui/app/scripts/directives/file-opener/file-opener.html +++ b/catalog-ui/src/app/directives/file-opener/file-opener.html diff --git a/catalog-ui/src/app/directives/file-opener/file-opener.ts b/catalog-ui/src/app/directives/file-opener/file-opener.ts new file mode 100644 index 0000000000..95e43262f5 --- /dev/null +++ b/catalog-ui/src/app/directives/file-opener/file-opener.ts @@ -0,0 +1,54 @@ +'use strict'; + +export interface IFileOpenerScope extends ng.IScope { + importFile:any; + testsId:any; + extensions:string; + + onFileSelect():void; + onFileUpload(file:any):void; + getExtensionsWithDot():string; +} + +export class FileOpenerDirective implements ng.IDirective { + + constructor(private $compile:ng.ICompileService) { + } + + scope = { + onFileUpload: '&', + testsId: '@', + extensions: '@' + }; + + restrict = 'AE'; + replace = true; + template = ():string => { + return require('./file-opener.html'); + }; + + link = (scope:IFileOpenerScope, element:any) => { + + scope.onFileSelect = () => { + scope.onFileUpload({file: scope.importFile}); + element.html('app/directives/file-opener/file-opener.html'); + this.$compile(element.contents())(scope); + }; + + scope.getExtensionsWithDot = ():string => { + let ret = []; + _.each(scope.extensions.split(','), function (item) { + ret.push("." + item.toString()); + }); + return ret.join(","); + }; + + }; + + public static factory = ($compile:ng.ICompileService)=> { + return new FileOpenerDirective($compile); + }; + +} + +FileOpenerDirective.factory.$inject = ['$compile']; diff --git a/catalog-ui/src/app/directives/file-type/file-type.ts b/catalog-ui/src/app/directives/file-type/file-type.ts new file mode 100644 index 0000000000..11795724d0 --- /dev/null +++ b/catalog-ui/src/app/directives/file-type/file-type.ts @@ -0,0 +1,45 @@ +'use strict'; + +export class FileTypeDirective implements ng.IDirective { + + constructor() { + } + + require = 'ngModel'; + + link = (scope, elem, attrs, ngModel) => { + + let typesToApprove = ""; + + attrs.$observe('fileType', (val:string) => { + typesToApprove = val; + validate(ngModel.$viewValue); + }); + + let validate:Function = function (value) { + let fileName:string = elem.val(), valid:boolean = true; + + if (fileName && value && typesToApprove) { + let extension:string = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase(); + valid = typesToApprove.split(',').indexOf(extension) > -1; + } + + ngModel.$setValidity('filetype', valid); + if (!value) { + ngModel.$setPristine(); + } + return value; + }; + + //For DOM -> model validation + ngModel.$parsers.unshift(validate); + + }; + + public static factory = ()=> { + return new FileTypeDirective(); + }; + +} + +FileTypeDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/file-upload/file-upload.html b/catalog-ui/src/app/directives/file-upload/file-upload.html index 7cbc8d25f3..a69340d0ba 100644 --- a/catalog-ui/app/scripts/directives/file-upload/file-upload.html +++ b/catalog-ui/src/app/directives/file-upload/file-upload.html @@ -12,6 +12,7 @@ data-ng-change="onFileChange()" onchange="angular.element(this).scope().setEmptyError(this)" onclick="angular.element(this).scope().onFileClick(this)" + on-after-validate="onAfterValidate" data-ng-required="{{elementRequired}}" data-ng-disabled="elementDisabled==='true'" data-tests-id="browseButton" diff --git a/catalog-ui/app/scripts/directives/file-upload/file-upload.less b/catalog-ui/src/app/directives/file-upload/file-upload.less index 1c4b010853..1c4b010853 100644 --- a/catalog-ui/app/scripts/directives/file-upload/file-upload.less +++ b/catalog-ui/src/app/directives/file-upload/file-upload.less diff --git a/catalog-ui/src/app/directives/file-upload/file-upload.ts b/catalog-ui/src/app/directives/file-upload/file-upload.ts new file mode 100644 index 0000000000..63a6f08062 --- /dev/null +++ b/catalog-ui/src/app/directives/file-upload/file-upload.ts @@ -0,0 +1,130 @@ +/** + * Created by obarda on 1/27/2016. + */ +'use strict'; +import {IAppConfigurtaion} from "app/models"; + +export class FileUploadModel { + filetype:string; + filename:string; + filesize:number; + base64:string; +} + +export interface IFileUploadScope extends ng.IScope { + fileModel:FileUploadModel; + formElement:ng.IFormController; + extensions:string; + elementDisabled:string; + elementName:string; + elementRequired:string; + myFileModel:any; // From the ng bind to <input type=file + defaultText:string; + onFileChangedInDirective:Function; + + getExtensionsWithDot():string; + onFileChange():void + onFileClick(element:any):void; + onAfterValidate():void; + setEmptyError(element):void; + validateField(field:any):boolean; + cancel():void; +} + + +export class FileUploadDirective implements ng.IDirective { + + constructor(private sdcConfig:IAppConfigurtaion) { + } + + scope = { + fileModel: '=', + formElement: '=', + extensions: '@', + elementDisabled: '@', + elementName: '@', + elementRequired: '@', + onFileChangedInDirective: '=?', + defaultText: '=', + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./file-upload.html'); + }; + + link = (scope:IFileUploadScope, element:any, $attr:any) => { + + // In case the browse has filename, set it valid. + // When editing artifact the file is not sent again, so if we have filename I do not want to show error. + if (scope.fileModel && scope.fileModel.filename && scope.fileModel.filename !== '') { + scope.formElement[scope.elementName].$setValidity('required', true); + } + + scope.getExtensionsWithDot = ():string => { + let ret = []; + if (scope.extensions) { + _.each(scope.extensions.split(','), function (item) { + ret.push("." + item.toString()); + }); + } + return ret.join(","); + }; + + scope.onFileChange = ():void => { + if (scope.onFileChangedInDirective) { + scope.onFileChangedInDirective(); + } + if (scope.myFileModel) { + scope.fileModel = scope.myFileModel; + scope.formElement[scope.elementName].$setValidity('required', true); + } + }; + + scope.setEmptyError = (element):void => { + if (element.files[0].size) { + scope.formElement[scope.elementName].$setValidity('emptyFile', true); + } else { + scope.formElement[scope.elementName].$setValidity('emptyFile', false); + scope.fileModel = undefined; + } + + }; + + // Prevent case-sensitivity in the upload-file accept parameter + // Workaround for github issue: https://github.com/adonespitogo/angular-base64-upload/issues/81 + scope.onAfterValidate = () => { + if (!scope.formElement[scope.elementName].$valid && scope.extensions) { + let uploadfileExtension:string = scope.fileModel.filename.split('.').pop().toLowerCase(); + if (scope.extensions.split(',').indexOf(uploadfileExtension) > -1) { + scope.formElement[scope.elementName].$setValidity('accept', true); + } + } + // Adding fix for cases when we're changing file type for upload from file that requires certain + // extensions to a file that don't requires any extensions + if (!scope.formElement[scope.elementName].$valid && scope.formElement[scope.elementName].$error.accept && scope.extensions === "") { + scope.formElement[scope.elementName].$setValidity('accept', true); + } + }; + + // Workaround, in case user select a file then cancel (X) then select the file again, the event onChange is not fired. + // This is a workaround to fix this issue. + scope.onFileClick = (element:any):void => { + element.value = null; + }; + + scope.cancel = ():void => { + scope.fileModel.filename = ''; + scope.formElement[scope.elementName].$pristine; + scope.formElement[scope.elementName].$setValidity('required', false); + } + }; + + public static factory = (sdcConfig:IAppConfigurtaion)=> { + return new FileUploadDirective(sdcConfig); + }; + +} + +FileUploadDirective.factory.$inject = [ 'sdcConfig']; diff --git a/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.html b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.html new file mode 100644 index 0000000000..659ff7014f --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.html @@ -0,0 +1,11 @@ +<div class="assetPopover" ng-class="assetPopoverObj.menuSide" ng-style="{left: assetPopoverObj.menuPosition.x, top: assetPopoverObj.menuPosition.y}"> + <div class="display-name-tooltip" >{{assetPopoverObj.displayName}}</div> + + <div class="assetMenu"> + <!--<div class="sprite-new expand-asset-icon" uib-tooltip="Open" tooltip-class="uib-custom-tooltip" tooltip-placement="{{tooltipSide}}"></div>--> + <div class="sprite-new view-info-icon" uib-tooltip="Information" tooltip-class="uib-custom-tooltip" tooltip-placement="{{assetPopoverObj.menuSide}}"></div> + <div class="sprite-new cp-icon" uib-tooltip="Connection Points" tooltip-class="uib-custom-tooltip" tooltip-placement="{{assetPopoverObj.menuSide}}"></div> + <div class="sprite-new vl-icon" uib-tooltip="Links" tooltip-class="uib-custom-tooltip" tooltip-placement="{{assetPopoverObj.menuSide}}"></div> + <div class="sprite-new trash-icon" uib-tooltip="Delete" tooltip-class="uib-custom-tooltip" tooltip-placement="{{assetPopoverObj.menuSide}}" ng-click="deleteAsset()" data-ng-class="{'disabled-icon': assetPopoverObj.isViewOnly}"></div> + </div> +</div> diff --git a/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.less b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.less new file mode 100644 index 0000000000..44de4dfed1 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.less @@ -0,0 +1,64 @@ +.assetPopover { + font-family: omnes-regular,sans-serif; + font-size: 13px; + width:230px; + padding:0 15px; + position:absolute; + display:flex; + flex-direction:column; + align-items:flex-start; + + &.left { + align-items:flex-end; + + .uib-custom-tooltip { + margin-left:-10px; + } + } + + .display-name-tooltip { + + border:solid 1px @main_color_p; + color: @main_color_p; + padding:5px 10px; + width:200px; + margin-bottom:10px; + border-radius: 2px; + background-color: rgba(80, 99, 113, 0.8); + box-shadow: 0px 3px 7.44px 0.56px rgba(0, 0, 0, 0.33); + } + + .uib-custom-tooltip { + margin-left:20px; + font-family: omnes-regular,sans-serif; + font-size: 13px; + } + + .assetMenu { + + border-radius: 2px; + border: solid 1px @main_color_p; + background-color: rgba(234, 234, 234, 0.7); + box-shadow: 0px 3px 7.44px 0.56px rgba(0, 0, 0, 0.33); + display:flex; + flex-direction: column; + justify-content: center; + align-items:center; + + .sprite-new { + border-bottom:solid 1px #CCC; + &:hover:not(.disabled-icon) { + .hand; + } + &:active:not(.disabled-icon) { + background-color: @main_color_a; + border-bottom-color: @main_color_a; + } + &.trash-icon { + border-bottom: none; + } + } + + + } +} diff --git a/catalog-ui/app/scripts/filters/resource-name-filter.ts b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.ts index a1f6162a4c..c560161d6e 100644 --- a/catalog-ui/app/scripts/filters/resource-name-filter.ts +++ b/catalog-ui/src/app/directives/graphs-v2/asset-popover/asset-popover.ts @@ -17,29 +17,39 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Filters { - export class ResourceNameFilter{ +'use strict'; +import {AssetPopoverObj} from "app/models"; +export interface IAssetPopoverScope extends ng.IScope { + assetPopoverObj:AssetPopoverObj; + deleteAsset:Function; +} + +export class AssetPopoverDirective implements ng.IDirective { constructor() { - let filter = <ResourceNameFilter>( (name:string) => { - if(name){ - //let newName:string = _.last(name.split('.')); - let newName = - _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.')) - .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.')) - .split('nodes.module.')).split('cp.')).split('vl.')); - if (newName){ - return newName; - } - return name; - } - }); - - return filter; } - } + scope = { + assetPopoverObj: '=', + deleteAsset: '&' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('app/directives/graphs-v2/asset-popover/asset-popover.html'); + }; + + link = (scope:IAssetPopoverScope, element:JQuery, $attr:ng.IAttributes) => { + + }; + + public static factory = ()=> { + return new AssetPopoverDirective(); + }; } + +AssetPopoverDirective.factory.$inject = []; + diff --git a/catalog-ui/src/app/directives/graphs-v2/common/common-graph-utils.ts b/catalog-ui/src/app/directives/graphs-v2/common/common-graph-utils.ts new file mode 100644 index 0000000000..0b02173e9a --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/common/common-graph-utils.ts @@ -0,0 +1,372 @@ +import {CommonNodeBase, CompositionCiLinkBase, RelationshipModel, Relationship, CompositionCiNodeBase, NodesFactory, LinksFactory} from "app/models"; +import {GraphUIObjects} from "app/utils"; +/** + * Created by obarda on 12/21/2016. + */ +export class CommonGraphUtils { + + constructor(private NodesFactory:NodesFactory, private LinksFactory:LinksFactory) { + + } + + public safeApply = (scope:ng.IScope, fn:any) => { //todo remove to general utils + let phase = scope.$root.$$phase; + if (phase == '$apply' || phase == '$digest') { + if (fn && (typeof(fn) === 'function')) { + fn(); + } + } else { + scope.$apply(fn); + } + }; + + /** + * Draw node on the graph + * @param cy + * @param compositionGraphNode + * @param position + * @returns {CollectionElements} + */ + public addNodeToGraph(cy:Cy.Instance, compositionGraphNode:CommonNodeBase, position?:Cy.Position):Cy.CollectionElements { + + let node = cy.add(<Cy.ElementDefinition> { + group: 'nodes', + position: position, + data: compositionGraphNode, + classes: compositionGraphNode.classes + }); + + if(!node.data().isUcpe) { //ucpe should not have tooltip + this.initNodeTooltip(node); + } + return node; + }; + + /** + * The function will create a component instance node by the componentInstance position. + * If the node is UCPE the function will create all cp lan&wan for the ucpe + * @param cy + * @param compositionGraphNode + * @returns {Cy.CollectionElements} + */ + public addComponentInstanceNodeToGraph(cy:Cy.Instance, compositionGraphNode:CompositionCiNodeBase):Cy.CollectionElements { + + let nodePosition = { + x: +compositionGraphNode.componentInstance.posX, + y: +compositionGraphNode.componentInstance.posY + }; + + let node = this.addNodeToGraph(cy, compositionGraphNode, nodePosition); + if (compositionGraphNode.isUcpe) { + this.createUcpeCpNodes(cy, node); + } + return node; + }; + + /** + * This function will create CP_WAN & CP_LAN for the UCPE. this is a special node on the group that will behave like ports on the ucpe + * @param cy + * @param ucpeGraphNode + */ + private createUcpeCpNodes(cy:Cy.Instance, ucpeGraphNode:Cy.CollectionNodes):void { + + let requirementsArray:Array<any> = ucpeGraphNode.data().componentInstance.requirements["tosca.capabilities.Node"]; + //show only LAN or WAN requirements + requirementsArray = _.reject(requirementsArray, (requirement:any) => { + let name:string = requirement.ownerName.toLowerCase(); + return name.indexOf('lan') === -1 && name.indexOf('wan') === -1; + }); + requirementsArray.sort(function (a, b) { + let nameA = a.ownerName.toLowerCase().match(/[^ ]+/)[0]; + let nameB = b.ownerName.toLowerCase().match(/[^ ]+/)[0]; + let numA = _.last(a.ownerName.toLowerCase().split(' ')); + let numB = _.last(b.ownerName.toLowerCase().split(' ')); + + if (nameA === nameB) return numA > numB ? 1 : -1; + return nameA < nameB ? 1 : -1; + }); + let position = angular.copy(ucpeGraphNode.boundingbox()); + //add CP nodes to group + let topCps:number = 0; + for (let i = 0; i < requirementsArray.length; i++) { + + let cpNode = this.NodesFactory.createUcpeCpNode(angular.copy(ucpeGraphNode.data().componentInstance)); + cpNode.componentInstance.capabilities = requirementsArray[i]; + cpNode.id = requirementsArray[i].ownerId; + cpNode.group = ucpeGraphNode.data().componentInstance.uniqueId; + cpNode.name = requirementsArray[i].ownerName; //for tooltip + cpNode.displayName = requirementsArray[i].ownerName; + cpNode.displayName = cpNode.displayName.length > 5 ? cpNode.displayName.substring(0, 5) + '...' : cpNode.displayName; + + + if (cpNode.name.toLowerCase().indexOf('lan') > -1) { + cpNode.textPosition = "top"; + cpNode.componentInstance.posX = position.x1 + (i * 90) - (topCps * 90) + 53; + cpNode.componentInstance.posY = position.y1 + 400 + 27; + } else { + cpNode.textPosition = "bottom"; + cpNode.componentInstance.posX = position.x1 + (topCps * 90) + 53; + cpNode.componentInstance.posY = position.y1 + 27; + topCps++; + } + let cyCpNode = this.addComponentInstanceNodeToGraph(cy, cpNode); + cyCpNode.lock(); + } + }; + + /** + * + * @param nodes - all nodes in graph in order to find the edge connecting the two nodes + * @param fromNodeId + * @param toNodeId + * @returns {boolean} true/false if the edge is certified (from node and to node are certified) + */ + public isRelationCertified(nodes:Cy.CollectionNodes, fromNodeId:string, toNodeId:string):boolean { + let resourceTemp = _.filter(nodes, function (node:Cy.CollectionFirst) { + return node.data().id === fromNodeId || node.data().id === toNodeId; + }); + let certified:boolean = true; + + _.forEach(resourceTemp, (item) => { + certified = certified && item.data().certified; + }); + + return certified; + } + + /** + * Add link to graph - only draw the link + * @param cy + * @param link + */ + public insertLinkToGraph = (cy:Cy.Instance, link:CompositionCiLinkBase) => { + + if (!this.isRelationCertified(cy.nodes(), link.source, link.target)) { + link.classes = 'not-certified-link'; + } + cy.add({ + group: 'edges', + data: link, + classes: link.classes + }); + + }; + + /** + * go over the relations and draw links on the graph + * @param cy + * @param instancesRelations + */ + public initGraphLinks(cy:Cy.Instance, instancesRelations:Array<RelationshipModel>) { + + if (instancesRelations) { + _.forEach(instancesRelations, (relationshipModel:RelationshipModel) => { + _.forEach(relationshipModel.relationships, (relationship:Relationship) => { + let linkToCreate = this.LinksFactory.createGraphLink(cy, relationshipModel, relationship); + this.insertLinkToGraph(cy, linkToCreate); + }); + }); + } + } + + /** + * Determine which nodes are in the UCPE and set child data for them. + * @param cy + */ + public initUcpeChildren(cy:Cy.Instance) { + let ucpe:Cy.CollectionNodes = cy.nodes('[?isUcpe]'); // Get ucpe on graph if exist + _.each(cy.edges('.ucpe-host-link'), (link)=> { + + let ucpeChild:Cy.CollectionNodes = (link.source().id() == ucpe.id()) ? link.target() : link.source(); + this.initUcpeChildData(ucpeChild, ucpe); + + //vls dont have ucpe-host-link connection, so need to find them and iterate separately + let connectedVLs = ucpeChild.connectedEdges().connectedNodes('.vl-node'); + _.forEach(connectedVLs, (vl)=> { //all connected vls must be UCPE children because not allowed to connect to a VL outside of the UCPE + this.initUcpeChildData(vl, ucpe); + }); + }); + } + + /** + * Set properties for nodes contained by the UCPE + * @param childNode- node contained in UCPE + * @param ucpe- ucpe container node + */ + public initUcpeChildData(childNode:Cy.CollectionNodes, ucpe:Cy.CollectionNodes) { + + if (!childNode.data('isInsideGroup')) { + this.updateUcpeChildPosition(childNode, ucpe); + childNode.data({isInsideGroup: true}); + } + + } + + /** + * Updates UCPE child node offset, which allows child nodes to be dragged in synchronization with ucpe + * @param childNode- node contained in UCPE + * @param ucpe- ucpe container node + */ + public updateUcpeChildPosition(childNode:Cy.CollectionNodes, ucpe:Cy.CollectionNodes) { + let childPos:Cy.Position = childNode.relativePosition(); + let ucpePos:Cy.Position = ucpe.relativePosition(); + let offset:Cy.Position = { + x: childPos.x - ucpePos.x, + y: childPos.y - ucpePos.y + }; + childNode.data("ucpeOffset", offset); + } + + /** + * Removes ucpe-child properties from the node + * @param childNode- node being removed from UCPE + */ + public removeUcpeChildData(childNode:Cy.CollectionNodes) { + childNode.removeData("ucpeOffset"); + childNode.data({isInsideGroup: false}); + + } + + + public HTMLCoordsToCytoscapeCoords(cytoscapeBoundingBox:Cy.Extent, mousePos:Cy.Position):Cy.Position { + return {x: mousePos.x + cytoscapeBoundingBox.x1, y: mousePos.y + cytoscapeBoundingBox.y1} + }; + + + public getCytoscapeNodePosition = (cy:Cy.Instance, event:IDragDropEvent):Cy.Position => { + let targetOffset = $(event.target).offset(); + let x = event.pageX - targetOffset.left; + let y = event.pageY - targetOffset.top; + + return this.HTMLCoordsToCytoscapeCoords(cy.extent(), { + x: x, + y: y + }); + }; + + + public getNodePosition(node:Cy.CollectionFirstNode):Cy.Position { + let nodePosition = node.relativePoint(); + if (node.data().isUcpe) { //UCPEs use bounding box and not relative point. + nodePosition = {x: node.boundingbox().x1, y: node.boundingbox().y1}; + } + + return nodePosition; + } + + /** + * Generic function that can be used for any html elements overlaid on canvas + * Returns the html position of a node on canvas, including left palette and header offsets. Option to pass in additional offset to add to return position. + * @param node + * @param additionalOffset + * @returns {Cy.Position} + + public getNodePositionWithOffset = (node:Cy.CollectionFirstNode, additionalOffset?:Cy.Position): Cy.Position => { + if(!additionalOffset) additionalOffset = {x: 0, y:0}; + + let nodePosition = node.renderedPosition(); + let posWithOffset:Cy.Position = { + x: nodePosition.x + GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET + additionalOffset.x, + y: nodePosition.y + GraphUIObjects.COMPOSITION_HEADER_OFFSET + additionalOffset.y + }; + return posWithOffset; + };*/ + + /** + * return true/false if first node contains in second - this used in order to verify is node is entirely inside ucpe + * @param firstBox + * @param secondBox + * @returns {boolean} + */ + public isFirstBoxContainsInSecondBox(firstBox:Cy.BoundingBox, secondBox:Cy.BoundingBox) { + + return firstBox.x1 > secondBox.x1 && firstBox.x2 < secondBox.x2 && firstBox.y1 > secondBox.y1 && firstBox.y2 < secondBox.y2; + + }; + + + /** + * Check if node node bounds position is inside any ucpe on graph, and return the ucpe + * @param {diagram} the diagram. + * @param {nodeActualBounds} the actual bound position of the node. + * @return the ucpe if found else return null + */ + public isInUcpe = (cy:Cy.Instance, nodeBounds:Cy.BoundingBox):Cy.CollectionElements => { + + let ucpeNodes = cy.nodes('[?isUcpe]').filterFn((ucpeNode) => { + return this.isFirstBoxContainsInSecondBox(nodeBounds, ucpeNode.boundingbox()); + }); + return ucpeNodes; + }; + + /** + * + * @param cy + * @param node + * @returns {Array} + */ + public getLinkableNodes(cy:Cy.Instance, node:Cy.CollectionFirstNode):Array<CompositionCiNodeBase> { + let compatibleNodes = []; + _.each(cy.nodes(), (tempNode)=> { + if (this.nodeLocationsCompatible(cy, node, tempNode)) { + compatibleNodes.push(tempNode.data()); + } + }); + return compatibleNodes; + } + + /** + * Checks whether node locations are compatible in reference to UCPEs. + * Returns true if both nodes are in UCPE or both nodes out, or one node is UCPEpart. + * @param node1 + * @param node2 + */ + public nodeLocationsCompatible(cy:Cy.Instance, node1:Cy.CollectionFirstNode, node2:Cy.CollectionFirstNode) { + + let ucpe = cy.nodes('[?isUcpe]'); + if(!ucpe.length){ return true; } + if(node1.data().isUcpePart || node2.data().isUcpePart) { return true; } + + return (this.isFirstBoxContainsInSecondBox(node1.boundingbox(), ucpe.boundingbox()) == this.isFirstBoxContainsInSecondBox(node2.boundingbox(), ucpe.boundingbox())); + + } + + /** + * This function will init qtip tooltip on the node + * @param node - the node we want the tooltip to apply on + */ + public initNodeTooltip(node:Cy.CollectionNodes) { + + let opts = { + content: function () { + return this.data('name'); + }, + position: { + my: 'top center', + at: 'bottom center', + adjust: {x:0, y:-5} + }, + style: { + classes: 'qtip-dark qtip-rounded qtip-custom', + tip: { + width: 16, + height: 8 + } + }, + show: { + event: 'mouseover', + delay: 1000 + }, + hide: {event: 'mouseout mousedown'}, + includeLabels: true + }; + + if (node.data().isUcpePart){ //fix tooltip positioning for UCPE-cps + opts.position.adjust = {x:0, y:20}; + } + + node.qtip(opts); + }; +} + +CommonGraphUtils.$inject = ['NodesFactory', 'LinksFactory'];
\ No newline at end of file diff --git a/catalog-ui/app/scripts/directives/graphs-v2/common/style/component-instances-nodes-style.ts b/catalog-ui/src/app/directives/graphs-v2/common/style/component-instances-nodes-style.ts index 2ec0174aa9..971dabafe8 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/common/style/component-instances-nodes-style.ts +++ b/catalog-ui/src/app/directives/graphs-v2/common/style/component-instances-nodes-style.ts @@ -1,13 +1,10 @@ +import {GraphColors} from "app/utils/constants"; /** * Created by obarda on 12/18/2016. */ -/** - * Created by obarda on 12/13/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils.ComponentIntanceNodesStyle { +export class ComponentInstanceNodesStyle { - export function getCompositionGraphStyle():Array<Cy.Stylesheet> { + public static getCompositionGraphStyle = ():Array<Cy.Stylesheet> => { return [ { selector: 'core', @@ -29,7 +26,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'events': 'yes', 'text-events': 'yes', 'text-border-width': 15, - 'text-border-color': Sdc.Utils.Constants.GraphColors.NODE_UCPE, + 'text-border-color': GraphColors.NODE_UCPE, 'text-margin-y': 5 } }, @@ -49,7 +46,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'text-halign': 'center', 'background-fit': 'cover', 'background-clip': 'node', - 'overlay-color': Sdc.Utils.Constants.GraphColors.NODE_BACKGROUND_COLOR, + 'overlay-color': GraphColors.NODE_BACKGROUND_COLOR, 'overlay-opacity': 0 } }, @@ -68,7 +65,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'text-valign': 'bottom', 'text-halign': 'center', 'background-opacity': 0, - 'overlay-color': Sdc.Utils.Constants.GraphColors.NODE_BACKGROUND_COLOR, + 'overlay-color': GraphColors.NODE_BACKGROUND_COLOR, 'overlay-opacity': 0 } }, @@ -86,7 +83,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'text-valign': 'bottom', 'text-halign': 'center', 'background-opacity': 0, - 'overlay-color': Sdc.Utils.Constants.GraphColors.NODE_BACKGROUND_COLOR, + 'overlay-color': GraphColors.NODE_BACKGROUND_COLOR, 'overlay-opacity': 0 } }, @@ -104,14 +101,14 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'text-valign': 'bottom', 'text-halign': 'center', 'background-opacity': 0, - 'overlay-color': Sdc.Utils.Constants.GraphColors.NODE_BACKGROUND_COLOR, + 'overlay-color': GraphColors.NODE_BACKGROUND_COLOR, 'overlay-opacity': 0 } }, { selector: '.ucpe-cp', css: { - 'background-color': Sdc.Utils.Constants.GraphColors.NODE_UCPE_CP, + 'background-color': GraphColors.NODE_UCPE_CP, 'background-width': 15, 'background-height': 15, 'width': 15, @@ -121,7 +118,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { 'label': 'data(displayName)', 'text-valign': 'data(textPosition)', 'text-margin-y': (ele:Cy.Collection) => { - return (ele.data('textPosition') == 'top')? -5 : 5; + return (ele.data('textPosition') == 'top') ? -5 : 5; }, 'font-size': 12 } @@ -138,7 +135,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { selector: '.simple-link', css: { 'width': 1, - 'line-color': Sdc.Utils.Constants.GraphColors.BASE_LINK, + 'line-color': GraphColors.BASE_LINK, 'target-arrow-color': '#3b7b9b', 'target-arrow-shape': 'triangle', 'curve-style': 'bezier', @@ -149,7 +146,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { selector: '.vl-link', css: { 'width': 3, - 'line-color': Sdc.Utils.Constants.GraphColors.VL_LINK, + 'line-color': GraphColors.VL_LINK, 'curve-style': 'bezier', 'control-point-step-size': 30 } @@ -164,7 +161,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { selector: '.not-certified-link', css: { 'width': 1, - 'line-color': Sdc.Utils.Constants.GraphColors.NOT_CERTIFIED_LINK, + 'line-color': GraphColors.NOT_CERTIFIED_LINK, 'curve-style': 'bezier', 'control-point-step-size': 30, 'line-style': 'dashed', @@ -182,20 +179,20 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { return ele.data().initImage(ele) }, "border-width": 0 - } + } }, { selector: 'node:selected', css: { "border-width": 2, - "border-color": Sdc.Utils.Constants.GraphColors.NODE_SELECTED_BORDER_COLOR, + "border-color": GraphColors.NODE_SELECTED_BORDER_COLOR, 'shape': 'rectangle' } }, { selector: 'edge:selected', css: { - 'line-color': Sdc.Utils.Constants.GraphColors.ACTIVE_LINK + 'line-color': GraphColors.ACTIVE_LINK } }, @@ -208,7 +205,7 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { ] } - export function getBasicNodeHanlde() { + public static getBasicNodeHanlde = () => { return { positionX: "center", positionY: "top", @@ -218,14 +215,14 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { type: "default", single: false, nodeTypeNames: ["basic-node"], - imageUrl: Sdc.Utils.Constants.IMAGE_PATH + '/styles/images/resource-icons/' + 'canvasPlusIcon.png', + imageUrl: '/assets/styles/images/resource-icons/' + 'canvasPlusIcon.png', lineWidth: 2, lineStyle: 'dashed' } } - export function getBasicSmallNodeHandle() { + public static getBasicSmallNodeHandle = () => { return { positionX: "center", positionY: "top", @@ -235,13 +232,13 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { type: "default", single: false, nodeTypeNames: ["basic-small-node"], - imageUrl: Sdc.Utils.Constants.IMAGE_PATH + '/styles/images/resource-icons/' + 'canvasPlusIcon.png', + imageUrl: '/assets/styles/images/resource-icons/' + 'canvasPlusIcon.png', lineWidth: 2, lineStyle: 'dashed' } } - export function getUcpeCpNodeHandle() { + public static getUcpeCpNodeHandle = () => { return { positionX: "center", positionY: "center", @@ -251,9 +248,9 @@ module Sdc.Graph.Utils.ComponentIntanceNodesStyle { type: "default", single: false, nodeTypeNames: ["ucpe-cp-node"], - imageUrl: Sdc.Utils.Constants.IMAGE_PATH + '/styles/images/resource-icons/' + 'canvasPlusIcon.png', + imageUrl: '/assets/styles/images/resource-icons/' + 'canvasPlusIcon.png', lineWidth: 2, lineStyle: 'dashed' } } -}
\ No newline at end of file +} diff --git a/catalog-ui/app/scripts/directives/graphs-v2/common/style/module-node-style.ts b/catalog-ui/src/app/directives/graphs-v2/common/style/module-node-style.ts index 62436fbf74..0c92c90538 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/common/style/module-node-style.ts +++ b/catalog-ui/src/app/directives/graphs-v2/common/style/module-node-style.ts @@ -1,16 +1,7 @@ -/** - * Created by obarda on 1/1/2017. - */ -/** - * Created by obarda on 12/18/2016. - */ -/** - * Created by obarda on 12/13/2016. - */ -/// <reference path="../../../../references"/> -module Sdc.Graph.Utils.ModulesNodesStyle { +import {GraphColors} from "app/utils"; +export class ModulesNodesStyle { - export function getModuleGraphStyle():Array<Cy.Stylesheet> { + public static getModuleGraphStyle = ():Array<Cy.Stylesheet> => { return [ { @@ -36,7 +27,7 @@ module Sdc.Graph.Utils.ModulesNodesStyle { 'background-color': 'transparent', 'background-opacity': 0, "border-width": 2, - "border-color": Sdc.Utils.Constants.GraphColors.NODE_SELECTED_BORDER_COLOR, + "border-color": GraphColors.NODE_SELECTED_BORDER_COLOR, 'border-style': 'dashed', 'label': 'data(displayName)', 'events': 'yes', @@ -55,19 +46,19 @@ module Sdc.Graph.Utils.ModulesNodesStyle { { selector: '.simple-link:selected', css: { - 'line-color': Sdc.Utils.Constants.GraphColors.BASE_LINK, + 'line-color': GraphColors.BASE_LINK, } }, { selector: '.vl-link:selected', css: { - 'line-color': Sdc.Utils.Constants.GraphColors.VL_LINK, + 'line-color': GraphColors.VL_LINK, } }, { selector: '.cy-expand-collapse-collapsed-node:selected', css: { - "border-color": Sdc.Utils.Constants.GraphColors.NODE_SELECTED_BORDER_COLOR, + "border-color": GraphColors.NODE_SELECTED_BORDER_COLOR, 'border-opacity': 1, 'border-style': 'solid', 'border-width': 2 @@ -76,7 +67,7 @@ module Sdc.Graph.Utils.ModulesNodesStyle { { selector: '.module-node:selected', css: { - "border-color": Sdc.Utils.Constants.GraphColors.NODE_SELECTED_BORDER_COLOR, + "border-color": GraphColors.NODE_SELECTED_BORDER_COLOR, 'border-opacity': 1 } }, @@ -89,4 +80,4 @@ module Sdc.Graph.Utils.ModulesNodesStyle { }, ] } -}
\ No newline at end of file +} diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts new file mode 100644 index 0000000000..db03aa53fb --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.directive.ts @@ -0,0 +1,539 @@ +import { + MatchBase, + LinkMenu, + ComponentInstance, + LeftPaletteComponent, + Component, + RelationMenuDirectiveObj, + CompositionCiNodeBase, + CompositionCiNodeVl, + NodesFactory/*, + AssetPopoverObj*/ +} from "app/models"; +import {ComponentInstanceFactory, ComponentFactory, GRAPH_EVENTS, GraphColors} from "app/utils"; +import {EventListenerService, LoaderService} from "app/services"; +import {CompositionGraphLinkUtils} from "./utils/composition-graph-links-utils"; +import {CompositionGraphGeneralUtils} from "./utils/composition-graph-general-utils"; +import {CompositionGraphNodesUtils} from "./utils/composition-graph-nodes-utils"; +import {CommonGraphUtils} from "../common/common-graph-utils"; +import {MatchCapabilitiesRequirementsUtils} from "./utils/match-capability-requierment-utils"; +import {CompositionGraphPaletteUtils} from "./utils/composition-graph-palette-utils"; +import {ComponentInstanceNodesStyle} from "../common/style/component-instances-nodes-style"; +import {CytoscapeEdgeEditation} from 'third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js'; +import {ComponentServiceNg2} from "../../../ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "../../../ng2/services/responses/component-generic-response"; + +interface ICompositionGraphScope extends ng.IScope { + + component:Component; + isLoading: boolean; + isViewOnly:boolean; + // Link menu - create link menu + relationMenuDirectiveObj:RelationMenuDirectiveObj; + isLinkMenuOpen:boolean; + createLinkFromMenu:(chosenMatch:MatchBase, vl:Component)=>void; + + //modify link menu - for now only delete menu + relationMenuTimeout:ng.IPromise<any>; + linkMenuObject:LinkMenu; + + //left palette functions callbacks + dropCallback(event:JQueryEventObject, ui:any):void; + beforeDropCallback(event:IDragDropEvent):void; + verifyDrop(event:JQueryEventObject, ui:any):void; + + //Links menus + deleteRelation(link:Cy.CollectionEdges):void; + hideRelationMenu(); + /*//asset popover menu + assetPopoverObj:AssetPopoverObj; + assetPopoverOpen:boolean; + hideAssetPopover():void; + deleteNode(nodeId:string):void;*/ +} + +export class CompositionGraph implements ng.IDirective { + private _cy:Cy.Instance; + private _currentlyCLickedNodePosition:Cy.Position; + // private $document:JQuery = $(document); + private dragElement:JQuery; + private dragComponent:ComponentInstance; + + constructor(private $q:ng.IQService, + private $log:ng.ILogService, + private $timeout:ng.ITimeoutService, + private NodesFactory:NodesFactory, + private CompositionGraphLinkUtils:CompositionGraphLinkUtils, + private GeneralGraphUtils:CompositionGraphGeneralUtils, + private ComponentInstanceFactory:ComponentInstanceFactory, + private NodesGraphUtils:CompositionGraphNodesUtils, + private eventListenerService:EventListenerService, + private ComponentFactory:ComponentFactory, + private LoaderService:LoaderService, + private commonGraphUtils:CommonGraphUtils, + private matchCapabilitiesRequirementsUtils:MatchCapabilitiesRequirementsUtils, + private CompositionGraphPaletteUtils:CompositionGraphPaletteUtils, + private ComponentServiceNg2: ComponentServiceNg2) { + + } + + restrict = 'E'; + template = require('./composition-graph.html'); + scope = { + component: '=', + isViewOnly: '=' + }; + + link = (scope:ICompositionGraphScope, el:JQuery) => { + + this.loadGraph(scope, el); + + if(scope.component.componentInstances && scope.component.componentInstancesRelations) { + this.loadGraphData(scope); + } else { + //when we don't have the data we register to on graph load event + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_COMPOSITION_GRAPH_DATA_LOADED, () => { + this.loadGraphData(scope); + }); + } + scope.$on('$destroy', () => { + this._cy.destroy(); + _.forEach(GRAPH_EVENTS, (event) => { + this.eventListenerService.unRegisterObserver(event); + }); + }); + + }; + + private loadGraphData = (scope:ICompositionGraphScope) => { + this.initGraphNodes(scope.component.componentInstances, scope.isViewOnly); + this.commonGraphUtils.initGraphLinks(this._cy, scope.component.componentInstancesRelations); + this.commonGraphUtils.initUcpeChildren(this._cy); + } + + private loadGraph = (scope:ICompositionGraphScope, el:JQuery) => { + + let graphEl = el.find('.sdc-composition-graph-wrapper'); + this.initGraph(graphEl, scope.isViewOnly); + this.initDropZone(scope); + this.registerCytoscapeGraphEvents(scope); + this.registerCustomEvents(scope, el); + this.initViewMode(scope.isViewOnly); + + }; + + private initGraph(graphEl:JQuery, isViewOnly:boolean) { + + this._cy = cytoscape({ + container: graphEl, + style: ComponentInstanceNodesStyle.getCompositionGraphStyle(), + zoomingEnabled: false, + selectionType: 'single', + boxSelectionEnabled: true, + autolock: isViewOnly, + autoungrabify: isViewOnly + }); + } + + private initViewMode(isViewOnly:boolean) { + + if (isViewOnly) { + //remove event listeners + this._cy.off('drag'); + this._cy.off('handlemouseout'); + this._cy.off('handlemouseover'); + this._cy.edges().unselectify(); + } + }; + + private registerCustomEvents(scope:ICompositionGraphScope, el:JQuery) { + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, (leftPaletteComponent:LeftPaletteComponent) => { + this.$log.info(`composition-graph::registerEventServiceEvents:: palette hover on component: ${leftPaletteComponent.uniqueId}`); + + let nodesData = this.NodesGraphUtils.getAllNodesData(this._cy.nodes()); + let nodesLinks = this.GeneralGraphUtils.getAllCompositionCiLinks(this._cy); + + if (this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.containsKey(leftPaletteComponent.uniqueId)) { + let cacheComponent = this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.getValue(leftPaletteComponent.uniqueId); + let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(cacheComponent, nodesData, nodesLinks); + + this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy); + this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy); + + return; + } + + //----------------------- ORIT TO FIX------------------------// + + this.ComponentServiceNg2.getCapabilitiesAndRequirements(leftPaletteComponent.componentType, leftPaletteComponent.uniqueId).subscribe((response: ComponentGenericResponse) => { + + let component = this.ComponentFactory.createEmptyComponent(leftPaletteComponent.componentType); + component.uniqueId = component.uniqueId; + component.capabilities = response.capabilities; + component.requirements = response.requirements; + this.GeneralGraphUtils.componentRequirementsAndCapabilitiesCaching.setValue(leftPaletteComponent.uniqueId, component); + let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(component, nodesData, nodesLinks); + this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy); + this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy) + }); + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT, () => { + this._cy.emit('hidehandles'); + this.matchCapabilitiesRequirementsUtils.resetFadedNodes(this._cy); + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_START, (dragElement, dragComponent) => { + + this.dragElement = dragElement; + this.dragComponent = this.ComponentInstanceFactory.createComponentInstanceFromComponent(dragComponent); + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_ACTION, (event:IDragDropEvent) => { + this.CompositionGraphPaletteUtils.onComponentDrag(this._cy, event, this.dragElement, this.dragComponent); + + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_COMPONENT_INSTANCE_NAME_CHANGED, (component:ComponentInstance) => { + + let selectedNode = this._cy.getElementById(component.uniqueId); + selectedNode.data().componentInstance.name = component.name; + selectedNode.data('name', component.name); //used for tooltip + selectedNode.data('displayName', selectedNode.data().getDisplayName()); //abbreviated + + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, (componentInstance:ComponentInstance) => { + let nodeToDelete = this._cy.getElementById(componentInstance.uniqueId); + this.NodesGraphUtils.deleteNode(this._cy, scope.component, nodeToDelete); + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_MULTIPLE_COMPONENTS, () => { + + this._cy.$('node:selected').each((i:number, node:Cy.CollectionNodes) => { + this.NodesGraphUtils.deleteNode(this._cy, scope.component, node); + }); + + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_EDGE, (releaseLoading:boolean, linksToDelete:Cy.CollectionEdges) => { + this.CompositionGraphLinkUtils.deleteLink(this._cy, scope.component, releaseLoading, linksToDelete); + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, (node:Cy.CollectionNodes, ucpe:Cy.CollectionNodes, updateExistingNode:boolean) => { + + this.commonGraphUtils.initUcpeChildData(node, ucpe); + //check if item is a VL, and if so, skip adding the binding to ucpe + if (!(node.data() instanceof CompositionCiNodeVl)) { + this.CompositionGraphLinkUtils.createVfToUcpeLink(scope.component, this._cy, ucpe.data(), node.data()); //create link from the node to the ucpe + } + + if (updateExistingNode) { + let vlsPendingDeletion:Cy.CollectionNodes = this.NodesGraphUtils.deleteNodeVLsUponMoveToOrFromUCPE(scope.component, node.cy(), node); //delete connected VLs that no longer have 2 links + this.CompositionGraphLinkUtils.deleteLinksWhenNodeMovedFromOrToUCPE(scope.component, node.cy(), node, vlsPendingDeletion); //delete all connected links if needed + this.GeneralGraphUtils.pushUpdateComponentInstanceActionToQueue(scope.component, true, node.data().componentInstance); //update componentInstance position + } + + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, (node:Cy.CollectionNodes, ucpe:Cy.CollectionNodes) => { + this.commonGraphUtils.removeUcpeChildData(node); + let vlsPendingDeletion:Cy.CollectionNodes = this.NodesGraphUtils.deleteNodeVLsUponMoveToOrFromUCPE(scope.component, node.cy(), node); + this.CompositionGraphLinkUtils.deleteLinksWhenNodeMovedFromOrToUCPE(scope.component, node.cy(), node, vlsPendingDeletion); //delete all connected links if needed + this.GeneralGraphUtils.pushUpdateComponentInstanceActionToQueue(scope.component, true, node.data().componentInstance); //update componentInstance position + }); + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_VERSION_CHANGED, (component:Component) => { + scope.component = component; + this.loadGraphData(scope); + }); + + + scope.createLinkFromMenu = (chosenMatch:MatchBase):void => { + scope.isLinkMenuOpen = false; + this.CompositionGraphLinkUtils.createLinkFromMenu(this._cy, chosenMatch, scope.component); + }; + + scope.hideRelationMenu = () => { + this.commonGraphUtils.safeApply(scope, () => { + scope.linkMenuObject = null; + this.$timeout.cancel(scope.relationMenuTimeout); + }); + }; + + + scope.deleteRelation = (link:Cy.CollectionEdges) => { + scope.hideRelationMenu(); + + //if multiple edges selected, delete the VL itself so edges get deleted automatically + if (this._cy.$('edge:selected').length > 1) { + this.NodesGraphUtils.deleteNode(this._cy, scope.component, this._cy.$('node:selected')); + } else { + this.CompositionGraphLinkUtils.deleteLink(this._cy, scope.component, true, link); + } + }; + + /* + scope.hideAssetPopover = ():void => { + + this.commonGraphUtils.safeApply(scope, () => { + scope.assetPopoverOpen = false; + scope.assetPopoverObj = null; + }); + }; + + scope.deleteNode = (nodeId:string):void => { + if (!scope.isViewOnly) { + this.NodesGraphUtils.confirmDeleteNode(nodeId, this._cy, scope.component); + //scope.hideAssetPopover(); + } + };*/ + } + + private registerCytoscapeGraphEvents(scope:ICompositionGraphScope) { + + this._cy.on('addedgemouseup', (event, data) => { + scope.relationMenuDirectiveObj = this.CompositionGraphLinkUtils.onLinkDrawn(this._cy, data.source, data.target); + if (scope.relationMenuDirectiveObj != null) { + scope.$apply(() => { + scope.isLinkMenuOpen = true; + }); + } + }); + this._cy.on('tapstart', 'node', (event:Cy.EventObject) => { + this._currentlyCLickedNodePosition = angular.copy(event.cyTarget[0].position()); //update node position on drag + if (event.cyTarget.data().isUcpe) { + this._cy.nodes('.ucpe-cp').unlock(); + event.cyTarget.style('opacity', 0.5); + } + //scope.hideAssetPopover(); + }); + + this._cy.on('drag', 'node', (event:Cy.EventObject) => { + + if (event.cyTarget.data().isDraggable) { + event.cyTarget.style({'overlay-opacity': 0.24}); + if (this.GeneralGraphUtils.isValidDrop(this._cy, event.cyTarget)) { + event.cyTarget.style({'overlay-color': GraphColors.NODE_BACKGROUND_COLOR}); + } else { + event.cyTarget.style({'overlay-color': GraphColors.NODE_OVERLAPPING_BACKGROUND_COLOR}); + } + } + + if (event.cyTarget.data().isUcpe) { + let pos = event.cyTarget.position(); + + this._cy.nodes('[?isInsideGroup]').positions((i, node)=> { + return { + x: pos.x + node.data("ucpeOffset").x, + y: pos.y + node.data("ucpeOffset").y + } + }); + } + }); + + /* this._cy.on('mouseover', 'node', (event:Cy.EventObject) => { + if (!this._cy.scratch('_edge_editation_highlights')) { + this.commonGraphUtils.safeApply(scope, () => { + this.showNodePopoverMenu(scope, event.cyTarget[0]); + }); + } + }); + + this._cy.on('mouseout', 'node', (event:Cy.EventObject) => { + scope.hideAssetPopover(); + });*/ + this._cy.on('handlemouseover', (event, payload) => { + + if (payload.node.grabbed() /* || this._cy.scratch('_edge_editation_highlights') === true*/) { //no need to add opacity while we are dragging and hovering othe nodes- or if opacity was already calculated for these nodes + return; + } + let nodesData = this.NodesGraphUtils.getAllNodesData(this._cy.nodes()); + let nodesLinks = this.GeneralGraphUtils.getAllCompositionCiLinks(this._cy); + + let linkableNodes = this.commonGraphUtils.getLinkableNodes(this._cy, payload.node); + let filteredNodesData = this.matchCapabilitiesRequirementsUtils.findByMatchingCapabilitiesToRequirements(payload.node.data().componentInstance, linkableNodes, nodesLinks); + this.matchCapabilitiesRequirementsUtils.highlightMatchingComponents(filteredNodesData, this._cy); + this.matchCapabilitiesRequirementsUtils.fadeNonMachingComponents(filteredNodesData, nodesData, this._cy, payload.node.data()); + /* + this._cy.scratch()._edge_editation_highlights = true; + scope.hideAssetPopover();*/ + }); + + this._cy.on('handlemouseout', () => { + if (this._cy.scratch('_edge_editation_highlights') === true) { + this._cy.removeScratch('_edge_editation_highlights'); + this._cy.emit('hidehandles'); + this.matchCapabilitiesRequirementsUtils.resetFadedNodes(this._cy); + } + }); + + + this._cy.on('tapend', (event:Cy.EventObject) => { + + if (event.cyTarget === this._cy) { //On Background clicked + if (this._cy.$('node:selected').length === 0) { //if the background click but not dragged + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED); + } + scope.hideRelationMenu(); + } + + else if (event.cyTarget.isEdge()) { //On Edge clicked + if (scope.isViewOnly) return; + this.CompositionGraphLinkUtils.handleLinkClick(this._cy, event); + this.openModifyLinkMenu(scope, this.CompositionGraphLinkUtils.getModifyLinkMenu(event.cyTarget[0], event), 6000); + } + + else { //On Node clicked + this._cy.nodes(':grabbed').style({'overlay-opacity': 0}); + + let isUcpe:boolean = event.cyTarget.data().isUcpe; + let newPosition = event.cyTarget[0].position(); + //node position changed (drop after drag event) - we need to update position + if (this._currentlyCLickedNodePosition.x !== newPosition.x || this._currentlyCLickedNodePosition.y !== newPosition.y) { + let nodesMoved:Cy.CollectionNodes = this._cy.$(':grabbed'); + if (isUcpe) { + nodesMoved = nodesMoved.add(this._cy.nodes('[?isInsideGroup]:free')); //'child' nodes will not be recognized as "grabbed" elements within cytoscape. manually add them to collection of nodes moved. + } + this.NodesGraphUtils.onNodesPositionChanged(this._cy, scope.component, nodesMoved); + } else { + this.$log.debug('composition-graph::onNodeSelectedEvent:: fired'); + scope.$apply(() => { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_NODE_SELECTED, event.cyTarget.data().componentInstance); + //open node popover menu + //this.showNodePopoverMenu(scope, event.cyTarget[0]); + }); + } + + if (isUcpe) { + this._cy.nodes('.ucpe-cp').lock(); + event.cyTarget.style('opacity', 1); + } + + } + }); + + this._cy.on('boxselect', 'node', (event:Cy.EventObject) => { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_NODE_SELECTED, event.cyTarget.data().componentInstance); + }); + } + + /* + private showNodePopoverMenu = (scope:ICompositionGraphScope, node:Cy.CollectionNodes) => { + + scope.assetPopoverObj = this.NodesGraphUtils.createAssetPopover(this._cy, node, scope.isViewOnly); + scope.assetPopoverOpen = true; + + };*/ + private openModifyLinkMenu = (scope:ICompositionGraphScope, linkMenuObject:LinkMenu, timeOutInMilliseconds?:number) => { + + this.commonGraphUtils.safeApply(scope, () => { + scope.linkMenuObject = linkMenuObject; + }); + + scope.relationMenuTimeout = this.$timeout(() => { + scope.hideRelationMenu(); + }, timeOutInMilliseconds ? timeOutInMilliseconds : 6000); + }; + + private initGraphNodes(componentInstances:ComponentInstance[], isViewOnly:boolean) { + + if (!isViewOnly) { //Init nodes handle extension - enable dynamic links + setTimeout(()=> { + let handles = new CytoscapeEdgeEditation; + handles.init(this._cy, 18); + handles.registerHandle(ComponentInstanceNodesStyle.getBasicNodeHanlde()); + handles.registerHandle(ComponentInstanceNodesStyle.getBasicSmallNodeHandle()); + handles.registerHandle(ComponentInstanceNodesStyle.getUcpeCpNodeHandle()); + }, 0); + } + + _.each(componentInstances, (instance) => { + let compositionGraphNode:CompositionCiNodeBase = this.NodesFactory.createNode(instance); + this.commonGraphUtils.addComponentInstanceNodeToGraph(this._cy, compositionGraphNode); + }); + } + + + private initDropZone(scope:ICompositionGraphScope) { + + if (scope.isViewOnly) { + return; + } + scope.dropCallback = (event:IDragDropEvent) => { + this.$log.debug(`composition-graph::dropCallback:: fired`); + this.CompositionGraphPaletteUtils.addNodeFromPalette(this._cy, event, scope.component); + }; + + scope.verifyDrop = (event:JQueryEventObject) => { + + if (this.dragElement.hasClass('red')) { + return false; + } + return true; + }; + + scope.beforeDropCallback = (event:IDragDropEvent):ng.IPromise<void> => { + let deferred:ng.IDeferred<void> = this.$q.defer<void>(); + if (this.dragElement.hasClass('red')) { + deferred.reject(); + } else { + deferred.resolve(); + } + + return deferred.promise; + } + } + + public static factory = ($q, + $log, + $timeout, + NodesFactory, + LinksGraphUtils, + GeneralGraphUtils, + ComponentInstanceFactory, + NodesGraphUtils, + EventListenerService, + ComponentFactory, + LoaderService, + CommonGraphUtils, + MatchCapabilitiesRequirementsUtils, + CompositionGraphPaletteUtils, + ComponentServiceNg2) => { + return new CompositionGraph( + $q, + $log, + $timeout, + NodesFactory, + LinksGraphUtils, + GeneralGraphUtils, + ComponentInstanceFactory, + NodesGraphUtils, + EventListenerService, + ComponentFactory, + LoaderService, + CommonGraphUtils, + MatchCapabilitiesRequirementsUtils, + CompositionGraphPaletteUtils, + ComponentServiceNg2); + } +} + +CompositionGraph.factory.$inject = [ + '$q', + '$log', + '$timeout', + 'NodesFactory', + 'CompositionGraphLinkUtils', + 'CompositionGraphGeneralUtils', + 'ComponentInstanceFactory', + 'CompositionGraphNodesUtils', + 'EventListenerService', + 'ComponentFactory', + 'LoaderService', + 'CommonGraphUtils', + 'MatchCapabilitiesRequirementsUtils', + 'CompositionGraphPaletteUtils', + 'ComponentServiceNg2' +]; diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.html b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html index 5f2c488341..1e69d3384a 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.html +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.html @@ -15,8 +15,9 @@ <div class="w-sdc-canvas-menu-content hand" data-ng-click="deleteRelation(linkMenuObject.link)"> <div class="w-sdc-canvas-menu-content-delete-button"></div> - <!--{{relationComponent.data.relation.relationships[0].relationship.type | relationName }}--> Delete </div> </div> + +<!--<asset-popover ng-if="assetPopoverOpen" asset-popover-obj="assetPopoverObj" delete-asset="deleteNode(assetPopoverObj.nodeId)"></asset-popover>--> diff --git a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.less b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less index 7b999967b7..56c8b5529d 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/composition-graph/composition-graph.less +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/composition-graph.less @@ -1,14 +1,14 @@ composition-graph { display: block; - height:100%; width: 100%; + .sdc-composition-graph-wrapper{ height:100%; width: 100%; } - &.view-only{ + .view-only{ background-color:rgb(248, 248, 248); } -}
\ No newline at end of file +} diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts new file mode 100644 index 0000000000..1303e7a894 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-general-utils.ts @@ -0,0 +1,244 @@ +import {ComponentInstance, Component, MatchReqToCapability, MatchBase, CompositionCiLinkBase, CompositionCiNodeUcpeCp} from "app/models"; +import {QueueUtils, Dictionary, GraphUIObjects} from "app/utils"; +import {LoaderService} from "app/services"; +import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requierment-utils"; +import {CommonGraphUtils} from "../../common/common-graph-utils"; + + +export class CompositionGraphGeneralUtils { + + public componentRequirementsAndCapabilitiesCaching = new Dictionary<string, Component>(); + protected static graphUtilsUpdateQueue:QueueUtils; + + constructor(private $q:ng.IQService, + private LoaderService:LoaderService, + private commonGraphUtils:CommonGraphUtils, + private matchCapabilitiesRequirementsUtils:MatchCapabilitiesRequirementsUtils) { + CompositionGraphGeneralUtils.graphUtilsUpdateQueue = new QueueUtils(this.$q); + } + + + /** + * Get the offset for the link creation Menu + * @param point + * @returns {Cy.Position} + */ + public calcMenuOffset:Function = (point:Cy.Position):Cy.Position => { + point.x = point.x + 60; + point.y = point.y + 105; + return point; + }; + + /** + * return the top left position of the link menu + * @param cy + * @param targetNodePosition + * @returns {Cy.Position} + */ + public getLinkMenuPosition = (cy:Cy.Instance, targetNodePosition:Cy.Position) => { + let menuPosition:Cy.Position = this.calcMenuOffset(targetNodePosition); //get the link mid point + if ($(document.body).height() < menuPosition.y + GraphUIObjects.LINK_MENU_HEIGHT + $(document.getElementsByClassName('sdc-composition-graph-wrapper')).offset().top) { // if position menu is overflow bottom + menuPosition.y = $(document.body).height() - GraphUIObjects.TOP_HEADER_HEIGHT - GraphUIObjects.LINK_MENU_HEIGHT; + } + return menuPosition; + }; + + + /** + * will return true/false if two nodes overlapping + * + * @param graph node + */ + private isNodesOverlapping(node:Cy.CollectionFirstNode, draggedNode:Cy.CollectionFirstNode):boolean { + + let nodeBoundingBox:Cy.BoundingBox = node.renderedBoundingBox(); + let secondNodeBoundingBox:Cy.BoundingBox = draggedNode.renderedBoundingBox(); + + return this.isBBoxOverlapping(nodeBoundingBox, secondNodeBoundingBox); + } + + /** + * Checks whether the bounding boxes of two nodes are overlapping on any side + * @param nodeOneBBox + * @param nodeTwoBBox + * @returns {boolean} + */ + private isBBoxOverlapping(nodeOneBBox:Cy.BoundingBox, nodeTwoBBox:Cy.BoundingBox) { + return (((nodeOneBBox.x1 < nodeTwoBBox.x1 && nodeOneBBox.x2 > nodeTwoBBox.x1) || + (nodeOneBBox.x1 < nodeTwoBBox.x2 && nodeOneBBox.x2 > nodeTwoBBox.x2) || + (nodeTwoBBox.x1 < nodeOneBBox.x1 && nodeTwoBBox.x2 > nodeOneBBox.x2)) && + ((nodeOneBBox.y1 < nodeTwoBBox.y1 && nodeOneBBox.y2 > nodeTwoBBox.y1) || + (nodeOneBBox.y1 < nodeTwoBBox.y2 && nodeOneBBox.y2 > nodeTwoBBox.y2) || + (nodeTwoBBox.y1 < nodeOneBBox.y1 && nodeTwoBBox.y2 > nodeOneBBox.y2))) + } + + + /** + * Checks whether a specific component instance can be hosted on the UCPE instance + * @param cy - Cytoscape instance + * @param fromUcpeInstance + * @param toComponentInstance + * @returns {MatchReqToCapability} + */ + public canBeHostedOn(cy:Cy.Instance, fromUcpeInstance:ComponentInstance, toComponentInstance:ComponentInstance):MatchReqToCapability { + + let matches:Array<MatchBase> = this.matchCapabilitiesRequirementsUtils.getMatchedRequirementsCapabilities(fromUcpeInstance, toComponentInstance, this.getAllCompositionCiLinks(cy)); + let hostedOnMatch:MatchBase = _.find(matches, (match:MatchReqToCapability) => { + return match.requirement.capability.toLowerCase() === 'tosca.capabilities.container'; + }); + + return <MatchReqToCapability>hostedOnMatch; + }; + + + /** + * Checks whether node can be dropped into UCPE + * @param cy + * @param nodeToInsert + * @param ucpeNode + * @returns {boolean} + */ + private isValidDropInsideUCPE(cy:Cy.Instance, nodeToInsert:ComponentInstance, ucpeNode:ComponentInstance):boolean { + + let hostedOnMatch:MatchReqToCapability = this.canBeHostedOn(cy, ucpeNode, nodeToInsert); + let result:boolean = !angular.isUndefined(hostedOnMatch) || nodeToInsert.isVl(); //group validation + return result; + + }; + + + /** + * For drops from palette, checks whether the node can be dropped. If node is being held over another node, check if capable of hosting + * @param cy + * @param pseudoNodeBBox + * @param paletteComponentInstance + * @returns {boolean} + */ + public isPaletteDropValid(cy:Cy.Instance, pseudoNodeBBox:Cy.BoundingBox, paletteComponentInstance:ComponentInstance) { + + let componentIsUCPE:boolean = (paletteComponentInstance.capabilities && paletteComponentInstance.capabilities['tosca.capabilities.Container'] && paletteComponentInstance.name.toLowerCase().indexOf('ucpe') > -1); + + if (componentIsUCPE && cy.nodes('[?isUcpe]').length > 0) { //second UCPE not allowed + return false; + } + + let illegalOverlappingNodes = _.filter(cy.nodes("[isSdcElement]"), (graphNode:Cy.CollectionFirstNode) => { + + if (this.isBBoxOverlapping(pseudoNodeBBox, graphNode.renderedBoundingBox())) { + if (!componentIsUCPE && graphNode.data().isUcpe) { + return !this.isValidDropInsideUCPE(cy, paletteComponentInstance, graphNode.data().componentInstance); //if this is valid insert into ucpe, we return false - no illegal overlapping nodes + } + return true; + } + + return false; + }); + + return illegalOverlappingNodes.length === 0; + } + + /** + * will return true/false if a drop of a single node is valid + * + * @param graph node + */ + public isValidDrop(cy:Cy.Instance, draggedNode:Cy.CollectionFirstNode):boolean { + + let illegalOverlappingNodes = _.filter(cy.nodes("[isSdcElement]"), (graphNode:Cy.CollectionFirstNode) => { //all sdc nodes, removing child nodes (childe node allways collaps + + if (draggedNode.data().isUcpe && (graphNode.isChild() || graphNode.data().isInsideGroup)) { //ucpe cps always inside ucpe, no overlapping + return false; + } + if (draggedNode.data().isInsideGroup && (!draggedNode.active() || graphNode.data().isUcpe)) { + return false; + } + + if (!draggedNode.data().isUcpe && !(draggedNode.data() instanceof CompositionCiNodeUcpeCp) && graphNode.data().isUcpe) { //case we are dragging a node into UCPE + let isEntirelyInUCPE:boolean = this.commonGraphUtils.isFirstBoxContainsInSecondBox(draggedNode.renderedBoundingBox(), graphNode.renderedBoundingBox()); + if (isEntirelyInUCPE) { + if (this.isValidDropInsideUCPE(cy, draggedNode.data().componentInstance, graphNode.data().componentInstance)) { //if this is valid insert into ucpe, we return false - no illegal overlapping nodes + return false; + } + } + } + return graphNode.data().id !== draggedNode.data().id && this.isNodesOverlapping(draggedNode, graphNode); + + }); + // return false; + return illegalOverlappingNodes.length === 0; + }; + + /** + * will return true/false if the move of the nodes is valid (no node overlapping and verifying if insert into UCPE is valid) + * + * @param nodesArray - the selected drags nodes + */ + public isGroupValidDrop(cy:Cy.Instance, nodesArray:Cy.CollectionNodes):boolean { + let filterDraggedNodes = nodesArray.filter('[?isDraggable]'); + let isValidDrop = _.every(filterDraggedNodes, (node:Cy.CollectionFirstNode) => { + return this.isValidDrop(cy, node); + + }); + return isValidDrop; + }; + + /** + * get all links in diagram + * @param cy + * @returns {any[]|boolean[]} + */ + public getAllCompositionCiLinks = (cy:Cy.Instance):Array<CompositionCiLinkBase> => { + return _.map(cy.edges("[isSdcElement]"), (edge:Cy.CollectionEdges) => { + return edge.data(); + }); + }; + + + /** + * Get Graph Utils server queue + * @returns {QueueUtils} + */ + public getGraphUtilsServerUpdateQueue():QueueUtils { + return CompositionGraphGeneralUtils.graphUtilsUpdateQueue; + } + ; + + /** + * + * @param blockAction - true/false if this is a block action + * @param instances + * @param component + */ + public pushMultipleUpdateComponentInstancesRequestToQueue = (blockAction:boolean, instances:Array<ComponentInstance>, component:Component):void => { + if (blockAction) { + this.getGraphUtilsServerUpdateQueue().addBlockingUIAction( + () => component.updateMultipleComponentInstances(instances) + ); + } else { + this.getGraphUtilsServerUpdateQueue().addNonBlockingUIAction( + () => component.updateMultipleComponentInstances(instances), + () => this.LoaderService.hideLoader('composition-graph')); + } + }; + + /** + * this function will update component instance data + * @param blockAction - true/false if this is a block action + * @param updatedInstance + */ + public pushUpdateComponentInstanceActionToQueue = (component:Component, blockAction:boolean, updatedInstance:ComponentInstance):void => { + + if (blockAction) { + this.LoaderService.showLoader('composition-graph'); + this.getGraphUtilsServerUpdateQueue().addBlockingUIAction( + () => component.updateComponentInstance(updatedInstance) + ); + } else { + this.getGraphUtilsServerUpdateQueue().addNonBlockingUIAction( + () => component.updateComponentInstance(updatedInstance), + () => this.LoaderService.hideLoader('composition-graph')); + } + }; +} + +CompositionGraphGeneralUtils.$inject = ['$q', 'LoaderService', 'CommonGraphUtils', 'MatchCapabilitiesRequirementsUtils']; diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts new file mode 100644 index 0000000000..314c761edd --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-links-utils.ts @@ -0,0 +1,271 @@ +/** + * Created by obarda on 6/28/2016. + */ +import {GraphUIObjects, ComponentInstanceFactory, ResourceType} from "app/utils"; +import {LeftPaletteLoaderService, LoaderService} from "app/services"; +import { + NodeUcpe, + CompositionCiNodeVf, + MatchReqToCapability, + MatchBase, + MatchReqToReq, + ComponentInstance, + CompositionCiNodeBase, + RelationshipModel, + RelationMenuDirectiveObj, + CapabilitiesGroup, + LinksFactory, + NodesFactory, + RequirementsGroup, + Component, + Relationship, + Capability, + LinkMenu, + Point, + CompositionCiLinkBase +} from "app/models"; +import {CommonGraphUtils} from "../../common/common-graph-utils"; +import {CompositionGraphGeneralUtils} from "./composition-graph-general-utils"; +import {MatchCapabilitiesRequirementsUtils} from "./match-capability-requierment-utils"; + +export class CompositionGraphLinkUtils { + + constructor(private linksFactory:LinksFactory, + private loaderService:LoaderService, + private generalGraphUtils:CompositionGraphGeneralUtils, + private commonGraphUtils:CommonGraphUtils, + private matchCapabilitiesRequirementsUtils:MatchCapabilitiesRequirementsUtils) { + } + + + /** + * Delete the link on server and then remove it from graph + * @param component + * @param releaseLoading - true/false release the loader when finished + * @param link - the link to delete + */ + public deleteLink = (cy:Cy.Instance, component:Component, releaseLoading:boolean, link:Cy.CollectionEdges) => { + + this.loaderService.showLoader('composition-graph'); + let onSuccessDeleteRelation = (response) => { + cy.remove(link); + }; + + if (!releaseLoading) { + this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIAction( + () => component.deleteRelation(link.data().relation).then(onSuccessDeleteRelation) + ); + } else { + this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( + () => component.deleteRelation(link.data().relation).then(onSuccessDeleteRelation), + () => this.loaderService.hideLoader('composition-graph')); + } + }; + + /** + * create the link on server and than draw it on graph + * @param link - the link to create + * @param cy + * @param component + */ + public createLink = (link:CompositionCiLinkBase, cy:Cy.Instance, component:Component):void => { + + this.loaderService.showLoader('composition-graph'); + + let onSuccess:(response:RelationshipModel) => void = (relation:RelationshipModel) => { + link.setRelation(relation); + this.commonGraphUtils.insertLinkToGraph(cy, link); + }; + + link.updateLinkDirection(); + + this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( + () => component.createRelation(link.relation).then(onSuccess), + () => this.loaderService.hideLoader('composition-graph') + ); + }; + + private createSimpleLink = (match:MatchReqToCapability, cy:Cy.Instance, component:Component):void => { + let newRelation:RelationshipModel = match.matchToRelationModel(); + let linkObg:CompositionCiLinkBase = this.linksFactory.createGraphLink(cy, newRelation, newRelation.relationships[0]); + this.createLink(linkObg, cy, component); + }; + + public createLinkFromMenu = (cy:Cy.Instance, chosenMatch:MatchBase, component:Component):void => { + + if (chosenMatch) { + if (chosenMatch && chosenMatch instanceof MatchReqToCapability) { + this.createSimpleLink(chosenMatch, cy, component); + } + } + }; + + + /** + * Filters the matches for UCPE links so that shown requirements and capabilites are only related to the selected ucpe-cp + * @param fromNode + * @param toNode + * @param matchesArray + * @returns {Array<MatchBase>} + */ + public filterUcpeLinks(fromNode:CompositionCiNodeBase, toNode:CompositionCiNodeBase, matchesArray:Array<MatchBase>):any { + + let matchLink:Array<MatchBase>; + + if (fromNode.isUcpePart) { + matchLink = _.filter(matchesArray, (match:MatchBase) => { + return match.isOwner(fromNode.id); + }); + } + + if (toNode.isUcpePart) { + matchLink = _.filter(matchesArray, (match:MatchBase) => { + return match.isOwner(toNode.id); + }); + } + return matchLink ? matchLink : matchesArray; + } + + + /** + * open the connect link menu if the link drawn is valid - match requirements & capabilities + * @param cy + * @param fromNode + * @param toNode + * @returns {any} + */ + public onLinkDrawn(cy:Cy.Instance, fromNode:Cy.CollectionFirstNode, toNode:Cy.CollectionFirstNode):RelationMenuDirectiveObj { + + if (!this.commonGraphUtils.nodeLocationsCompatible(cy, fromNode, toNode)) { + return null; + } + let linkModel:Array<CompositionCiLinkBase> = this.generalGraphUtils.getAllCompositionCiLinks(cy); + + let possibleRelations:Array<MatchBase> = this.matchCapabilitiesRequirementsUtils.getMatchedRequirementsCapabilities(fromNode.data().componentInstance, + toNode.data().componentInstance, linkModel); + + //filter relations found to limit to specific ucpe-cp + possibleRelations = this.filterUcpeLinks(fromNode.data(), toNode.data(), possibleRelations); + + //if found possibleRelations between the nodes we create relation menu directive and open the link menu + if (possibleRelations.length) { + let menuPosition = this.generalGraphUtils.getLinkMenuPosition(cy, toNode.renderedPoint()); + return new RelationMenuDirectiveObj(fromNode.data(), toNode.data(), menuPosition, possibleRelations); + } + return null; + }; + + + /** + * when we drag instance in to UCPE or out of UCPE - get all links we need to delete - one node in ucpe and one node outside of ucpe + * @param node - the node we dragged into or out of the ucpe + */ + public deleteLinksWhenNodeMovedFromOrToUCPE(component:Component, cy:Cy.Instance, nodeMoved:Cy.CollectionNodes, vlsPendingDeletion?:Cy.CollectionNodes):void { + + + let linksToDelete:Cy.CollectionElements = cy.collection(); + _.forEach(nodeMoved.neighborhood('node'), (neighborNode)=> { + + if (neighborNode.data().isUcpePart) { //existing connections to ucpe or ucpe-cp - we want to delete even though nodeLocationsCompatible will technically return true + linksToDelete = linksToDelete.add(nodeMoved.edgesWith(neighborNode)); // This will delete the ucpe-host-link, or the vl-ucpe-link if nodeMoved is vl + } else if (!this.commonGraphUtils.nodeLocationsCompatible(cy, nodeMoved, neighborNode)) { //connection to regular node or vl - check if locations are compatible + if (!vlsPendingDeletion || !vlsPendingDeletion.intersect(neighborNode).length) { //Check if this is a link to a VL pending deletion, to prevent double deletion of between the node moved and vl + linksToDelete = linksToDelete.add(nodeMoved.edgesWith(neighborNode)); + } + } + }); + + linksToDelete.each((i, link)=> { + this.deleteLink(cy, component, false, link); + }); + + }; + + /** + * Creates a hostedOn link between a VF and UCPE + * @param component + * @param cy + * @param ucpeNode + * @param vfNode + */ + public createVfToUcpeLink = (component:Component, cy:Cy.Instance, ucpeNode:NodeUcpe, vfNode:CompositionCiNodeVf):void => { + let hostedOnMatch:MatchReqToCapability = this.generalGraphUtils.canBeHostedOn(cy, ucpeNode.componentInstance, vfNode.componentInstance); + /* create relation */ + let newRelation = new RelationshipModel(); + newRelation.fromNode = ucpeNode.id; + newRelation.toNode = vfNode.id; + + let link:CompositionCiLinkBase = this.linksFactory.createUcpeHostLink(newRelation); + link.relation = hostedOnMatch.matchToRelationModel(); + this.createLink(link, cy, component); + }; + + + /** + * Handles click event on links. + * If one edge selected: do nothing. + /*Two edges selected - always select all + /* Three or more edges: first click - select all, secondary click - select single. + * @param cy + * @param event + */ + public handleLinkClick(cy:Cy.Instance, event:Cy.EventObject) { + if (cy.$('edge:selected').length > 2 && event.cyTarget[0].selected()) { + cy.$(':selected').unselect(); + } else { + + let vl:Cy.CollectionNodes = event.cyTarget[0].target('.vl-node'); + let connectedEdges:Cy.CollectionEdges = vl.connectedEdges(); + if (vl.length && connectedEdges.length > 1) { + + setTimeout(() => { + vl.select(); + connectedEdges.select(); + }, 0); + } + } + + } + + + /** + * Calculates the position for the menu that modifies an existing link + * @param event + * @param elementWidth + * @param elementHeight + * @returns {Point} + */ + public calculateLinkMenuPosition(event, elementWidth, elementHeight):Point { + let point:Point = new Point(event.originalEvent.x, event.originalEvent.y); + if (event.originalEvent.view.screen.height - elementHeight < point.y) { + point.y = event.originalEvent.view.screen.height - elementHeight; + } + if (event.originalEvent.view.screen.width - elementWidth < point.x) { + point.x = event.originalEvent.view.screen.width - elementWidth; + } + return point; + }; + + + /** + * Gets the menu that is displayed when you click an existing link. + * @param link + * @param event + * @returns {LinkMenu} + */ + public getModifyLinkMenu(link:Cy.CollectionFirstEdge, event:Cy.EventObject):LinkMenu { + let point:Point = this.calculateLinkMenuPosition(event, GraphUIObjects.MENU_LINK_VL_WIDTH_OFFSET, GraphUIObjects.MENU_LINK_VL_HEIGHT_OFFSET); + let menu:LinkMenu = new LinkMenu(point, true, link); + return menu; + }; + +} + + +CompositionGraphLinkUtils.$inject = [ + 'LinksFactory', + 'LoaderService', + 'CompositionGraphGeneralUtils', + 'CommonGraphUtils', + 'MatchCapabilitiesRequirementsUtils' +]; diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts new file mode 100644 index 0000000000..96afc8a4ea --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils.ts @@ -0,0 +1,266 @@ +import {Component, NodesFactory, ComponentInstance, CompositionCiNodeVl,IAppMenu,AssetPopoverObj} from "app/models"; +import {EventListenerService, LoaderService} from "app/services"; +import {GRAPH_EVENTS,ModalsHandler,GraphUIObjects} from "app/utils"; +import {CompositionGraphGeneralUtils} from "./composition-graph-general-utils"; +import {CommonGraphUtils} from "../../common/common-graph-utils"; +/** + * Created by obarda on 11/9/2016. + */ +export class CompositionGraphNodesUtils { + constructor(private NodesFactory:NodesFactory, private $log:ng.ILogService, + private GeneralGraphUtils:CompositionGraphGeneralUtils, + private commonGraphUtils:CommonGraphUtils, + private eventListenerService:EventListenerService, + private loaderService:LoaderService /*, + private sdcMenu: IAppMenu, + private ModalsHandler: ModalsHandler*/) { + + } + + /** + * Returns component instances for all nodes passed in + * @param nodes - Cy nodes + * @returns {any[]} + */ + public getAllNodesData(nodes:Cy.CollectionNodes) { + return _.map(nodes, (node:Cy.CollectionFirstNode)=> { + return node.data(); + }) + }; + + /** + * Deletes component instances on server and then removes it from the graph as well + * @param cy + * @param component + * @param nodeToDelete + */ + public deleteNode(cy:Cy.Instance, component:Component, nodeToDelete:Cy.CollectionNodes):void { + + this.loaderService.showLoader('composition-graph'); + let onSuccess:(response:ComponentInstance) => void = (response:ComponentInstance) => { + console.info('onSuccess', response); + + //if node to delete is a UCPE, remove all children (except UCPE-CPs) and remove their "hostedOn" links + if (nodeToDelete.data().isUcpe) { + _.each(cy.nodes('[?isInsideGroup]'), (node)=> { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node, nodeToDelete); + }); + } + + //check whether the node is connected to any VLs that only have one other connection. If so, delete that VL as well + if (!(nodeToDelete.data() instanceof CompositionCiNodeVl)) { + let connectedVls:Array<Cy.CollectionFirstNode> = this.getConnectedVlToNode(nodeToDelete); + this.handleConnectedVlsToDelete(connectedVls); + } + + //update UI + cy.remove(nodeToDelete); + + }; + + let onFailed:(response:any) => void = (response:any) => { + console.info('onFailed', response); + }; + + + this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback( + () => component.deleteComponentInstance(nodeToDelete.data().componentInstance.uniqueId).then(onSuccess, onFailed), + () => this.loaderService.hideLoader('composition-graph') + ); + + }; + +/* + public confirmDeleteNode = (nodeId:string, cy:Cy.Instance, component:Component) => { + let node:Cy.CollectionNodes = cy.getElementById(nodeId); + let onOk = ():void => { + this.deleteNode(cy, component, node); + }; + + let componentInstance:ComponentInstance = node.data().componentInstance; + let state = "deleteInstance"; + let title:string = this.sdcMenu.alertMessages[state].title; + let message:string = this.sdcMenu.alertMessages[state].message.format([componentInstance.name]); + + this.ModalsHandler.openAlertModal(title, message).then(onOk); + };*/ + /** + * Finds all VLs connected to a single node + * @param node + * @returns {Array<Cy.CollectionFirstNode>} + */ + public getConnectedVlToNode = (node:Cy.CollectionNodes):Array<Cy.CollectionFirstNode> => { + let connectedVls:Array<Cy.CollectionFirstNode> = new Array<Cy.CollectionFirstNode>(); + _.forEach(node.connectedEdges().connectedNodes(), (node:Cy.CollectionFirstNode) => { + if (node.data() instanceof CompositionCiNodeVl) { + connectedVls.push(node); + } + }); + return connectedVls; + }; + + + /** + * Delete all VLs that have only two connected nodes (this function is called when deleting a node) + * @param connectedVls + */ + public handleConnectedVlsToDelete = (connectedVls:Array<Cy.CollectionFirstNode>) => { + _.forEach(connectedVls, (vlToDelete:Cy.CollectionNodes) => { + + if (vlToDelete.connectedEdges().length === 2) { // if vl connected only to 2 nodes need to delete the vl + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, vlToDelete.data().componentInstance); + } + }); + }; + + + /** + * This function is called when moving a node in or out of UCPE. + * Deletes all connected VLs that have less than 2 valid connections remaining after the move + * Returns the collection of vls that are in the process of deletion (async) to prevent duplicate calls while deletion is in progress + * @param component + * @param cy + * @param node - node that was moved in/out of ucpe + */ + public deleteNodeVLsUponMoveToOrFromUCPE = (component:Component, cy:Cy.Instance, node:Cy.CollectionNodes):Cy.CollectionNodes => { + if (node.data() instanceof CompositionCiNodeVl) { + return; + } + + let connectedVLsToDelete:Cy.CollectionNodes = cy.collection(); + _.forEach(node.neighborhood('node'), (connectedNode) => { + + //Find all neighboring nodes that are VLs + if (connectedNode.data() instanceof CompositionCiNodeVl) { + + //check VL's neighbors to see if it has 2 or more nodes whose location is compatible with VL (regardless of whether VL is in or out of UCPE) + let compatibleNodeCount = 0; + let vlNeighborhood = connectedNode.neighborhood('node'); + _.forEach(vlNeighborhood, (vlNeighborNode)=> { + if (this.commonGraphUtils.nodeLocationsCompatible(cy, connectedNode, vlNeighborNode)) { + compatibleNodeCount++; + } + }); + + if (compatibleNodeCount < 2) { + connectedVLsToDelete = connectedVLsToDelete.add(connectedNode); + } + } + }); + + connectedVLsToDelete.each((i, vlToDelete:Cy.CollectionNodes)=> { + this.deleteNode(cy, component, vlToDelete); + }); + return connectedVLsToDelete; + }; + + /** + * This function will update nodes position. if the new position is into or out of ucpe, the node will trigger the ucpe events + * @param cy + * @param component + * @param nodesMoved - the node/multiple nodes now moved by the user + */ + public onNodesPositionChanged = (cy:Cy.Instance, component:Component, nodesMoved:Cy.CollectionNodes):void => { + + if (nodesMoved.length === 0) { + return; + } + + let isValidMove:boolean = this.GeneralGraphUtils.isGroupValidDrop(cy, nodesMoved); + if (isValidMove) { + + this.$log.debug(`composition-graph::ValidDrop:: updating node position`); + let instancesToUpdateInNonBlockingAction:Array<ComponentInstance> = new Array<ComponentInstance>(); + + _.each(nodesMoved, (node:Cy.CollectionFirstNode)=> { //update all nodes new position + + if (node.data().isUcpePart && !node.data().isUcpe) { + return; + }//No need to update UCPE-CPs + + //update position + let newPosition:Cy.Position = this.commonGraphUtils.getNodePosition(node); + node.data().componentInstance.updatePosition(newPosition.x, newPosition.y); + + //check if node moved to or from UCPE + let ucpe = this.commonGraphUtils.isInUcpe(node.cy(), node.boundingbox()); + if (node.data().isInsideGroup || ucpe.length) { + this.handleUcpeChildMove(node, ucpe, instancesToUpdateInNonBlockingAction); + } else { + instancesToUpdateInNonBlockingAction.push(node.data().componentInstance); + } + + }); + + if (instancesToUpdateInNonBlockingAction.length > 0) { + this.GeneralGraphUtils.pushMultipleUpdateComponentInstancesRequestToQueue(false, instancesToUpdateInNonBlockingAction, component); + } + } else { + this.$log.debug(`composition-graph::notValidDrop:: node return to latest position`); + //reset nodes position + nodesMoved.positions((i, node) => { + return { + x: +node.data().componentInstance.posX, + y: +node.data().componentInstance.posY + }; + }) + } + + this.GeneralGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIActionWithReleaseCallback(() => { + }, () => { + this.loaderService.hideLoader('composition-graph'); + }); + + }; + + /** + * Checks whether the node has been added or removed from UCPE and triggers appropriate events + * @param node - node moved + * @param ucpeContainer - UCPE container that the node has been moved to. When moving a node out of ucpe, param will be empty + * @param instancesToUpdateInNonBlockingAction + */ + public handleUcpeChildMove(node:Cy.CollectionFirstNode, ucpeContainer:Cy.CollectionElements, instancesToUpdateInNonBlockingAction:Array<ComponentInstance>) { + + if (node.data().isInsideGroup) { + if (ucpeContainer.length) { //moving node within UCPE. Simply update position + this.commonGraphUtils.updateUcpeChildPosition(<Cy.CollectionNodes>node, ucpeContainer); + instancesToUpdateInNonBlockingAction.push(node.data().componentInstance); + } else { //removing node from UCPE. Notify observers + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_REMOVE_NODE_FROM_UCPE, node, ucpeContainer); + } + } else if (!node.data().isInsideGroup && ucpeContainer.length && !node.data().isUcpePart) { //adding node to UCPE + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, node, ucpeContainer, true); + } + } + /** + * Gets the position for the asset popover menu + * Then, check if right edge of menu would overlap horizontal screen edge (palette offset + canvas width - right panel) + * Then, check if bottom edge of menu would overlap the vertical end of the canvas. + * @param cy + * @param node + * @returns {Cy.Position} + + public createAssetPopover = (cy: Cy.Instance, node:Cy.CollectionFirstNode, isViewOnly:boolean):AssetPopoverObj => { + + let menuOffset:Cy.Position = { x: node.renderedWidth() / 2, y: -(node.renderedWidth() / 2) };// getNodePositionWithOffset returns central point of node. First add node.renderedWidth()/2 to get its to border. + let menuPosition:Cy.Position = this.commonGraphUtils.getNodePositionWithOffset(node, menuOffset); + let menuSide:string = 'right'; + + if(menuPosition.x + GraphUIObjects.COMPOSITION_NODE_MENU_WIDTH >= cy.width() + GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET - GraphUIObjects.COMPOSITION_RIGHT_PANEL_OFFSET){ + menuPosition.x -= menuOffset.x * 2 + GraphUIObjects.COMPOSITION_NODE_MENU_WIDTH; //menu position already includes offset to the right. Therefore, subtract double offset so we have same distance from node for menu on left + menuSide = 'left'; + } + + if(menuPosition.y + GraphUIObjects.COMPOSITION_NODE_MENU_HEIGHT >= cy.height()){ + menuPosition.y = menuPosition.y - GraphUIObjects.COMPOSITION_NODE_MENU_HEIGHT - menuOffset.y * 2; + } + + return new AssetPopoverObj(node.data().id, node.data().name, menuPosition, menuSide, isViewOnly); + }; + */ + + } + + + CompositionGraphNodesUtils.$inject = ['NodesFactory', '$log', 'CompositionGraphGeneralUtils', 'CommonGraphUtils', 'EventListenerService', 'LoaderService' /*, 'sdcMenu', 'ModalsHandler'*/] + diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-palette-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-palette-utils.ts new file mode 100644 index 0000000000..83bf747501 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/composition-graph-palette-utils.ts @@ -0,0 +1,163 @@ +import {EventListenerService, LoaderService} from "app/services"; +import {CapabilitiesGroup, NodesFactory, ComponentInstance, Component, CompositionCiNodeBase, RequirementsGroup} from "app/models"; +import {ComponentFactory, ComponentInstanceFactory, GRAPH_EVENTS, GraphUIObjects} from "app/utils"; +import {CompositionGraphGeneralUtils} from "./composition-graph-general-utils"; +import {CommonGraphUtils} from "../../common/common-graph-utils"; +import 'angular-dragdrop'; +import {LeftPaletteComponent} from "../../../../models/components/displayComponent"; + +export class CompositionGraphPaletteUtils { + + constructor(private ComponentFactory:ComponentFactory, + private $filter:ng.IFilterService, + private loaderService:LoaderService, + private generalGraphUtils:CompositionGraphGeneralUtils, + private componentInstanceFactory:ComponentInstanceFactory, + private nodesFactory:NodesFactory, + private commonGraphUtils:CommonGraphUtils, + private eventListenerService:EventListenerService) { + } + + /** + * Calculate the dragged element (html element) position on canvas + * @param cy + * @param event + * @param position + * @returns {Cy.BoundingBox} + * @private + */ + private _getNodeBBox(cy:Cy.Instance, event:IDragDropEvent, position?:Cy.Position) { + let bbox = <Cy.BoundingBox>{}; + if (!position) { + position = this.commonGraphUtils.getCytoscapeNodePosition(cy, event); + } + let cushionWidth:number = 40; + let cushionHeight:number = 40; + + bbox.x1 = position.x - cushionWidth / 2; + bbox.y1 = position.y - cushionHeight / 2; + bbox.x2 = position.x + cushionWidth / 2; + bbox.y2 = position.y + cushionHeight / 2; + return bbox; + } + + /** + * Create the component instance, update data from parent component in the left palette and notify on_insert_to_ucpe if component was dragg into ucpe + * @param cy + * @param fullComponent + * @param event + * @param component + */ + private _createComponentInstanceOnGraphFromPaletteComponent(cy:Cy.Instance, fullComponent:LeftPaletteComponent, event:IDragDropEvent, component:Component) { + + let componentInstanceToCreate:ComponentInstance = this.componentInstanceFactory.createComponentInstanceFromComponent(fullComponent); + let cytoscapePosition:Cy.Position = this.commonGraphUtils.getCytoscapeNodePosition(cy, event); + + componentInstanceToCreate.posX = cytoscapePosition.x; + componentInstanceToCreate.posY = cytoscapePosition.y; + + + let onFailedCreatingInstance:(error:any) => void = (error:any) => { + this.loaderService.hideLoader('composition-graph'); + }; + + //on success - update node data + let onSuccessCreatingInstance = (createInstance:ComponentInstance):void => { + + this.loaderService.hideLoader('composition-graph'); + + createInstance.name = this.$filter('resourceName')(createInstance.name); + createInstance.requirements = new RequirementsGroup(createInstance.requirements); + createInstance.capabilities = new CapabilitiesGroup(createInstance.capabilities); + createInstance.componentVersion = fullComponent.version; + createInstance.icon = fullComponent.icon; + createInstance.setInstanceRC(); + + let newNode:CompositionCiNodeBase = this.nodesFactory.createNode(createInstance); + let cyNode:Cy.CollectionNodes = this.commonGraphUtils.addComponentInstanceNodeToGraph(cy, newNode); + + //check if node was dropped into a UCPE + let ucpe:Cy.CollectionElements = this.commonGraphUtils.isInUcpe(cy, cyNode.boundingbox()); + if (ucpe.length > 0) { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_INSERT_NODE_TO_UCPE, cyNode, ucpe, false); + } + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_CREATE_COMPONENT_INSTANCE); + + }; + + this.loaderService.showLoader('composition-graph'); + + // Create the component instance on server + this.generalGraphUtils.getGraphUtilsServerUpdateQueue().addBlockingUIAction(() => { + component.createComponentInstance(componentInstanceToCreate).then(onSuccessCreatingInstance, onFailedCreatingInstance); + }); + } + + /** + * Thid function applay red/green background when component dragged from palette + * @param cy + * @param event + * @param dragElement + * @param dragComponent + */ + public onComponentDrag(cy:Cy.Instance, event:IDragDropEvent, dragElement:JQuery, dragComponent:ComponentInstance) { + + if (event.clientX < GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET || event.clientY < GraphUIObjects.DIAGRAM_HEADER_OFFSET) { //hovering over palette. Dont bother computing validity of drop + dragElement.removeClass('red'); + return; + } + + let offsetPosition = { + x: event.clientX - GraphUIObjects.DIAGRAM_PALETTE_WIDTH_OFFSET, + y: event.clientY - GraphUIObjects.DIAGRAM_HEADER_OFFSET + }; + let bbox = this._getNodeBBox(cy, event, offsetPosition); + + if (this.generalGraphUtils.isPaletteDropValid(cy, bbox, dragComponent)) { + dragElement.removeClass('red'); + } else { + dragElement.addClass('red'); + } + } + + /** + * This function is called when after dropping node on canvas + * Check if the capability & requirements fulfilled and if not get from server + * @param cy + * @param event + * @param component + */ + public addNodeFromPalette(cy:Cy.Instance, event:IDragDropEvent, component:Component) { + this.loaderService.showLoader('composition-graph'); + + let draggedComponent:LeftPaletteComponent = event.dataTransfer.component; + + if (this.generalGraphUtils.componentRequirementsAndCapabilitiesCaching.containsKey(draggedComponent.uniqueId)) { + let fullComponent = this.generalGraphUtils.componentRequirementsAndCapabilitiesCaching.getValue(draggedComponent.uniqueId); + draggedComponent.capabilities = fullComponent.capabilities; + draggedComponent.requirements = fullComponent.requirements; + this._createComponentInstanceOnGraphFromPaletteComponent(cy, draggedComponent, event, component); + + } else { + + this.ComponentFactory.getComponentFromServer(draggedComponent.getComponentSubType(), draggedComponent.uniqueId) + .then((fullComponent:Component) => { + draggedComponent.capabilities = fullComponent.capabilities; + draggedComponent.requirements = fullComponent.requirements; + this._createComponentInstanceOnGraphFromPaletteComponent(cy, draggedComponent, event, component); + }); + } + } +} + + +CompositionGraphPaletteUtils.$inject = [ + 'ComponentFactory', + '$filter', + 'LoaderService', + 'CompositionGraphGeneralUtils', + 'ComponentInstanceFactory', + 'NodesFactory', + 'CommonGraphUtils', + 'EventListenerService' +]; diff --git a/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts new file mode 100644 index 0000000000..0e21f033be --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils.ts @@ -0,0 +1,259 @@ +import {Requirement, CompositionCiLinkBase, ComponentInstance, CapabilitiesGroup, RequirementsGroup, MatchReqToCapability, MatchBase, + MatchReqToReq,CompositionCiNodeBase, Component, Capability} from "app/models"; +/** + * Created by obarda on 1/1/2017. + */ + +export class MatchCapabilitiesRequirementsUtils { + + constructor() { + } + + public static linkable(requirement1:Requirement, requirement2:Requirement, vlCapability:Capability):boolean { + return MatchCapabilitiesRequirementsUtils.isMatch(requirement1, vlCapability) && MatchCapabilitiesRequirementsUtils.isMatch(requirement2, vlCapability); + }; + + + /** + * Shows + icon in corner of each node passed in + * @param filteredNodesData + * @param cy + */ + public highlightMatchingComponents(filteredNodesData, cy:Cy.Instance) { + _.each(filteredNodesData, (data:any) => { + let node = cy.getElementById(data.id); + cy.emit('showhandle', [node]); + }); + } + + /** + * Adds opacity to each node that cannot be linked to hovered node + * @param filteredNodesData + * @param nodesData + * @param cy + * @param hoveredNodeData + */ + public fadeNonMachingComponents(filteredNodesData, nodesData, cy:Cy.Instance, hoveredNodeData?) { + let fadeNodes = _.xorWith(nodesData, filteredNodesData, (node1, node2) => { + return node1.id === node2.id; + }); + if (hoveredNodeData) { + _.remove(fadeNodes, hoveredNodeData); + } + cy.batch(()=> { + _.each(fadeNodes, (node) => { + cy.getElementById(node.id).style({'background-image-opacity': 0.4}); + }); + }) + } + + /** + * Resets all nodes to regular opacity + * @param cy + */ + public resetFadedNodes(cy:Cy.Instance) { + cy.batch(()=> { + cy.nodes().style({'background-image-opacity': 1}); + }) + } + + // -------------------------------------------ALL FUNCTIONS NEED REFACTORING---------------------------------------------------------------// + + private static requirementFulfilled(fromNodeId:string, requirement:any, links:Array<CompositionCiLinkBase>):boolean { + return _.some(links, { + 'relation': { + 'fromNode': fromNodeId, + 'relationships': [{ + 'requirementOwnerId': requirement.ownerId, + 'requirement': requirement.name, + 'relationship': { + 'type': requirement.relationship + } + } + ] + } + }); + }; + + private static isMatch(requirement:Requirement, capability:Capability):boolean { + if (capability.type === requirement.capability) { + if (requirement.node) { + if (_.includes(capability.capabilitySources, requirement.node)) { + return true; + } + } else { + return true; + } + } + return false; + }; + + private getFromToMatches(requirements1:RequirementsGroup, + requirements2:RequirementsGroup, + capabilities:CapabilitiesGroup, + links:Array<CompositionCiLinkBase>, + fromId:string, + toId:string, + vlCapability?:Capability):Array<MatchBase> { + let matches:Array<MatchBase> = new Array<MatchBase>(); + _.forEach(requirements1, (requirementValue:Array<Requirement>, key) => { + _.forEach(requirementValue, (requirement:Requirement) => { + if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromId, requirement, links)) { + _.forEach(capabilities, (capabilityValue:Array<Capability>, key) => { + _.forEach(capabilityValue, (capability:Capability) => { + if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { + let match:MatchReqToCapability = new MatchReqToCapability(requirement, capability, true, fromId, toId); + matches.push(match); + } + }); + }); + if (vlCapability) { + _.forEach(requirements2, (requirement2Value:Array<Requirement>, key) => { + _.forEach(requirement2Value, (requirement2:Requirement) => { + if (!MatchCapabilitiesRequirementsUtils.requirementFulfilled(toId, requirement2, links) && MatchCapabilitiesRequirementsUtils.linkable(requirement, requirement2, vlCapability)) { + let match:MatchReqToReq = new MatchReqToReq(requirement, requirement2, true, fromId, toId); + matches.push(match); + } + }); + }); + } + } + }); + }); + return matches; + } + + private getToFromMatches(requirements:RequirementsGroup, capabilities:CapabilitiesGroup, links:Array<CompositionCiLinkBase>, fromId:string, toId:string):Array<MatchReqToCapability> { + let matches:Array<MatchReqToCapability> = []; + _.forEach(requirements, (requirementValue:Array<Requirement>, key) => { + _.forEach(requirementValue, (requirement:Requirement) => { + if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(toId, requirement, links)) { + _.forEach(capabilities, (capabilityValue:Array<Capability>, key) => { + _.forEach(capabilityValue, (capability:Capability) => { + if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { + let match:MatchReqToCapability = new MatchReqToCapability(requirement, capability, false, toId, fromId); + matches.push(match); + } + }); + }); + } + }); + }); + return matches; + } + + public getMatchedRequirementsCapabilities(fromComponentInstance:ComponentInstance, + toComponentInstance:ComponentInstance, + links:Array<CompositionCiLinkBase>, + vl?:Component):Array<MatchBase> {//TODO allow for VL array + let linkCapability; + if (vl) { + let linkCapabilities:Array<Capability> = vl.capabilities.findValueByKey('linkable'); + if (linkCapabilities) { + linkCapability = linkCapabilities[0]; + } + } + let fromToMatches:Array<MatchBase> = this.getFromToMatches(fromComponentInstance.requirements, + toComponentInstance.requirements, + toComponentInstance.capabilities, + links, + fromComponentInstance.uniqueId, + toComponentInstance.uniqueId, + linkCapability); + let toFromMatches:Array<MatchReqToCapability> = this.getToFromMatches(toComponentInstance.requirements, + fromComponentInstance.capabilities, + links, + fromComponentInstance.uniqueId, + toComponentInstance.uniqueId); + + return fromToMatches.concat(toFromMatches); + } + + + /** + * Step I: Check if capabilities of component match requirements of nodeDataArray + * 1. Get component capabilities and loop on each capability + * 2. Inside the loop, perform another loop on all nodeDataArray, and fetch the requirements for each one + * 3. Loop on the requirements, and verify match (see in code the rules) + * + * Step II: Check if requirements of component match capabilities of nodeDataArray + * 1. Get component requirements and loop on each requirement + * 2. + * + * @param component - this is the hovered resource of the left panel of composition screen + * @param nodeDataArray - Array of resource instances that are on the canvas + * @param links -getMatchedRequirementsCapabilities + * @param vl - + * @returns {any[]|T[]} + */ + public findByMatchingCapabilitiesToRequirements(component:Component, + nodeDataArray:Array<CompositionCiNodeBase>, + links:Array<CompositionCiLinkBase>, + vl?:Component):Array<any> {//TODO allow for VL array + let res = []; + + // STEP I + { + let capabilities:any = component.capabilities; + _.forEach(capabilities, (capabilityValue:Array<any>, capabilityKey)=> { + _.forEach(capabilityValue, (capability)=> { + _.forEach(nodeDataArray, (node:CompositionCiNodeBase)=> { + if (node && node.componentInstance) { + let requirements:any = node.componentInstance.requirements; + let fromNodeId:string = node.componentInstance.uniqueId; + _.forEach(requirements, (requirementValue:Array<any>, requirementKey)=> { + _.forEach(requirementValue, (requirement)=> { + if (requirement.name !== "dependency" && MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability) + && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromNodeId, requirement, links)) { + res.push(node); + } + }); + }); + } + }); + }); + }); + } + + // STEP II + { + let requirements:any = component.requirements; + let fromNodeId:string = component.uniqueId; + let linkCapability:Array<Capability> = vl ? vl.capabilities.findValueByKey('linkable') : undefined; + + _.forEach(requirements, (requirementValue:Array<any>, requirementKey)=> { + _.forEach(requirementValue, (requirement)=> { + if (requirement.name !== "dependency" && !MatchCapabilitiesRequirementsUtils.requirementFulfilled(fromNodeId, requirement, links)) { + _.forEach(nodeDataArray, (node:any)=> { + if (node && node.componentInstance && node.category !== 'groupCp') { + let capabilities:any = node.componentInstance.capabilities; + _.forEach(capabilities, (capabilityValue:Array<any>, capabilityKey)=> { + _.forEach(capabilityValue, (capability)=> { + if (MatchCapabilitiesRequirementsUtils.isMatch(requirement, capability)) { + res.push(node); + } + }); + }); + if (linkCapability) { + let linkRequirements = node.componentInstance.requirements; + _.forEach(linkRequirements, (value:Array<any>, key)=> { + _.forEach(value, (linkRequirement)=> { + if (!MatchCapabilitiesRequirementsUtils.requirementFulfilled(node.componentInstance.uniqueId, linkRequirement, links) + && MatchCapabilitiesRequirementsUtils.linkable(requirement, linkRequirement, linkCapability[0])) { + res.push(node); + } + }); + }); + } + } + }); + } + }); + }); + } + + return _.uniq(res); + }; +} + +MatchCapabilitiesRequirementsUtils.$inject = []; diff --git a/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts new file mode 100644 index 0000000000..5ad6570013 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.directive.ts @@ -0,0 +1,122 @@ +import {Component, Module, NodesFactory, ComponentInstance} from "app/models"; +import {ComponentInstanceFactory} from "app/utils"; +import {DeploymentGraphGeneralUtils} from "./deployment-utils/deployment-graph-general-utils"; +import {CommonGraphUtils} from "../common/common-graph-utils"; +import {ComponentInstanceNodesStyle} from "../common/style/component-instances-nodes-style"; +import {ModulesNodesStyle} from "../common/style/module-node-style"; +import {GRAPH_EVENTS} from "app/utils"; +import {EventListenerService} from "app/services"; +import 'cytoscape-expand-collapse'; + +interface IDeploymentGraphScope extends ng.IScope { + component:Component; +} + +export class DeploymentGraph implements ng.IDirective { + private _cy:Cy.Instance; + + constructor(private NodesFactory:NodesFactory, private commonGraphUtils:CommonGraphUtils, + private deploymentGraphGeneralUtils:DeploymentGraphGeneralUtils, private ComponentInstanceFactory:ComponentInstanceFactory, private eventListenerService:EventListenerService) { + } + + restrict = 'E'; + template = require('./deployment-graph.html'); + scope = { + component: '=', + isViewOnly: '=' + }; + + link = (scope:IDeploymentGraphScope, el:JQuery) => { + + if (scope.component.isResource()) { + if (scope.component.componentInstances && scope.component.componentInstancesRelations && scope.component.groups) { + this.loadGraph(scope, el); + } else { + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DEPLOYMENT_GRAPH_DATA_LOADED, () => { + this.loadGraph(scope, el); + }); + } + } + }; + + + public initGraphNodes = (cy:Cy.Instance, component:Component):void => { + if (component.groups) { // Init module nodes + _.each(component.groups, (groupModule:Module) => { + let moduleNode = this.NodesFactory.createModuleNode(groupModule); + this.commonGraphUtils.addNodeToGraph(cy, moduleNode); + + }); + } + _.each(component.componentInstances, (instance:ComponentInstance) => { // Init component instance nodes + let componentInstanceNode = this.NodesFactory.createNode(instance); + componentInstanceNode.parent = this.deploymentGraphGeneralUtils.findInstanceModule(component.groups, instance.uniqueId); + if (componentInstanceNode.parent) { // we are not drawing instances that are not a part of a module + this.commonGraphUtils.addComponentInstanceNodeToGraph(cy, componentInstanceNode); + } + }); + + // This is a special functionality to pass the cytoscape default behavior - we can't create Parent module node without children's + // so we must add an empty dummy child node + _.each(this._cy.nodes('[?isGroup]'), (moduleNode:Cy.CollectionFirstNode) => { + if (!moduleNode.isParent()) { + let dummyInstance = this.ComponentInstanceFactory.createEmptyComponentInstance(); + let componentInstanceNode = this.NodesFactory.createNode(dummyInstance); + componentInstanceNode.parent = moduleNode.id(); + let dummyNode = this.commonGraphUtils.addNodeToGraph(cy, componentInstanceNode, moduleNode.position()); + dummyNode.addClass('dummy-node'); + } + }) + }; + + private registerGraphEvents() { + + this._cy.on('afterExpand', (event) => { + event.cyTarget.qtip({}); + }); + + this._cy.on('afterCollapse', (event) => { + this.commonGraphUtils.initNodeTooltip(event.cyTarget); + }); + } + + private loadGraph = (scope:IDeploymentGraphScope, el:JQuery) => { + + let graphEl = el.find('.sdc-deployment-graph-wrapper'); + this._cy = cytoscape({ + container: graphEl, + style: ComponentInstanceNodesStyle.getCompositionGraphStyle().concat(ModulesNodesStyle.getModuleGraphStyle()), + zoomingEnabled: false, + selectionType: 'single', + + }); + + //adding expand collapse extension + this._cy.expandCollapse({ + layoutBy: { + name: "grid", + animate: true, + randomize: false, + fit: true + }, + fisheye: false, + undoable: false, + expandCollapseCueSize: 18, + expandCueImage: '/assets/styles/images/resource-icons/' + 'closeModule.png', + collapseCueImage: '/assets/styles/images/resource-icons/' + 'openModule.png', + expandCollapseCueSensitivity: 2, + cueOffset: -20 + }); + + this.initGraphNodes(this._cy, scope.component); //creating instances nodes + this.commonGraphUtils.initGraphLinks(this._cy, scope.component.componentInstancesRelations); + this._cy.collapseAll(); + this.registerGraphEvents(); + }; + + public static factory = (NodesFactory:NodesFactory, CommonGraphUtils:CommonGraphUtils, DeploymentGraphGeneralUtils:DeploymentGraphGeneralUtils, ComponentInstanceFactory:ComponentInstanceFactory, EventListenerService:EventListenerService) => { + return new DeploymentGraph(NodesFactory, CommonGraphUtils, DeploymentGraphGeneralUtils, ComponentInstanceFactory, EventListenerService) + } +} + +DeploymentGraph.factory.$inject = ['NodesFactory', 'CommonGraphUtils', 'DeploymentGraphGeneralUtils', 'ComponentInstanceFactory', 'EventListenerService']; diff --git a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.html b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.html index 55e1c131f4..56c2d8b200 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.html +++ b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.html @@ -1,2 +1,2 @@ <div class="sdc-deployment-graph-wrapper" ng-class="{'view-only':isViewOnly}"> -</div>
\ No newline at end of file +</div> diff --git a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.less b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.less index ff8fc46380..f83ee8a891 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/deployment-graph/deployment-graph.less +++ b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-graph.less @@ -11,4 +11,4 @@ deployment-graph { .view-only{ background-color:rgb(248, 248, 248); } -}
\ No newline at end of file +} diff --git a/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts new file mode 100644 index 0000000000..368455cb24 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils.ts @@ -0,0 +1,22 @@ +import {Module} from "app/models"; +/** + * Created by obarda on 12/21/2016. + */ + +export class DeploymentGraphGeneralUtils { + + constructor() { + + } + + public findInstanceModule = (groupsArray:Array<Module>, componentInstanceId:string):string => { + let parentGroup:Module = _.find(groupsArray, (group:Module) => { + return _.find(group.members, (member) => { + return member === componentInstanceId; + }); + }); + return parentGroup ? parentGroup.uniqueId : ""; + }; +} + +DeploymentGraphGeneralUtils.$inject = []; diff --git a/catalog-ui/src/app/directives/graphs-v2/image-creator/image-creator.service.ts b/catalog-ui/src/app/directives/graphs-v2/image-creator/image-creator.service.ts new file mode 100644 index 0000000000..1bafb2f32b --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/image-creator/image-creator.service.ts @@ -0,0 +1,45 @@ +'use strict'; +export class ImageCreatorService { + static '$inject' = ['$q']; + private _canvas:HTMLCanvasElement; + + constructor(private $q:ng.IQService) { + this._canvas = <HTMLCanvasElement>$('<canvas>')[0]; + this._canvas.setAttribute('style', 'display:none'); + + let body = document.getElementsByTagName('body')[0]; + body.appendChild(this._canvas); + } + + getImageBase64(imageBaseUri:string, imageLayerUri:string):ng.IPromise<string> { + let deferred = this.$q.defer(); + let imageBase = new Image(); + let imageLayer = new Image(); + let imagesLoaded = 0; + let onImageLoaded = () => { + imagesLoaded++; + + if (imagesLoaded < 2) { + return; + } + this._canvas.setAttribute('width', imageBase.width.toString()); + this._canvas.setAttribute('height', imageBase.height.toString()); + + let canvasCtx = this._canvas.getContext('2d'); + canvasCtx.clearRect(0, 0, this._canvas.width, this._canvas.height); + + canvasCtx.drawImage(imageBase, 0, 0, imageBase.width, imageBase.height); + canvasCtx.drawImage(imageLayer, imageBase.width - imageLayer.width, 0, imageLayer.width, imageLayer.height); + + let base64Image = this._canvas.toDataURL(); + deferred.resolve(base64Image); + }; + + imageBase.onload = onImageLoaded; + imageLayer.onload = onImageLoaded; + imageBase.src = imageBaseUri; + imageLayer.src = imageLayerUri; + + return deferred.promise; + } +} diff --git a/catalog-ui/app/scripts/directives/graphs-v2/palette/interfaces/i-dragdrop-event.d.ts b/catalog-ui/src/app/directives/graphs-v2/palette/interfaces/i-dragdrop-event.d.ts index 26c042611c..26c042611c 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/palette/interfaces/i-dragdrop-event.d.ts +++ b/catalog-ui/src/app/directives/graphs-v2/palette/interfaces/i-dragdrop-event.d.ts diff --git a/catalog-ui/src/app/directives/graphs-v2/palette/palette.directive.ts b/catalog-ui/src/app/directives/graphs-v2/palette/palette.directive.ts new file mode 100644 index 0000000000..4bfbe5270e --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/palette/palette.directive.ts @@ -0,0 +1,349 @@ +import { + Component, + IAppMenu, + LeftPanelModel, + NodesFactory, + LeftPaletteComponent, + CompositionCiNodeBase, + ComponentInstance +} from "app/models"; +import {CompositionGraphGeneralUtils} from "../composition-graph/utils/composition-graph-general-utils"; +import {EventListenerService} from "app/services"; +import {ResourceType, GRAPH_EVENTS, EVENTS, ComponentInstanceFactory, ModalsHandler} from "app/utils"; +import 'angular-dragdrop'; +import {LeftPaletteLoaderService} from "../../../services/components/utils/composition-left-palette-service"; + +interface IPaletteScope { + components:Array<LeftPaletteComponent>; + currentComponent:Component; + model:any; + displaySortedCategories:any; + expandedSection:string; + dragElement:JQuery; + dragbleNode:{ + event:JQueryEventObject, + components:LeftPaletteComponent, + ui:any + } + + sectionClick:(section:string)=>void; + searchComponents:(searchText:string)=>void; + onMouseOver:(displayComponent:LeftPaletteComponent)=>void; + onMouseOut:(displayComponent:LeftPaletteComponent)=>void; + dragStartCallback:(event:JQueryEventObject, ui, displayComponent:LeftPaletteComponent)=>void; + dragStopCallback:()=>void; + onDragCallback:(event:JQueryEventObject) => void; + + setElementTemplate:(e:JQueryEventObject)=>void; + + isOnDrag:boolean; + isDragable:boolean; + isLoading:boolean; + isViewOnly:boolean; +} + +export class Palette implements ng.IDirective { + constructor(private $log:ng.ILogService, + private LeftPaletteLoaderService: LeftPaletteLoaderService, + private sdcConfig, + private ComponentFactory, + private ComponentInstanceFactory:ComponentInstanceFactory, + private NodesFactory:NodesFactory, + private CompositionGraphGeneralUtils:CompositionGraphGeneralUtils, + private EventListenerService:EventListenerService, + private sdcMenu:IAppMenu, + private ModalsHandler:ModalsHandler) { + + } + + private fetchingComponentFromServer:boolean = false; + private nodeHtmlSubstitute:JQuery; + + scope = { + currentComponent: '=', + isViewOnly: '=', + isLoading: '=' + }; + restrict = 'E'; + template = require('./palette.html'); + + link = (scope:IPaletteScope, el:JQuery) => { + this.nodeHtmlSubstitute = $('<div class="node-substitute"><span></span><img /></div>'); + el.append(this.nodeHtmlSubstitute); + this.registerEventListenerForLeftPalette(scope); + // this.LeftPaletteLoaderService.loadLeftPanel(scope.currentComponent.componentType); + + this.initComponents(scope); + this.initEvents(scope); + this.initDragEvents(scope); + this._initExpandedSection(scope, ''); + el.on('$destroy', ()=> { + //remove listener of download event + this.unRegisterEventListenerForLeftPalette(scope); + }); + }; + + private registerEventListenerForLeftPalette = (scope:IPaletteScope):void => { + if (scope.currentComponent.isResource()) { + this.EventListenerService.registerObserverCallback(EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT, () => { + this.updateLeftPanelDisplay(scope); + }); + } + if (scope.currentComponent.isService()) { + this.EventListenerService.registerObserverCallback(EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT, () => { + this.updateLeftPanelDisplay(scope); + }); + } + if (scope.currentComponent.isProduct()) { + this.EventListenerService.registerObserverCallback(EVENTS.PRODUCT_LEFT_PALETTE_UPDATE_EVENT, () => { + this.updateLeftPanelDisplay(scope); + }); + } + }; + + private unRegisterEventListenerForLeftPalette = (scope:IPaletteScope):void => { + if (scope.currentComponent.isResource()) { + this.EventListenerService.unRegisterObserver(EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT); + } + if (scope.currentComponent.isService()) { + this.EventListenerService.unRegisterObserver(EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT); + } + if (scope.currentComponent.isProduct()) { + this.EventListenerService.unRegisterObserver(EVENTS.PRODUCT_LEFT_PALETTE_UPDATE_EVENT); + } + }; + + private leftPanelResourceFilter(resourcesNotAbstract:Array<LeftPaletteComponent>, resourceFilterTypes:Array<string>):Array<LeftPaletteComponent> { + let filterResources = _.filter(resourcesNotAbstract, (component) => { + return resourceFilterTypes.indexOf(component.getComponentSubType()) > -1; + }); + return filterResources; + } + + private initLeftPanel(leftPanelComponents:Array<LeftPaletteComponent>, resourceFilterTypes:Array<string>):LeftPanelModel { + let leftPanelModel = new LeftPanelModel(); + + if (resourceFilterTypes && resourceFilterTypes.length) { + leftPanelComponents = this.leftPanelResourceFilter(leftPanelComponents, resourceFilterTypes); + } + leftPanelModel.numberOfElements = leftPanelComponents && leftPanelComponents.length || 0; + + if (leftPanelComponents && leftPanelComponents.length) { + + let categories:any = _.groupBy(leftPanelComponents, 'mainCategory'); + for (let category in categories) + categories[category] = _.groupBy(categories[category], 'subCategory'); + + leftPanelModel.sortedCategories = categories; + } + return leftPanelModel; + } + + + private initEvents(scope:IPaletteScope) { + /** + * + * @param section + */ + scope.sectionClick = (section:string) => { + if (section === scope.expandedSection) { + scope.expandedSection = ''; + return; + } + scope.expandedSection = section; + }; + + scope.onMouseOver = (displayComponent:LeftPaletteComponent) => { + if (scope.isOnDrag) { + return; + } + scope.isOnDrag = true; + + this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_IN, displayComponent); + this.$log.debug('palette::onMouseOver:: fired'); + // + // if (this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.containsKey(displayComponent.uniqueId)) { + // this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} found in cache`); + // let cacheComponent:Component = this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.getValue(displayComponent.uniqueId); + // + // //TODO: Danny: fire event to highlight matching nodes + // //showMatchingNodes(cacheComponent); + // return; + // } + // + // this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} not found in cache, initiating server get`); + // // This will bring the component from the server including requirements and capabilities + // // Check that we do not fetch many times, because only in the success we add the component to componentRequirementsAndCapabilitiesCaching + // if (this.fetchingComponentFromServer) { + // return; + // } + // + // this.fetchingComponentFromServer = true; + // this.ComponentFactory.getComponentFromServer(displayComponent.componentSubType, displayComponent.uniqueId) + // .then((component:Component) => { + // this.$log.debug(`palette::onMouseOver:: component id ${displayComponent.uniqueId} fetch success`); + // // this.LeftPaletteLoaderService.updateSpecificComponentLeftPalette(component, scope.currentComponent.componentType); + // this.CompositionGraphGeneralUtils.componentRequirementsAndCapabilitiesCaching.setValue(component.uniqueId, component); + // this.fetchingComponentFromServer = false; + // + // //TODO: Danny: fire event to highlight matching nodes + // //showMatchingNodes(component); + // }) + // .catch(() => { + // this.$log.debug('palette::onMouseOver:: component id fetch error'); + // this.fetchingComponentFromServer = false; + // }); + + + }; + + scope.onMouseOut = () => { + scope.isOnDrag = false; + this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_HOVER_OUT); + } + } + + private initComponents(scope:IPaletteScope) { + scope.searchComponents = (searchText:any):void => { + scope.displaySortedCategories = this._searchComponents(searchText, scope.model.sortedCategories); + this._initExpandedSection(scope, searchText); + }; + + scope.isDragable = scope.currentComponent.isComplex(); + this.updateLeftPanelDisplay(scope); + } + + private updateLeftPanelDisplay(scope:IPaletteScope) { + let entityType:string = scope.currentComponent.componentType.toLowerCase(); + let resourceFilterTypes:Array<string> = this.sdcConfig.resourceTypesFilter[entityType]; + scope.components = this.LeftPaletteLoaderService.getLeftPanelComponentsForDisplay(scope.currentComponent.componentType); + scope.model = this.initLeftPanel(scope.components, resourceFilterTypes); + scope.displaySortedCategories = angular.copy(scope.model.sortedCategories); + }; + + private _initExpandedSection(scope:IPaletteScope, searchText:string):void { + if (searchText == '') { + let isContainingCategory:boolean = false; + let categoryToExpand:string; + if (scope.currentComponent && scope.currentComponent.categories && scope.currentComponent.categories[0]) { + categoryToExpand = this.sdcMenu.categoriesDictionary[scope.currentComponent.categories[0].name]; + for (let category in scope.model.sortedCategories) { + if (categoryToExpand == category) { + isContainingCategory = true; + break; + } + } + } + isContainingCategory ? scope.expandedSection = categoryToExpand : scope.expandedSection = 'Generic'; + } + else { + scope.expandedSection = Object.keys(scope.displaySortedCategories).sort()[0]; + } + }; + + private initDragEvents(scope:IPaletteScope) { + scope.dragStartCallback = (event:IDragDropEvent, ui, displayComponent:LeftPaletteComponent):void => { + if (scope.isLoading || !scope.isDragable || scope.isViewOnly) { + return; + } + + let component = _.find(this.LeftPaletteLoaderService.getLeftPanelComponentsForDisplay(scope.currentComponent.componentType), (componentFullData:LeftPaletteComponent) => { + return displayComponent.uniqueId === componentFullData.uniqueId; + }); + this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_START, scope.dragElement, component); + + scope.isOnDrag = true; + + // this.graphUtils.showMatchingNodes(component, myDiagram, scope.sdcConfig.imagesPath); + // document.addEventListener('mousemove', moveOnDocument); + event.dataTransfer.component = component; + }; + + scope.dragStopCallback = () => { + scope.isOnDrag = false; + }; + + scope.onDragCallback = (event:IDragDropEvent):void => { + this.EventListenerService.notifyObservers(GRAPH_EVENTS.ON_PALETTE_COMPONENT_DRAG_ACTION, event); + }; + scope.setElementTemplate = (e) => { + let dragComponent:LeftPaletteComponent = _.find(this.LeftPaletteLoaderService.getLeftPanelComponentsForDisplay(scope.currentComponent.componentType), + (fullComponent:LeftPaletteComponent) => { + return (<any>angular.element(e.currentTarget).scope()).component.uniqueId === fullComponent.uniqueId; + }); + let componentInstance:ComponentInstance = this.ComponentInstanceFactory.createComponentInstanceFromComponent(dragComponent); + let node:CompositionCiNodeBase = this.NodesFactory.createNode(componentInstance); + + // myDiagram.dragFromPalette = node; + this.nodeHtmlSubstitute.find("img").attr('src', node.img); + scope.dragElement = this.nodeHtmlSubstitute.clone().show(); + + return scope.dragElement; + }; + } + + private _searchComponents = (searchText:string, categories:any):void => { + let displaySortedCategories = angular.copy(categories); + if (searchText != '') { + angular.forEach(categories, function (category:any, categoryKey) { + + angular.forEach(category, function (subcategory:Array<LeftPaletteComponent>, subcategoryKey) { + let filteredResources = []; + angular.forEach(subcategory, function (component:LeftPaletteComponent) { + + let resourceFilterTerm:string = component.searchFilterTerms; + if (resourceFilterTerm.indexOf(searchText.toLowerCase()) >= 0) { + filteredResources.push(component); + } + }); + if (filteredResources.length > 0) { + displaySortedCategories[categoryKey][subcategoryKey] = filteredResources; + } + else { + delete displaySortedCategories[categoryKey][subcategoryKey]; + } + }); + if (!(Object.keys(displaySortedCategories[categoryKey]).length > 0)) { + delete displaySortedCategories[categoryKey]; + } + + }); + } + return displaySortedCategories; + }; + + public static factory = ($log, + LeftPaletteLoaderService, + sdcConfig, + ComponentFactory, + ComponentInstanceFactory, + NodesFactory, + CompositionGraphGeneralUtils, + EventListenerService, + sdcMenu, + ModalsHandler) => { + return new Palette($log, + LeftPaletteLoaderService, + sdcConfig, + ComponentFactory, + ComponentInstanceFactory, + NodesFactory, + CompositionGraphGeneralUtils, + EventListenerService, + sdcMenu, + ModalsHandler); + }; +} + +Palette.factory.$inject = [ + '$log', + 'LeftPaletteLoaderService', + 'sdcConfig', + 'ComponentFactory', + 'ComponentInstanceFactory', + 'NodesFactory', + 'CompositionGraphGeneralUtils', + 'EventListenerService', + 'sdcMenu', + 'ModalsHandler' +]; diff --git a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.html b/catalog-ui/src/app/directives/graphs-v2/palette/palette.html index a8dd827927..4b123e5777 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.html +++ b/catalog-ui/src/app/directives/graphs-v2/palette/palette.html @@ -49,11 +49,9 @@ </div> <div class="i-sdc-designer-leftbar-section-content-item-info-text"> Type: {{component.componentSubType}} - <a data-ng-click="openViewerModal(component)" - class="i-sdc-designer-leftbar-section-content-item-info-text-link hand">More</a> </div> </div> </div> </div> </div> -</div>
\ No newline at end of file +</div> diff --git a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.less b/catalog-ui/src/app/directives/graphs-v2/palette/palette.less index 85657a43a5..85657a43a5 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/palette/palette.less +++ b/catalog-ui/src/app/directives/graphs-v2/palette/palette.less diff --git a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.html b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.html index a0a9e4af27..a0a9e4af27 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.html +++ b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.html diff --git a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.less b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.less index dea814dbec..dea814dbec 100644 --- a/catalog-ui/app/scripts/directives/graphs-v2/relation-menu/relation-menu.less +++ b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.less diff --git a/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.ts b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.ts new file mode 100644 index 0000000000..b05385b668 --- /dev/null +++ b/catalog-ui/src/app/directives/graphs-v2/relation-menu/relation-menu.ts @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict' +import {MatchBase, RelationMenuDirectiveObj} from "app/models"; +import {Component} from "../../../models/components/component"; + +export interface IRelationMenuScope extends ng.IScope { + relationMenuDirectiveObj:RelationMenuDirectiveObj; + createRelation:Function; + isLinkMenuOpen:boolean; + hideRelationMatch:Function; + cancel:Function; + + saveRelation(); + showMatch(arr1:Array<MatchBase>, arr2:Array<MatchBase>):boolean; + hasMatchesToShow(matchesObj:MatchBase, selectedMatch:Array<MatchBase>); + updateSelectionText():void; + +} + + +export class RelationMenuDirective implements ng.IDirective { + + constructor(private $filter:ng.IFilterService) { + } + + scope = { + relationMenuDirectiveObj: '=', + isLinkMenuOpen: '=', + createRelation: '&', + cancel: '&' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./relation-menu.html'); + }; + + link = (scope:IRelationMenuScope, element:JQuery, $attr:ng.IAttributes) => { + + scope.saveRelation = ():void=> { + let chosenMatches:Array<any> = _.intersection(scope.relationMenuDirectiveObj.rightSideLink.selectedMatch, scope.relationMenuDirectiveObj.leftSideLink.selectedMatch); + let chosenMatch:MatchBase = chosenMatches[0]; + scope.createRelation()(chosenMatch); + }; + + + scope.hideRelationMatch = () => { + scope.isLinkMenuOpen = false; + scope.cancel(); + }; + + //to show options in link menu + scope.showMatch = (arr1:Array<MatchBase>, arr2:Array<MatchBase>):boolean => { + return !arr1 || !arr2 || _.intersection(arr1, arr2).length > 0; + }; + + //to show requirements/capabilities title + scope.hasMatchesToShow = (matchesObj:MatchBase, selectedMatch:Array<MatchBase>):boolean => { + let result:boolean = false; + _.forEach(matchesObj, (matchesArr:Array<MatchBase>) => { + if (!result) { + result = scope.showMatch(matchesArr, selectedMatch); + } + }); + return result; + }; + + + scope.updateSelectionText = ():void => { + let left:string = scope.relationMenuDirectiveObj.leftSideLink.selectedMatch ? this.$filter('resourceName')(scope.relationMenuDirectiveObj.leftSideLink.selectedMatch[0].getDisplayText('left')) : ''; + let both:string = scope.relationMenuDirectiveObj.leftSideLink.selectedMatch && scope.relationMenuDirectiveObj.rightSideLink.selectedMatch ? ' - ' + + this.$filter('resourceName')(scope.relationMenuDirectiveObj.leftSideLink.selectedMatch[0].requirement.relationship) + ' - ' : ''; + let right:string = scope.relationMenuDirectiveObj.rightSideLink.selectedMatch ? this.$filter('resourceName')(scope.relationMenuDirectiveObj.rightSideLink.selectedMatch[0].getDisplayText('right')) : ''; + scope.relationMenuDirectiveObj.selectionText = left + both + right; + }; + + + } + public static factory = ($filter:ng.IFilterService)=> { + return new RelationMenuDirective($filter); + }; +} + +RelationMenuDirective.factory.$inject = ['$filter']; diff --git a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.html b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.html index 5c2bdcf5f1..5c2bdcf5f1 100644 --- a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.html +++ b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.html diff --git a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.less b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.less index 8811af16a4..cc3e3dc1ec 100644 --- a/catalog-ui/app/scripts/directives/info-tooltip/info-tooltip.less +++ b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.less @@ -13,7 +13,7 @@ left: 2px; } .info-tooltip-content { - box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.5); + box-shadow: 0px 4px 6px 0px rgba(0, 0, 0, 0.5); border: 1px solid @main_color_o; border-radius: 3px; border-top: 3px solid @main_color_a; @@ -34,6 +34,9 @@ margin: 15px; word-break: normal; font-size: 14px; + font-weight: normal; + text-align: left; + line-height: normal; } } } diff --git a/catalog-ui/src/app/directives/info-tooltip/info-tooltip.ts b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.ts new file mode 100644 index 0000000000..63ecdc6091 --- /dev/null +++ b/catalog-ui/src/app/directives/info-tooltip/info-tooltip.ts @@ -0,0 +1,37 @@ +/** + * Created by rcohen on 9/25/2016. + */ +'use strict'; + +export interface IInfoTooltipScope extends ng.IScope { + infoMessageTranslate:string; + direction:string; +} + + +export class InfoTooltipDirective implements ng.IDirective { + + constructor() { + } + + scope = { + infoMessageTranslate: '@', + direction: '@'//get 'right' or 'left', the default is 'right' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./info-tooltip.html'); + }; + + link = (scope:IInfoTooltipScope, element:any, $attr:any) => { + scope.direction = scope.direction || 'right'; + }; + + public static factory = ()=> { + return new InfoTooltipDirective(); + }; +} + +InfoTooltipDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-directive.ts b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-directive.ts new file mode 100644 index 0000000000..221c20d08f --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-directive.ts @@ -0,0 +1,43 @@ +/** + * Created by obarda on 1/8/2017. + */ +'use strict'; + +export interface IInputRowDirective extends ng.IScope { + showDeleteIcon:boolean; +} + + +export class InputRowDirective implements ng.IDirective { + + constructor() { + + } + + scope = { + instanceInputsMap: '=', + input: '=', + instanceName: '=', + instanceId: '=', + isViewOnly: '=', + deleteInput: '&', + onNameClicked: '&', + onCheckboxClicked: '&' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./input-row-view.html'); + }; + + link = (scope:IInputRowDirective, element:any, $attr:any) => { + scope.showDeleteIcon = $attr.deleteInput ? true : false; + }; + + public static factory = ()=> { + return new InputRowDirective(); + }; +} + +InputRowDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-view.html b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-view.html new file mode 100644 index 0000000000..872a26bc27 --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row-view.html @@ -0,0 +1,43 @@ +<div class="input-row"> + <div class="title-text" ng-click="onNameClicked(input)" data-tests-id="inputName_{{input.name}}"> + {{input.name}} + </div> + <div class="flex-container"> + <div class="expand-collapse-inputs-table-icon"></div> + <div class="flex-item"> + <div class="no-overflow"> + <span class="title-text">Description:</span> + <span tooltips tooltip-content="{{input.description}}" data-tests-id="inputDescription_{{input.name}}">{{input.description}}</span> + </div> + <div class="text" tooltips tooltip-content="{{input.defaultValue}}"> + <span class="title-text">Default Value:</span> + <span data-tests-id="inputDefaultValue_{{input.name}}">{{input.defaultValue}}</span> + </div> + </div> + <div class="flex-item "> + <div class="text"> + <span class="title-text">VF Instance:</span> + <span tooltips tooltip-content="{{instanceName}}" data-tests-id="inputInstanceName_{{input.name}}">{{instanceName}}</span> + </div> + <div class="text"> + <span class="title-text">Type:</span> + <span tooltips tooltip-content="{{input.type}}" data-tests-id="inputType_{{input.name}}">{{input.type}} </span> + </div> + </div> + <sdc-checkbox ng-if="instanceInputsMap" + class="input-check-box" + disabled="input.isAlreadySelected || isViewOnly" + sdc-checklist-model="instanceInputsMap[instanceId]" + sdc-checklist-value="input" + sdc-checklist-change="onCheckboxClicked()" + data-tests-id="inputsCheckbox_{{input.name}}" + data-ng-click=" $event.stopPropagation()"></sdc-checkbox> + + <div class="delete" ng-if="showDeleteIcon"> + <span class="sprite-new delete-icon remove-input-icon" + data-ng-class="{'disabled': isViewOnly || input.isDeleteDisabled}" + data-ng-click="deleteInput(input); $event.stopPropagation();" + data-tests-id="deleteInput_{{input.name}}"></span> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row.less b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row.less new file mode 100644 index 0000000000..fa79b45c3c --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/inputs/input-row.less @@ -0,0 +1,54 @@ +&.expanded { + .input-row { + background-color: @tlv_color_v; + } +} + +.input-row { + padding-left: 45px; + background: @tlv_color_t; + border: @main_color_o solid 1px; + align-items: center; + .hand; + margin: 1px 0px 1px 0px; + + &.selected { + background-color: @tlv_color_v; + } + .flex-item { + min-height: 60px; + padding: 0 15px; + } + .input-check-box { + padding-right: 10px; + margin-top: 9px; + } + & > .title-text { + text-align: start; + padding: 4px 35px 0 35px; + } + + .expand-collapse-inputs-table-icon { + margin-top: 15px; + } + + .delete { + width: 50px; + padding: 0; + position: relative; + } + + .remove-input-icon { + position: absolute; + top: 12px; + right: 18px; + } + + .remove-input-icon:hover { + .delete-icon-hover; + } +} + +.input-row:hover { + .bg_j; +} diff --git a/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-directive.ts b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-directive.ts new file mode 100644 index 0000000000..a9ff71cda5 --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-directive.ts @@ -0,0 +1,42 @@ +/** + * Created by obarda on 1/8/2017. + */ +'use strict'; + +export interface IPropertyRowDirective extends ng.IScope { + onNameClicked:Function; + isClickable:boolean; +} + +export class PropertyRowDirective implements ng.IDirective { + + constructor() { + + } + + scope = { + property: '=', + instanceName: '=', + instanceId: '=', + instancePropertiesMap: '=', + onNameClicked: '&', + onCheckboxClicked: '&' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./property-row-view.html'); + }; + + link = (scope:IPropertyRowDirective, element:any, $attr:any) => { + scope.isClickable = $attr.onNameClicked ? true : false; + }; + + public static factory = ()=> { + return new PropertyRowDirective(); + }; + +} + +PropertyRowDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.html b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.html new file mode 100644 index 0000000000..ff82a8b685 --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.html @@ -0,0 +1,26 @@ +<div class="property-row flex-container"> + <div class="flex-item text property-name-container"> + <span class="title-blue-text property-name-text " data-ng-class="{'hand': isClickable}" data-tests-id="propertyName" data-ng-click="onNameClicked(property)" tooltips tooltip-content="{{property.name}}">{{property.name}}</span> + </div> + <div class="flex-item text property-name-container"> + <span class="text instance-name-text" data-tests-id="instanceName" tooltips tooltip-content="{{instanceName}}">{{instanceName}}</span> + </div> + <div class="type-schema-container"> + <div class="text"> + <span tooltips tooltip-content="propertyName_{{property.type}}" data-tests-id="propertyType">{{property.type}}</span> + </div> + </div> + <div class="type-schema-container"> + <div class="text"> + <span tooltips tooltip-content="{{property.schema.property.type}}" data-tests-id="propertySchema">{{property.schema.property.type}} </span> + </div> + </div> + <sdc-checkbox ng-if="instancePropertiesMap" + class="property-check-box" + disabled="property.isAlreadySelected || isViewOnly" + sdc-checklist-model="instancePropertiesMap[instanceId]" + sdc-checklist-value="property" + sdc-checklist-change="onCheckboxClicked()" + data-tests-id="propertyCheckbox_{{property.name}}" + data-ng-click=" $event.stopPropagation()"></sdc-checkbox> +</div> diff --git a/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.less b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.less new file mode 100644 index 0000000000..e25427bda2 --- /dev/null +++ b/catalog-ui/src/app/directives/inputs-and-properties/properties/property-row-view.less @@ -0,0 +1,35 @@ +.property-row { + border-bottom: 1px solid @border_color_d; + padding-left: 10px; + .property-name-container { + display: flex; + flex-grow: 3; + } + + .type-schema-container { + flex-grow: 2; + border-left: 1px solid @border_color_d; + text-align: left; + line-height: 30px; + text-transform: capitalize; + width: 10px; + } + + .property-check-box { + padding-right: 10px; + margin-top: 9px; + } +} + +.property-row:hover { + background-color: @func_color_r; +} + +&.expanded { + .flex-container { + .expand-collapse-inputs-table-icon { + transform: rotate(180deg); + left: 0px; + } + } +} diff --git a/catalog-ui/src/app/directives/invalid-characters/invalid-characters.ts b/catalog-ui/src/app/directives/invalid-characters/invalid-characters.ts new file mode 100644 index 0000000000..20ed71e53f --- /dev/null +++ b/catalog-ui/src/app/directives/invalid-characters/invalid-characters.ts @@ -0,0 +1,51 @@ +'use strict'; + +export class InvalidCharactersDirective implements ng.IDirective { + + constructor() { + } + + require = 'ngModel'; + + link = (scope, elem, attrs, ngModel) => { + + let invalidCharacters = []; + + attrs.$observe('invalidCharacters', (val:string) => { + invalidCharacters = val.split(''); + validate(ngModel.$viewValue); + }); + + let validate:Function = function (value) { + + let valid:boolean = true; + + if (value) { + for (let i = 0; i < invalidCharacters.length; i++) { + if (value.indexOf(invalidCharacters[i]) != -1) { + valid = false; + } + } + } + + ngModel.$setValidity('invalidCharacters', valid); + if (!value) { + ngModel.$setPristine(); + } + return value; + }; + + //For DOM -> model validation + ngModel.$parsers.unshift(validate); + //For model -> DOM validation + ngModel.$formatters.unshift(validate); + + }; + + public static factory = ()=> { + return new InvalidCharactersDirective(); + }; + +} + +InvalidCharactersDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.html b/catalog-ui/src/app/directives/layout/top-nav/top-nav.html index 40b1e86d90..60d3d63855 100644 --- a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.html +++ b/catalog-ui/src/app/directives/layout/top-nav/top-nav.html @@ -1,7 +1,7 @@ <nav class="top-nav"> <div class="asdc-app-title-wrapper"> - <a class="asdc-app-title">SDC</a> <!-- data-ui-sref="dashboard" --> + <a class="asdc-app-title" translate="PROJECT_TITLE"></a> <div class="asdc-version"> v.{{version}}</div> </div> diff --git a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.less b/catalog-ui/src/app/directives/layout/top-nav/top-nav.less index 65021bdc4d..65021bdc4d 100644 --- a/catalog-ui/app/scripts/directives/layout/top-nav/top-nav.less +++ b/catalog-ui/src/app/directives/layout/top-nav/top-nav.less diff --git a/catalog-ui/src/app/directives/layout/top-nav/top-nav.ts b/catalog-ui/src/app/directives/layout/top-nav/top-nav.ts new file mode 100644 index 0000000000..c7208a909a --- /dev/null +++ b/catalog-ui/src/app/directives/layout/top-nav/top-nav.ts @@ -0,0 +1,141 @@ +'use strict'; +import {IAppConfigurtaion, IHostedApplication, IUserProperties} from "app/models"; +import {IUserResourceClass} from "app/services"; +import {MenuItemGroup, MenuItem} from "app/utils"; + +export interface ITopNavScope extends ng.IScope { + topLvlSelectedIndex:number; + hideSearch:boolean; + searchBind:any; + menuModel:Array<MenuItemGroup>; + + topLvlMenu:MenuItemGroup; + goToState(state:string, params:Array<any>):ng.IPromise<boolean>; + menuItemClick:Function; + user:IUserProperties; + version:string; +} + + +export class TopNavDirective implements ng.IDirective { + + constructor(private $filter:ng.IFilterService, + private $state:ng.ui.IStateService, + private $q:ng.IQService, + private userResourceService:IUserResourceClass, + private sdcConfig:IAppConfigurtaion) { + } + + public replace = true; + public restrict = 'E'; + public transclude = false; + + + scope = { + topLvlSelectedIndex: '@?', + hideSearch: '=', + searchBind: '=', + version: '@', + notificationIconCallback: '=', + menuModel: '=?', + }; + + template = ():string => { + return require('./top-nav.html'); + }; + + public link = (scope:ITopNavScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + + let getTopLvlSelectedIndexByState = ():number => { + if (!scope.topLvlMenu.menuItems) { + return 0; + } + + let result = -1; + + //set result to current state + scope.topLvlMenu.menuItems.forEach((item:MenuItem, index:number)=> { + if (item.state === this.$state.current.name) { + result = index; + } + }); + + //if it's a different state , checking previous state param + if (result === -1) { + scope.topLvlMenu.menuItems.forEach((item:MenuItem, index:number)=> { + if (item.state === this.$state.params['previousState']) { + result = index; + } + }); + } + + if (result === -1) { + result = 0; + } + + return result; + }; + + scope.user = this.userResourceService.getLoggedinUser(); + + let tmpArray:Array<MenuItem> = [ + new MenuItem(this.$filter('translate')("TOP_MENU_HOME_BUTTON"), null, "dashboard", "goToState", null, null), + new MenuItem(this.$filter('translate')("TOP_MENU_CATALOG_BUTTON"), null, "catalog", "goToState", null, null) + ]; + + // Only designer can perform onboarding + if (scope.user && scope.user.role === 'DESIGNER') { + tmpArray.push(new MenuItem(this.$filter('translate')("TOP_MENU_ON_BOARD_BUTTON"), null, "onboardVendor", "goToState", null, null)); + _.each(this.sdcConfig.hostedApplications, (hostedApp:IHostedApplication)=> { + if (hostedApp.exists) { + tmpArray.push(new MenuItem(hostedApp.navTitle, null, hostedApp.defaultState, "goToState", null, null)); + } + }); + } + + scope.topLvlMenu = new MenuItemGroup(0, tmpArray, true); + scope.topLvlMenu.selectedIndex = isNaN(scope.topLvlSelectedIndex) ? getTopLvlSelectedIndexByState() : scope.topLvlSelectedIndex; + + let generateMenu = () => { + if (scope.menuModel && scope.menuModel[0] !== scope.topLvlMenu) { + scope.menuModel.unshift(scope.topLvlMenu); + } + }; + scope.$watch('menuModel', generateMenu); + + generateMenu(); + + /////scope functions//// + + scope.goToState = (state:string, params:Array<any>):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + this.$state.go(state, params && params.length > 0 ? [0] : undefined); + deferred.resolve(true); + return deferred.promise; + }; + + scope.menuItemClick = (itemGroup:MenuItemGroup, item:MenuItem) => { + + itemGroup.itemClick = false; + + let onSuccess = ():void => { + itemGroup.selectedIndex = itemGroup.menuItems.indexOf(item); + }; + let onFailed = ():void => { + }; + + if (item.callback) { + (item.callback.apply(undefined, item.params)).then(onSuccess, onFailed); + } else { + scope[item.action](item.state, item.params).then(onSuccess, onFailed); + } + }; + }; + + public static factory = ($filter:ng.IFilterService, $state:ng.ui.IStateService, $q:ng.IQService, userResourceService:IUserResourceClass, sdcConfig:IAppConfigurtaion)=> { + return new TopNavDirective($filter, $state, $q, userResourceService, sdcConfig); + }; + +} + +TopNavDirective.factory.$inject = ['$filter', '$state', '$q', 'Sdc.Services.UserResourceService', 'sdcConfig']; diff --git a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.html b/catalog-ui/src/app/directives/layout/top-progress/top-progress.html index ab2c8e364e..ab2c8e364e 100644 --- a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.html +++ b/catalog-ui/src/app/directives/layout/top-progress/top-progress.html diff --git a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.less b/catalog-ui/src/app/directives/layout/top-progress/top-progress.less index acce826f80..ce70bd7378 100644 --- a/catalog-ui/app/scripts/directives/layout/top-progress/top-progress.less +++ b/catalog-ui/src/app/directives/layout/top-progress/top-progress.less @@ -3,6 +3,8 @@ .sdc-progress-title { .n_12_r; + height: 17px; + display: block; .progress-percentage { float: right; diff --git a/catalog-ui/src/app/directives/layout/top-progress/top-progress.ts b/catalog-ui/src/app/directives/layout/top-progress/top-progress.ts new file mode 100644 index 0000000000..06beb43ea1 --- /dev/null +++ b/catalog-ui/src/app/directives/layout/top-progress/top-progress.ts @@ -0,0 +1,36 @@ +'use strict'; + +export interface ITopProgressScope extends ng.IScope { + progressValue:number; + progressMessage:string; +} + +export class TopProgressDirective implements ng.IDirective { + + constructor() { + } + + public replace = true; + public restrict = 'E'; + public transclude = false; + + scope = { + progressValue: '=', + progressMessage: '=' + }; + + template = ():string => { + return require('./top-progress.html'); + }; + + public link = (scope:ITopProgressScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + + }; + + public static factory = ()=> { + return new TopProgressDirective(); + }; + +} + +TopProgressDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/loader/loader-directive.html b/catalog-ui/src/app/directives/loader/loader-directive.html index e40b059a57..e40b059a57 100644 --- a/catalog-ui/app/scripts/directives/loader/loader-directive.html +++ b/catalog-ui/src/app/directives/loader/loader-directive.html diff --git a/catalog-ui/app/scripts/directives/loader/loader-directive.less b/catalog-ui/src/app/directives/loader/loader-directive.less index ae0b41aab1..ae0b41aab1 100644 --- a/catalog-ui/app/scripts/directives/loader/loader-directive.less +++ b/catalog-ui/src/app/directives/loader/loader-directive.less diff --git a/catalog-ui/src/app/directives/loader/loader-directive.ts b/catalog-ui/src/app/directives/loader/loader-directive.ts new file mode 100644 index 0000000000..aa9c4b09c4 --- /dev/null +++ b/catalog-ui/src/app/directives/loader/loader-directive.ts @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {EVENTS} from "app/utils"; +import {EventListenerService} from "app/services"; + +export interface ILoaderScope extends ng.IScope { + display:boolean; // Toggle show || hide scroll + size:string; // small || medium || large + elementSelector:string; // Jquery selector to hide and scroll inside + relative:boolean; // Will use the parent of <loader> element and hide it and scroll inside + loaderType:string; +} + +export class LoaderDirective implements ng.IDirective { + + constructor(private EventListenerService:EventListenerService) { + } + + /* + * relative is used when inserting the HTML loader inside some div <loader data-display="isLoading" relative="true"></loader> + * elementSelector when we want to pass the Jquery selector of the loader. + */ + scope = { + display: '=', + size: '@?', + elementSelector: '@?', + relative: '=?', + loaderType: '@?' + }; + + public replace = false; + public restrict = 'E'; + template = ():string => { + return require('./loader-directive.html'); + } + + link = (scope:ILoaderScope, element:any) => { + + let interval; + + this.EventListenerService.registerObserverCallback(EVENTS.SHOW_LOADER_EVENT, (loaderType)=> { + if (scope.loaderType !== loaderType) { + return; + } + scope.display = true; + }); + this.EventListenerService.registerObserverCallback(EVENTS.HIDE_LOADER_EVENT, (loaderType)=> { + if (scope.loaderType !== loaderType) { + return; + } + scope.display = false; + }); + + let calculateSizesForFixPosition = (positionStyle:string):void => { + // This is problematic, I do not want to change the parent position. + // set the loader on all the screen + let parentPosition = element.parent().position(); + let parentWidth = element.parent().width(); + let parentHeight = element.parent().height(); + element.css('position', positionStyle); + element.css('top', parentPosition.top); + element.css('left', parentPosition.left); + element.css('width', parentWidth); + element.css('height', parentHeight); + }; + + let setStyle = (positionStyle:string):void => { + + switch (positionStyle) { + case 'absolute': + case 'fixed': + // The parent size is not set yet, still loading, so need to use interval to update the size. + interval = window.setInterval(()=> { + calculateSizesForFixPosition(positionStyle); + }, 2000); + break; + default: + // Can change the parent position to relative without causing style issues. + element.parent().css('position', 'relative'); + break; + } + }; + + // This should be executed after the dom loaded + window.setTimeout(():void => { + + element.css('display', 'none'); + + if (scope.elementSelector) { + let elemParent = angular.element(scope.elementSelector); + let positionStyle:string = elemParent.css('position'); + setStyle(positionStyle); + } + + if (scope.relative === true) { + let positionStyle:string = element.parent().css('position'); + setStyle(positionStyle); + } + + if (!scope.size) { + scope.size = 'large'; + } + + }, 0); + + if (scope.elementSelector) { + + } + + function cleanUp() { + clearInterval(interval); + } + + scope.$watch("display", (newVal, oldVal) => { + element.css('display', 'none'); + if (newVal === true) { + window.setTimeout(():void => { + element.css('display', 'block'); + }, 500); + } else { + window.setTimeout(():void => { + element.css('display', 'none'); + }, 0); + } + }); + + scope.$on('$destroy', cleanUp); + + }; + + public static factory = (EventListenerService:EventListenerService)=> { + return new LoaderDirective( EventListenerService); + }; + +} + +LoaderDirective.factory.$inject = ['EventListenerService']; diff --git a/catalog-ui/app/scripts/directives/modal/sdc-modal.html b/catalog-ui/src/app/directives/modal/sdc-modal.html index a8419f162d..a8419f162d 100644 --- a/catalog-ui/app/scripts/directives/modal/sdc-modal.html +++ b/catalog-ui/src/app/directives/modal/sdc-modal.html diff --git a/catalog-ui/app/scripts/directives/modal/sdc-modal.less b/catalog-ui/src/app/directives/modal/sdc-modal.less index d8dfdbb73b..d8dfdbb73b 100644 --- a/catalog-ui/app/scripts/directives/modal/sdc-modal.less +++ b/catalog-ui/src/app/directives/modal/sdc-modal.less diff --git a/catalog-ui/src/app/directives/modal/sdc-modal.ts b/catalog-ui/src/app/directives/modal/sdc-modal.ts new file mode 100644 index 0000000000..aedc28262f --- /dev/null +++ b/catalog-ui/src/app/directives/modal/sdc-modal.ts @@ -0,0 +1,80 @@ +'use strict'; + +export interface ISdcModalScope extends ng.IScope { + modal:ng.ui.bootstrap.IModalServiceInstance; + hideBackground:string; + ok():void; + close(result:any):void; + cancel(reason:any):void; +} + +export interface ISdcModalButton { + name:string; + css:string; + disabled?:boolean; + callback:Function; +} + +export class SdcModalDirective implements ng.IDirective { + + constructor() { + } + + scope = { + modal: '=', + type: '@', + header: '@', + headerTranslate: '@', + headerTranslateValues: '@', + showCloseButton: '@', + hideBackground: '@', + buttons: '=', + getCloseModalResponse: '=' + }; + + public replace = true; + public restrict = 'E'; + public transclude = true; + + template = ():string => { + return require('./sdc-modal.html'); + }; + + link = (scope:ISdcModalScope, $elem:any) => { + + if (scope.hideBackground === "true") { + $(".modal-backdrop").css('opacity', '0'); + } + + scope.close = function (result:any) { + scope.modal.close(result); + }; + + scope.ok = function () { + scope.modal.close(); + }; + + scope.cancel = function (reason:any) { + if (this.getCloseModalResponse) + scope.modal.dismiss(this.getCloseModalResponse()); + else { + scope.modal.dismiss(); + } + }; + + if (scope.modal) { + scope.modal.result.then(function (selectedItem) { + //$scope.selected = selectedItem; + }, function () { + //console.info('Modal dismissed at: ' + new Date()); + }); + } + } + + public static factory = ()=> { + return new SdcModalDirective(); + }; + +} + +SdcModalDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/perfect-scrollbar/angular-perfect-scrollbar.ts b/catalog-ui/src/app/directives/perfect-scrollbar/angular-perfect-scrollbar.ts new file mode 100644 index 0000000000..914a7049bb --- /dev/null +++ b/catalog-ui/src/app/directives/perfect-scrollbar/angular-perfect-scrollbar.ts @@ -0,0 +1,125 @@ +'use strict'; + +export interface IPerfectScrollerScope extends ng.IScope { + //update(event:string): void; +} + +export class PerfectScrollerDirective implements ng.IDirective { + + constructor(private $parse:any) { + + } + + replace = true; + restrict = 'EA'; + transclude = true; + + template = ():string => { + return '<div><div ng-transclude=""></div></div>'; + }; + + link = ($scope:IPerfectScrollerScope, $elem, $attr) => { + let self = this; + let options = {}; + + let psOptions = [ + 'wheelSpeed', 'wheelPropagation', 'minScrollbarLength', 'useBothWheelAxes', + 'useKeyboard', 'suppressScrollX', 'suppressScrollY', 'scrollXMarginOffset', + 'scrollYMarginOffset', 'includePadding'//, 'onScroll', 'scrollDown' + ]; + + for (let i = 0, l = psOptions.length; i < l; i++) { + let opt = psOptions[i]; + if ($attr[opt] !== undefined) { + options[opt] = self.$parse($attr[opt])(); + } + } + + $scope.$evalAsync(function () { + $elem.perfectScrollbar(options); + let onScrollHandler = self.$parse($attr.onScroll) + $elem.scroll(function () { + let scrollTop = $elem.scrollTop() + let scrollHeight = $elem.prop('scrollHeight') - $elem.height() + $scope.$apply(function () { + onScrollHandler($scope, { + scrollTop: scrollTop, + scrollHeight: scrollHeight + }) + }) + }); + }); + + /* + $scope.update = (event:string): void => { + $scope.$evalAsync(function() { + //if ($attr.scrollDown == 'true' && event != 'mouseenter') { + if (event != 'mouseenter') { + setTimeout(function () { + $($elem).scrollTop($($elem).prop("scrollHeight")); + }, 100); + } + $elem.perfectScrollbar('update'); + }); + }; + */ + + // This is necessary when you don't watch anything with the scrollbar + $elem.bind('mouseenter', function () { + //console.log("mouseenter"); + $elem.perfectScrollbar('update'); + }); + + $elem.bind('mouseleave', function () { + //console.log("mouseleave"); + setTimeout(function () { + $(window).trigger('mouseup'); + $elem.perfectScrollbar('update'); + }, 10); + }); + + $elem.bind('click', function () { + //console.log("click"); + // Wait 500 milliseconds until the collapse finish closing and update. + setTimeout(function () { + $elem.perfectScrollbar('update'); + }, 500); + }); + + /** + * Check if the content of the scroller was changed, and if changed update the scroller. + * Because DOMSubtreeModified event is fire many time (while filling the content), I'm checking that + * there is at least 100 milliseconds between DOMSubtreeModified events to update the scrollbar. + * @type {boolean} + */ + let insideDOMSubtreeModified = false; + $elem.bind('DOMSubtreeModified', function () { + if (insideDOMSubtreeModified == false) { + insideDOMSubtreeModified = true; + setTimeout(function () { + insideDOMSubtreeModified = false; + $elem.perfectScrollbar('update'); + }, 100); + } + }); + + // Possible future improvement - check the type here and use the appropriate watch for non-arrays + if ($attr.refreshOnChange) { + $scope.$watchCollection($attr.refreshOnChange, function () { + $elem.perfectScrollbar('update'); + }); + } + + $elem.bind('$destroy', function () { + $elem.perfectScrollbar('destroy'); + }); + + }; + + public static factory = ($parse:any)=> { + return new PerfectScrollerDirective($parse); + }; + +} + +PerfectScrollerDirective.factory.$inject = ['$parse']; diff --git a/catalog-ui/src/app/directives/print-graph-screen/print-graph-screen.ts b/catalog-ui/src/app/directives/print-graph-screen/print-graph-screen.ts new file mode 100644 index 0000000000..a6e07eefee --- /dev/null +++ b/catalog-ui/src/app/directives/print-graph-screen/print-graph-screen.ts @@ -0,0 +1,190 @@ +'use strict'; +import {IAppMenu, Component, IAppConfigurtaion} from "app/models"; +import {UrlToBase64Service} from "app/services"; + +export interface IPrintGraphScreenScope extends ng.IScope { + entity:Component; +} + + +export class PrintGraphScreenDirective implements ng.IDirective { + + constructor(private $filter:ng.IFilterService, + private sdcMenu:IAppMenu, + private sdcConfig:IAppConfigurtaion, + private urlToBase64Service:UrlToBase64Service) { + } + + scope = { + entity: '=' + }; + restrict = 'A'; + link = (scope:IPrintGraphScreenScope, element:any) => { + + + element.bind('click', function () { + printScreen(); + }); + + + let printScreen = ():void => { + // + // let pdf :any = new jsPDF('landscape', 'mm', 'a4'); + // pdf.setProperties({ + // title: scope.entity.name, + // subject: 'Design Snapshot for ' + scope.entity.name, + // author: scope.entity.creatorFullName, + // keywords: scope.entity.tags.join(', '), + // creator: scope.entity.creatorFullName + // }); + // + // // A4 measures is 210 × 297 millimeters + // let pdfWidth :number = 297, + // pdfHeight :number = 210, + // leftColumnWidth :number = 80; + // + // //left bar background + // pdf.setDrawColor(0); + // pdf.setFillColor(248, 249, 251); + // pdf.rect(0, 0, leftColumnWidth, pdfHeight, 'F'); + // + // //entity name + // pdf.setFontSize(12); + // pdf.setTextColor(38, 61, 77); + // let splitTitle :any = pdf.splitTextToSize(scope.entity.name, 50); + // pdf.text(22, 15 - (splitTitle.length - 1) * 2, splitTitle); + // + // //line + // pdf.setLineWidth(0.2); + // pdf.setDrawColor(208, 209, 213); + // pdf.line(0, 28, leftColumnWidth, 28); + // + // + // pdf.setFontSize(10); + // let properties :any = getPdfProperties(); + // + // let topOffset :number = 39, lines; + // properties.forEach( (item:any) => { + // if (!item.value) { + // return; + // } + // if (item.title === 'Description:') { + // topOffset += 5; + // } + // + // pdf.setTextColor(38, 61, 77); + // pdf.text(5, topOffset, item.title); + // pdf.setTextColor(102, 102, 102); + // lines = pdf.splitTextToSize(item.value, 49); + // pdf.text(5 + item.offset, topOffset, lines[0]); + // if (lines.length > 1) { + // lines = pdf.splitTextToSize(item.value.substring(lines[0].length + 1), 65); + // if (lines.length > 8) { + // lines = lines.slice(0, 7); + // lines[lines.length - 1] += '...'; + // } + // pdf.text(5, topOffset + 4, lines); + // topOffset += 4 * (lines.length); + // } + // + // topOffset += 6; + // }); + // + // + // //another background in case the text was too long + // let declarationLineOffset :number = 176; + // pdf.setDrawColor(0); + // pdf.setFillColor(248, 249, 251); + // pdf.rect(0, declarationLineOffset, leftColumnWidth, pdfHeight - declarationLineOffset, 'F'); + // //line + // pdf.setLineWidth(0.2); + // pdf.setDrawColor(208, 209, 213); + // pdf.line(0, declarationLineOffset, leftColumnWidth, declarationLineOffset); + // + // //declaration + // pdf.setFontSize(10.5); + // pdf.setTextColor(38, 61, 77); + // pdf.text(5, 185, 'Declaration'); + // pdf.setFontSize(9); + // pdf.setTextColor(102, 102, 102); + // pdf.setFontType('bold'); + // pdf.text(5, 190, this.$filter('translate')('PDF_FILE_DECLARATION_BOLD')); + // pdf.setFontType('normal'); + // pdf.text(5, 194, pdf.splitTextToSize(this.$filter('translate')('PDF_FILE_DECLARATION'), 65)); + // + // //entity icon + // let self = this; + // let addEntityIcon:Function = () => { + // let iconPath:string = self.sdcConfig.imagesPath + '/styles/images/'; + // if (scope.entity.isService()) { + // iconPath += 'service-icons/' + scope.entity.icon + '.png'; + // } else { + // iconPath += 'resource-icons/' + scope.entity.icon + '.png'; + // } + // self.urlToBase64Service.downloadUrl(iconPath, (base64string:string):void => { + // if (base64string) { + // pdf.addImage(base64string, 'JPEG', 5, 7, 15, 15); + // } + // pdf.save(scope.entity.name + '.pdf'); + // }); + // }; + // + // //actual snapshop of canvas + // let diagramDiv :any = document.getElementById('myDiagram'); + // let diagram :go.Diagram = go.Diagram.fromDiv(diagramDiv), canvasImg = new Image(); + // diagram.startTransaction('print screen'); + // let canvasImgBase64:any = diagram.makeImageData({ + // //scale: 1, + // size: new go.Size(pdfHeight * 5, NaN), + // background: 'white', + // type: 'image/jpeg' + // }); + // diagramDiv.firstElementChild.toDataURL(); + // diagram.commitTransaction('print screen'); + // + // canvasImg.onload = () => { + // if (canvasImg.height > 0) { + // let canvasImgRatio:number = Math.min((pdfWidth - leftColumnWidth - 15) / canvasImg.width, pdfHeight / canvasImg.height); + // let canvasImgWidth:number = canvasImg.width * canvasImgRatio, + // canvasImgHeight:number = canvasImg.height * canvasImgRatio; + // let canvasImgOffset:number = (pdfHeight - canvasImgHeight) / 2; + // pdf.addImage(canvasImg, 'JPEG', leftColumnWidth, canvasImgOffset, canvasImgWidth, canvasImgHeight); + // + // addEntityIcon(); + // } + // }; + // + // if(canvasImg.src === 'data:,') { //empty canvas + // addEntityIcon(); + // } else { + // canvasImg.src = canvasImgBase64; + // } + }; + + + let getPdfProperties = ():Array<any> => { + // return [ + // {title: this.$filter('translate')('GENERAL_LABEL_TYPE'), value: scope.entity.getComponentSubType(), offset: 10}, + // {title: this.$filter('translate')('GENERAL_LABEL_VERSION'), value: scope.entity.version, offset: 15}, + // {title: this.$filter('translate')('GENERAL_LABEL_CATEGORY'), value: scope.entity.categories.length ? scope.entity.categories[0].name : '', offset: 16}, + // {title: this.$filter('translate')('GENERAL_LABEL_CREATION_DATE'), value: this.$filter('date')(scope.entity.creationDate, 'MM/dd/yyyy'), offset: 24}, + // {title: this.$filter('translate')('GENERAL_LABEL_AUTHOR'), value: scope.entity.creatorFullName, offset: 13}, + // {title: this.$filter('translate')('GENERAL_LABEL_CONTACT_ID'), value: scope.entity.contactId, offset: 41}, + // {title: this.$filter('translate')('GENERAL_LABEL_STATUS'), value: (<any>this.sdcMenu).LifeCycleStatuses[scope.entity.lifecycleState].text, offset: 13}, + // {title: this.$filter('translate')('GENERAL_LABEL_PROJECT_CODE'), value: scope.entity.projectCode, offset: 15}, + // {title: this.$filter('translate')('GENERAL_LABEL_DESCRIPTION'), value: scope.entity.description, offset: 20}, + // {title: this.$filter('translate')('GENERAL_LABEL_TAGS'), value: scope.entity.tags.join(', '), offset: 10} + // ]; + return null; + }; + + + }; + + public static factory = ($filter:ng.IFilterService, sdcMenu:IAppMenu, sdcConfig:IAppConfigurtaion, urlToBase64Service:UrlToBase64Service)=> { + return new PrintGraphScreenDirective($filter, sdcMenu, sdcConfig, urlToBase64Service); + }; + +} + +PrintGraphScreenDirective.factory.$inject = ['$filter', 'sdcMenu', 'sdcConfig', 'Sdc.Services.UrlToBase64Service']; diff --git a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.html b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.html index b4583fd304..b62824d544 100644 --- a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.html +++ b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.html @@ -13,16 +13,17 @@ </div> </div> <!--<div class="property-value">--> - <div data-ng-if="dataTypesService.isDataTypeForDataTypePropertyType(property,types)" class="inner-structure"> + <div data-ng-if="dataTypesService.isDataTypeForDataTypePropertyType(property)" class="inner-structure"> <fields-structure value-obj-ref="(valueObjRef[property.name])" type-name="property.type" parent-form-obj="parentFormObj" fields-prefix-name="fieldsPrefixName+property.name" read-only="readOnly" - default-value="{{currentTypeDefaultValue[property.name]}}" - types="types"></fields-structure> + default-value="{{currentTypeDefaultValue[property.name]}}"> + + </fields-structure> </div> - <div data-ng-if="!dataTypesService.isDataTypeForDataTypePropertyType(property,types)" ng-switch="property.type"> + <div data-ng-if="!dataTypesService.isDataTypeForDataTypePropertyType(property)" ng-switch="property.type"> <div ng-switch-when="map"> <type-map value-obj-ref="valueObjRef[property.name]" schema-property="property.schema.property" @@ -48,13 +49,13 @@ ng-if="!((property.simpleType||property.type) == 'boolean')" data-ng-maxlength="100" data-ng-disabled="readOnly" - maxlength="100" + maxlength="{{(property.simpleType||property.type) == 'integer'? 10 : 100}}" data-ng-model="valueObjRef[property.name]" type="text" name="{{fieldsPrefixName+property.name}}" data-ng-pattern="getValidationPattern((property.simpleType||property.type))" data-ng-model-options="{ debounce: 200 }" - data-ng-change="!parentFormObj[fieldsPrefixName+property.name].$error.pattern && ('integer'==property.type && parentFormObj[fieldsPrefixName+property.name].$setValidity('pattern', validateIntRange(valueObjRef[property.name])) || onValueChange(property.name, (property.simpleType||property.type)))" + data-ng-change="inputOnValueChange(property)" autofocus /> <select class="i-sdc-form-select" data-tests-id="{{fieldsPrefixName+property.name}}" diff --git a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.less b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.less index 5c65fdc9dc..5c65fdc9dc 100644 --- a/catalog-ui/app/scripts/directives/property-types/data-type-fields-structure/data-type-fields-structure.less +++ b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.less diff --git a/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts new file mode 100644 index 0000000000..2506dbe400 --- /dev/null +++ b/catalog-ui/src/app/directives/property-types/data-type-fields-structure/data-type-fields-structure.ts @@ -0,0 +1,154 @@ +/** + * Created by obarda on 1/27/2016. + */ +'use strict'; +import {DataTypesService} from "app/services"; +import { ValidationUtils } from "app/utils"; +import { DataTypePropertyModel } from "app/models/data-type-properties"; +import { DataTypesMap} from "app/models"; + +export interface IDataTypeFieldsStructureScope extends ng.IScope { + parentFormObj:ng.IFormController; + dataTypeProperties:Array<DataTypePropertyModel>; + typeName:string; + valueObjRef:any; + propertyNameValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + currentTypeDefaultValue:any; + types:DataTypesMap; + expandByDefault:boolean; + expand:boolean; + expanded:boolean; + dataTypesService:DataTypesService; + + expandAndCollapse():void; + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + onValueChange(propertyName:string, type:string):void + inputOnValueChange(property:any):void; +} + + +export class DataTypeFieldsStructureDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private PropertyNameValidationPattern:RegExp, + private ValidationUtils:ValidationUtils) { + } + + scope = { + valueObjRef: '=', + typeName: '=', + parentFormObj: '=', + fieldsPrefixName: '=', + readOnly: '=', + defaultValue: '@', + // types: '=', + expandByDefault: '=' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./data-type-fields-structure.html'); + }; + //public types=Utils.Constants.PROPERTY_DATA.TYPES; + + //get data type properties array and return object with the properties and their default value + //(for example: get: [{name:"prop1",defaultValue:1 ...},{name:"prop2", defaultValue:"bla bla" ...}] + // return: {prop1: 1, prop2: "bla bla"} + private getDefaultValue = (dataTypeProperties:Array<DataTypePropertyModel>):any => { + let defaultValue = {}; + for (let i = 0; i < dataTypeProperties.length; i++) { + if (dataTypeProperties[i].type != 'string') { + if (!angular.isUndefined(dataTypeProperties[i].defaultValue)) { + defaultValue[dataTypeProperties[i].name] = JSON.parse(dataTypeProperties[i].defaultValue); + } + } else { + defaultValue[dataTypeProperties[i].name] = dataTypeProperties[i].defaultValue; + } + } + return defaultValue; + }; + + private initDataOnScope = (scope:any, $attr:any):void => { + scope.dataTypesService = this.DataTypesService; + scope.dataTypeProperties = this.DataTypesService.getFirsLevelOfDataTypeProperties(scope.typeName); + if ($attr.defaultValue) { + scope.currentTypeDefaultValue = JSON.parse($attr.defaultValue); + } else { + scope.currentTypeDefaultValue = this.getDefaultValue(scope.dataTypeProperties); + } + + if (!scope.valueObjRef) { + scope.valueObjRef = {}; + } + + _.forEach(scope.currentTypeDefaultValue, (value, key)=> { + if (angular.isUndefined(scope.valueObjRef[key])) { + if (typeof scope.currentTypeDefaultValue[key] == 'object') { + angular.copy(scope.currentTypeDefaultValue[key], scope.valueObjRef[key]); + } else { + scope.valueObjRef[key] = scope.currentTypeDefaultValue[key]; + } + } + }); + }; + + private rerender = (scope:any):void => { + scope.expanded = false; + scope.expand = false; + if (scope.expandByDefault) { + scope.expandAndCollapse(); + } + }; + + link = (scope:IDataTypeFieldsStructureScope, element:any, $attr:any) => { + scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + + scope.$watchCollection('[typeName,fieldsPrefixName]', (newData:any):void => { + this.rerender(scope); + }); + + + scope.expandAndCollapse = ():void => { + if (!scope.expanded) { + this.initDataOnScope(scope, $attr); + scope.expanded = true; + } + scope.expand = !scope.expand; + }; + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + scope.onValueChange = (propertyName:string, type:string):void => { + scope.valueObjRef[propertyName] = !angular.isUndefined(scope.valueObjRef[propertyName]) ? scope.valueObjRef[propertyName] : scope.currentTypeDefaultValue[propertyName]; + if (scope.valueObjRef[propertyName] && type != 'string') { + scope.valueObjRef[propertyName] = JSON.parse(scope.valueObjRef[propertyName]); + } + }; + + scope.inputOnValueChange = (property:any) => { + + let value = !scope.parentFormObj[scope.fieldsPrefixName + property.name].$error.pattern + && ('integer' == property.type && scope.parentFormObj[scope.fieldsPrefixName + property.name].$setValidity('pattern', scope.validateIntRange(scope.valueObjRef[property.name])) + || scope.onValueChange(property.name, (property.simpleType || property.type))); + return value; + } + }; + + public static factory = (DataTypesService:DataTypesService, + PropertyNameValidationPattern:RegExp, + ValidationUtils:ValidationUtils)=> { + return new DataTypeFieldsStructureDirective(DataTypesService, PropertyNameValidationPattern, ValidationUtils); + }; +} + +DataTypeFieldsStructureDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'PropertyNameValidationPattern', 'ValidationUtils']; diff --git a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.html b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.html index 410a24e62b..138e848e59 100644 --- a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.html +++ b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.html @@ -34,7 +34,7 @@ <div class="list-value-items"> <span class="list-value-item" data-ng-repeat="value in valueObjRef track by $index"> {{value}} - <span class="delete-list-item sprite-new small-x-button" data-ng-click="deleteListItem($index)"></span> + <span ng-if="!readOnly" class="delete-list-item sprite-new small-x-button" data-ng-click="deleteListItem($index)"></span> </span> </div> </div> @@ -46,8 +46,7 @@ type-name="schemaProperty.type" parent-form-obj="parentFormObj" fields-prefix-name="fieldsPrefixName+''+$index" - read-only="readOnly" - types="types"></fields-structure> + read-only="readOnly"></fields-structure> </div> <div class="add-btn add-list-item" data-tests-id="add-list-item" data-ng-class="{'disabled': readOnly}" data-ng-click="listNewItem.value='{}';addListItem();">Add</div> diff --git a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.less b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.less index eb4214e135..71263f2642 100644 --- a/catalog-ui/app/scripts/directives/property-types/type-list/type-list-directive.less +++ b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.less @@ -21,9 +21,9 @@ display: inline-block; background-color: @tlv_color_v; margin: 10px 0 0 10px; - padding-left: 8px; + padding: 0 8px; .delete-list-item{ - margin: 0 6px 0 10px; + margin: 0 0 0 2px; .hand; } } diff --git a/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts new file mode 100644 index 0000000000..ac5da2be73 --- /dev/null +++ b/catalog-ui/src/app/directives/property-types/type-list/type-list-directive.ts @@ -0,0 +1,106 @@ +/** + * Created by rcohen on 9/15/2016. + */ +'use strict'; +import {SchemaProperty} from "app/models"; +import {ValidationUtils, PROPERTY_TYPES} from "app/utils"; +import {DataTypesService} from "app/services"; + +export interface ITypeListScope extends ng.IScope { + parentFormObj:ng.IFormController; + schemaProperty:SchemaProperty; + isSchemaTypeDataType:boolean; + valueObjRef:any; + propertyNameValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + listDefaultValue:any; + listNewItem:any; + maxLength:number; + + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + addListItem():void; + deleteListItem(listItemIndex:number):void +} + + +export class TypeListDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private PropertyNameValidationPattern:RegExp, + private ValidationUtils:ValidationUtils) { + } + + scope = { + valueObjRef: '=',//ref to list object in the parent value object + schemaProperty: '=',//get the schema.property object + parentFormObj: '=',//ref to parent form (get angular form object) + fieldsPrefixName: '=',//prefix for form fields names + readOnly: '=',//is form read only + defaultValue: '@',//this list default value + maxLength: '=' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./type-list-directive.html'); + }; + + link = (scope:ITypeListScope, element:any, $attr:any) => { + scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + + //reset valueObjRef when schema type is changed + scope.$watchCollection('schemaProperty.type', (newData:any):void => { + scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); + //insert 1 empty item dt by default + if (scope.isSchemaTypeDataType && (!scope.valueObjRef || !scope.valueObjRef.length)) { + scope.valueObjRef = scope.valueObjRef || []; + scope.valueObjRef.push({}); + } + }); + + //when user brows between properties in "edit property form" + scope.$watchCollection('fieldsPrefixName', (newData:any):void => { + scope.listNewItem = {value: ''}; + + if ($attr.defaultValue) { + scope.listDefaultValue = JSON.parse($attr.defaultValue); + } + }); + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + scope.addListItem = ():void => { + scope.valueObjRef = scope.valueObjRef || []; + let newVal = ((scope.schemaProperty.simpleType || scope.schemaProperty.type) == PROPERTY_TYPES.STRING ? scope.listNewItem.value : JSON.parse(scope.listNewItem.value)); + scope.valueObjRef.push(newVal); + scope.listNewItem.value = ""; + }; + + scope.deleteListItem = (listItemIndex:number):void => { + scope.valueObjRef.splice(listItemIndex, 1); + if (!scope.valueObjRef.length) { + if (scope.listDefaultValue) { + angular.copy(scope.listDefaultValue, scope.valueObjRef); + } + } + }; + }; + + public static factory = (DataTypesService:DataTypesService, + PropertyNameValidationPattern:RegExp, + ValidationUtils:ValidationUtils)=> { + return new TypeListDirective(DataTypesService, PropertyNameValidationPattern, ValidationUtils); + }; +} + +TypeListDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'PropertyNameValidationPattern', 'ValidationUtils']; + diff --git a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.html b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html index ed82b840dc..37b076f26e 100644 --- a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.html +++ b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.html @@ -6,8 +6,10 @@ data-tests-id="mapKey{{fieldsPrefixName}}{{$index}}" data-ng-model="mapKeys[$index]" type="text" + data-ng-maxlength="50" + maxlength="50" name="mapKey{{fieldsPrefixName}}{{$index}}" - data-ng-pattern="propertyNameValidationPattern" + data-ng-pattern="MapKeyValidationPattern" data-ng-model-options="{ debounce: 200 }" data-ng-change="changeKeyOfMap(mapKeys[$index], $index,'mapKey'+fieldsPrefixName+$index);$event.stopPropagation();" data-ng-disabled="readOnly" @@ -16,6 +18,8 @@ <div class="input-error" data-ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$dirty && parentFormObj['mapKey'+fieldsPrefixName+$index].$invalid"> <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.keyExist" translate="PROPERTY_EDIT_MAP_UNIQUE_KEYS"></span> <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Key' }"></span> + <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> + <span ng-show="parentFormObj['mapKey'+fieldsPrefixName+$index].$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> </div> </div> <div data-ng-if="!isSchemaTypeDataType" class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapValue'+fieldsPrefixName+$index].$dirty && parentFormObj['mapValue'+fieldsPrefixName+$index].$invalid)}"> @@ -57,7 +61,6 @@ parent-form-obj="parentFormObj" fields-prefix-name="'mapValue'+fieldsPrefixName+''+$index" read-only="readOnly" - types="types" ></fields-structure> </div> <span ng-click="deleteMapItem($index)" class="delete-map-item" data-tests-id="delete-map-item{{fieldsPrefixName}}{{$index}}" data-ng-class="{'disabled': readOnly}"></span> diff --git a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.less b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.less index 2480b626f2..2480b626f2 100644 --- a/catalog-ui/app/scripts/directives/property-types/type-map/type-map-directive.less +++ b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.less diff --git a/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts new file mode 100644 index 0000000000..a0c9a6c460 --- /dev/null +++ b/catalog-ui/src/app/directives/property-types/type-map/type-map-directive.ts @@ -0,0 +1,143 @@ +/** + * Created by rcohen on 9/15/2016. + */ +'use strict'; +import {ValidationUtils, PROPERTY_TYPES} from "app/utils"; +import {DataTypesService} from "app/services"; +import {SchemaProperty} from "app/models"; + +export interface ITypeMapScope extends ng.IScope { + parentFormObj:ng.IFormController; + schemaProperty:SchemaProperty; + isSchemaTypeDataType:boolean; + valueObjRef:any; + mapKeys:Array<string>;//array of map keys + MapKeyValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + mapDefaultValue:any; + maxLength:number; + + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + changeKeyOfMap(newKey:string, index:number, fieldName:string):void; + deleteMapItem(index:number):void; + addMapItemFields():void; + parseToCorrectType(objectOfValues:any, locationInObj:string, type:string):void; + getNumber(num:number):Array<any>; +} + + +export class TypeMapDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private MapKeyValidationPattern:RegExp, + private ValidationUtils:ValidationUtils, + private $timeout:ng.ITimeoutService) { + } + + scope = { + valueObjRef: '=',//ref to map object in the parent value object + schemaProperty: '=',//get the schema.property object + parentFormObj: '=',//ref to parent form (get angular form object) + fieldsPrefixName: '=',//prefix for form fields names + readOnly: '=',//is form read only + defaultValue: '@',//this map default value + maxLength: '=' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./type-map-directive.html'); + }; + + link = (scope:ITypeMapScope, element:any, $attr:any) => { + scope.MapKeyValidationPattern = this.MapKeyValidationPattern; + + //reset valueObjRef and mapKeys when schema type is changed + scope.$watchCollection('schemaProperty.type', (newData:any):void => { + scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); + if (scope.valueObjRef) { + scope.mapKeys = Object.keys(scope.valueObjRef); + } + }); + + //when user brows between properties in "edit property form" + scope.$watchCollection('fieldsPrefixName', (newData:any):void => { + if (!scope.valueObjRef) { + scope.valueObjRef = {}; + } + scope.mapKeys = Object.keys(scope.valueObjRef); + + if ($attr.defaultValue) { + scope.mapDefaultValue = JSON.parse($attr.defaultValue); + } + }); + + //return dummy array in order to prevent rendering map-keys ng-repeat again when a map key is changed + scope.getNumber = (num:number):Array<any> => { + return new Array(num); + }; + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + scope.changeKeyOfMap = (newKey:string, index:number, fieldName:string):void => { + let oldKey = Object.keys(scope.valueObjRef)[index]; + let existsKeyIndex = Object.keys(scope.valueObjRef).indexOf(newKey); + if (existsKeyIndex > -1 && existsKeyIndex != index) { + scope.parentFormObj[fieldName].$setValidity('keyExist', false); + } else { + scope.parentFormObj[fieldName].$setValidity('keyExist', true); + if (!scope.parentFormObj[fieldName].$invalid) { + let newObj = {}; + angular.forEach(scope.valueObjRef,function(value:any,key:string){ + if(key == oldKey){ + newObj[newKey] = value; + }else{ + newObj[key] = value; + } + }); + scope.valueObjRef = newObj; + } + } + }; + + scope.deleteMapItem = (index:number):void=> { + delete scope.valueObjRef[scope.mapKeys[index]]; + scope.mapKeys.splice(index, 1); + if (!scope.mapKeys.length) {//only when user removes all pairs of key-value fields - put the default + if (scope.mapDefaultValue) { + angular.copy(scope.mapDefaultValue, scope.valueObjRef); + scope.mapKeys = Object.keys(scope.valueObjRef); + } + } + }; + + scope.addMapItemFields = ():void => { + scope.valueObjRef[''] = null; + scope.mapKeys = Object.keys(scope.valueObjRef); + }; + + scope.parseToCorrectType = (objectOfValues:any, locationInObj:string, type:string):void => { + if (objectOfValues[locationInObj] && type != PROPERTY_TYPES.STRING) { + objectOfValues[locationInObj] = JSON.parse(objectOfValues[locationInObj]); + } + } + }; + + public static factory = (DataTypesService:DataTypesService, + MapKeyValidationPattern:RegExp, + ValidationUtils:ValidationUtils, + $timeout:ng.ITimeoutService)=> { + return new TypeMapDirective(DataTypesService, MapKeyValidationPattern, ValidationUtils, $timeout); + }; +} + +TypeMapDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'MapKeyValidationPattern', 'ValidationUtils', '$timeout']; diff --git a/catalog-ui/src/app/directives/punch-out/punch-out.ts b/catalog-ui/src/app/directives/punch-out/punch-out.ts new file mode 100644 index 0000000000..aa15f1f3e9 --- /dev/null +++ b/catalog-ui/src/app/directives/punch-out/punch-out.ts @@ -0,0 +1,80 @@ +'use strict'; +import {IUserProperties, IAppConfigurtaion} from "app/models"; +let PunchOutRegistry = require('third-party/PunchOutRegistry.js'); + +export interface IPunchOutScope extends ng.IScope { + name:string; + data:any; + user:IUserProperties; + onEvent:Function; +} + +export class PunchOutDirective implements ng.IDirective { + + constructor(private sdcConfig:IAppConfigurtaion) { + } + + scope = { + name: '=', + data: '=', + user: '=', + onEvent: '&' + }; + + replace = false; + restrict = 'E'; + + link = (scope:IPunchOutScope, element:ng.IAugmentedJQuery):void => { + // global registry object + let PunchOutRegistry = window['PunchOutRegistry']; + + let render = ():void => { + let cookieConfig = this.sdcConfig.cookie; + let props = { + name: scope.name, + options: { + data: scope.data, + apiRoot: this.sdcConfig.api.root, + apiHeaders: { + userId: { + name: cookieConfig.userIdSuffix, + value: scope.user.userId + }, + userFirstName: { + name: cookieConfig.userFirstName, + value: scope.user.firstName + }, + userLastName: { + name: cookieConfig.userLastName, + value: scope.user.lastName + }, + userEmail: { + name: cookieConfig.userEmail, + value: scope.user.email + } + } + }, + onEvent: (...args) => { + scope.$apply(() => { + scope.onEvent().apply(null, args); + }); + } + }; + PunchOutRegistry.render(props, element[0]); + }; + + let unmount = ():void => { + PunchOutRegistry.unmount(element[0]); + }; + + scope.$watch('data', render); + element.on('$destroy', unmount); + }; + + public static factory = (sdcConfig:IAppConfigurtaion) => { + return new PunchOutDirective(sdcConfig); + }; + +} + +PunchOutDirective.factory.$inject = ['sdcConfig']; diff --git a/catalog-ui/src/app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts b/catalog-ui/src/app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts new file mode 100644 index 0000000000..a41d9c59e4 --- /dev/null +++ b/catalog-ui/src/app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive.ts @@ -0,0 +1,46 @@ +'use strict'; + +export class SdcSingleTabDirective implements ng.IDirective { + + constructor(private $compile:ng.ICompileService, private $parse:ng.IParseService) { + } + + restrict = 'E'; + + link = (scope, elem:any, attrs:any, ctrl:any) => { + if (!elem.attr('inner-sdc-single-tab')) { + let name = this.$parse(elem.attr('ctrl'))(scope); + elem = elem.removeAttr('ctrl'); + elem.attr('inner-sdc-single-tab', name); + this.$compile(elem)(scope); + } + }; + + public static factory = ($compile:ng.ICompileService, $parse:ng.IParseService)=> { + return new SdcSingleTabDirective($compile, $parse); + }; +} + +export class InnerSdcSingleTabDirective implements ng.IDirective { + + constructor() { + } + + scope = { + singleTab: "=", + isViewOnly: "=" + }; + + replace = true; + restrict = 'A'; + controller = '@'; + template = '<div ng-include src="singleTab.templateUrl"></div>'; + + public static factory = ()=> { + return new InnerSdcSingleTabDirective(); + }; +} + +SdcSingleTabDirective.factory.$inject = ['$compile', '$parse']; +InnerSdcSingleTabDirective.factory.$inject = []; + diff --git a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less b/catalog-ui/src/app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less index 8b13789179..8b13789179 100644 --- a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less +++ b/catalog-ui/src/app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less diff --git a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs-directive-view.html b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs-directive-view.html index d51d221922..4dc71b8780 100644 --- a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs-directive-view.html +++ b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs-directive-view.html @@ -11,7 +11,7 @@ </div> </div> </div> - <div class="sdc-single-tab-content" ng-if="isActive"> + <div class="sdc-single-tab-content" ng-show="isActive"> <sdc-single-tab class="sdc-single-tab-content-body" ng-if="selectedTab" ctrl="selectedTab.controller" data-dests-id="selected-tab" single-tab="selectedTab" is-view-only="isViewOnly"></sdc-single-tab> </div> </div> diff --git a/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs-directive.ts b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs-directive.ts new file mode 100644 index 0000000000..1567bfba53 --- /dev/null +++ b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs-directive.ts @@ -0,0 +1,48 @@ +/** + * Created by obarda on 7/28/2016. + */ +'use strict'; +import {Tab} from "app/models"; + +export interface ISdcTabsDirectiveScope extends ng.IScope { + tabs:Array<Tab>; + selectedTab:Tab; + isActive:boolean; + onTabSelected(selectedTab:Tab); +} + +export class SdcTabsDirective implements ng.IDirective { + + constructor() { + } + + scope = { + tabs: "=", + selectedTab: "=?", + isViewOnly: "=" + }; + + replace = true; + restrict = 'E'; + template = ():string => { + return require('./sdc-tabs-directive-view.html'); + }; + + link = (scope:ISdcTabsDirectiveScope) => { + scope.isActive = true; + + if (!scope.selectedTab) { + scope.selectedTab = scope.tabs[0]; + } + + scope.onTabSelected = (selectedTab:Tab) => { + scope.selectedTab = selectedTab; + } + }; + + public static factory = ()=> { + return new SdcTabsDirective(); + }; +} + +SdcTabsDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs.less b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs.less index ad390010ed..15b6fe9e1d 100644 --- a/catalog-ui/app/scripts/directives/sdc-tabs/sdc-tabs.less +++ b/catalog-ui/src/app/directives/sdc-tabs/sdc-tabs.less @@ -1,14 +1,13 @@ .sdc-tabs-body { height: 100%; width: 330px; - position: absolute; .sdc-tabs { display: inline-block; width: 40px; vertical-align: top; position: relative; z-index: 99; - right: 332px; + .sdc-tab-arrow { cursor: pointer; width: 40px; @@ -45,8 +44,8 @@ } .not-active { - // position: absolute; - right: 41px; + position: absolute; + right: 0px; } .sdc-single-tab-content { @@ -59,7 +58,7 @@ top: 0; position: absolute; box-shadow: 0.3px 1px 3px rgba(24, 24, 25, 0.42); - right: 331px; + .sdc-single-tab-content-body { height: 100%; display: flex; diff --git a/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.html b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.html new file mode 100644 index 0000000000..8560e66978 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.html @@ -0,0 +1,81 @@ +<div class="data-type-fields-structure"> + <div class="open-close"> + <div class="open-close-button" data-ng-class="{'expand':expand,'collapse':!expand}" + data-ng-click="expandAndCollapse()"></div> + <span class="data-type-name">{{typeName.replace("org.openecomp.datatypes.heat.","")}}</span> + </div> + <div data-ng-show="expand" data-ng-repeat="property in dataTypeProperties" class="property" data-ng-init="property.isAlreadyInput = isAlreadyInput(property)"> + + <sdc-radio-button sdc-model="dataTypesService.selectedPropertiesName" value="{{path + '#' + property.name}}" data-ng-if="path && !property.isAlreadyInput" + disabled="false" elem-name="selectedPropertiesName" elem-id="{{path + '#' + property.name}}" class="selectPropertyType" + on-value-change="setSelectedType(property)" data-tests-id="propertyRadioButton_{{property.name}}"></sdc-radio-button> + <div class="existInputContainer" data-ng-if="property.isAlreadyInput"><span class="existInput"></span></div> + <div class="i-sdc-form-item property-name"> + <div tooltips tooltip-content="{{property.name}}"> + <input class="i-sdc-form-input" + type="text" + data-ng-disabled="true" + value="{{property.name}}"/> + </div> + </div> + <div data-ng-if="dataTypesService.isDataTypeForDataTypePropertyType(property)" class="inner-structure"> + <select-fields-structure value-obj-ref="(valueObjRef[property.name])" + type-name="property.type" + parent-form-obj="parentFormObj" + fields-prefix-name="fieldsPrefixName+property.name" + read-only="readOnly" + default-value="{{currentTypeDefaultValue[property.name]}}" + path="{{path + '#' + property.name}}" + is-parent-already-input="isParentAlreadyInput" + ></select-fields-structure> + + </div> + <div data-ng-if="!dataTypesService.isDataTypeForDataTypePropertyType(property)" ng-switch="property.type"> + <div ng-switch-when="map"> + <select-type-map value-obj-ref="valueObjRef[property.name]" + schema-property="property.schema.property" + parent-form-obj="parentFormObj" + fields-prefix-name="fieldsPrefixName+property.name" + read-only="readOnly" + default-value="{{currentTypeDefaultValue[property.name]}}" + ></select-type-map> + </div> + <div ng-switch-when="list"> + <select-type-list value-obj-ref="valueObjRef[property.name]" + schema-property="property.schema.property" + parent-form-obj="parentFormObj" + fields-prefix-name="fieldsPrefixName+property.name" + read-only="readOnly" + default-value="{{currentTypeDefaultValue[property.name]}}" + ></select-type-list> + </div> + <div ng-switch-default class="primitive-value-field"> + <div class="i-sdc-form-item" + data-ng-class="{error:(parentFormObj[fieldsPrefixName+property.name].$dirty && parentFormObj[fieldsPrefixName+property.name].$invalid)}"> + <input class="i-sdc-form-input" + data-tests-id="{{fieldsPrefixName+property.name}}" + ng-if="!((property.simpleType||property.type) == 'boolean')" + data-ng-maxlength="100" + data-ng-disabled="readOnly" + maxlength="100" + data-ng-model="valueObjRef[property.name]" + type="text" + name="{{fieldsPrefixName+property.name}}" + data-ng-model-options="{ debounce: 200 }" + data-ng-change="!parentFormObj[fieldsPrefixName+property.name].$error.pattern && ('integer'==property.type && parentFormObj[fieldsPrefixName+property.name].$setValidity('pattern', validateIntRange(valueObjRef[property.name])) || onValueChange(property.name, (property.simpleType||property.type)))" + autofocus/> + <select class="i-sdc-form-select" + data-tests-id="{{fieldsPrefixName+property.name}}" + ng-if="(property.simpleType||property.type) == 'boolean'" + data-ng-disabled="readOnly" + name="{{fieldsPrefixName+property.name}}" + data-ng-change="onValueChange(property.name,'boolean')" + data-ng-model="valueObjRef[property.name]" + data-ng-options="option.v as option.n for option in [{ n: '', v: undefined }, { n: 'false', v: false }, { n: 'true', v: true }]"> + </select> + + </div> + </div> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.less b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.less new file mode 100644 index 0000000000..43d2d646a1 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.less @@ -0,0 +1,117 @@ + +.selectPropertyType { + .tlv-radio-label { + margin-top: -7px; + } +} + +.data-type-fields-structure { + background-color: @tlv_color_v; + padding: 10px; + display: table-caption; + .open-close { + position: relative; + .open-close-button { + position: absolute; + top: 50%; + margin-top: -7px; + &.expand { + .sprite-new; + .expand-collapse-minus-icon; + } + &.collapse { + .sprite-new; + .expand-collapse-plus-icon; + } + } + + } + + .existInputContainer { + height: 30px; + width: 20px; + position: relative; + } + .existInput { + .sprite-new; + .sdc-success; + position: absolute; + top: 18px; + left: 3px; + } + + .data-type-name { + .m_16_m; + margin-left: 22px; + } + + .i-sdc-form-input:disabled{ + .disabled; + &[type="text"]{ + opacity: 1 !important; + background-color: @tlv_color_t; + color:black; + } + } + + .property { + display: flex; + min-width: 365px; + min-height: 46px; + input[type="text"], select { + width: 170px; + } + .property-name { + float: left; + margin-top: 8px; + } + .primitive-value-field { + float: right; + margin-top: 8px; + margin-left: 10px; + } + .inner-structure { + display: -webkit-box; + } + } + + [ng-switch-when="map"] { + margin-top: 8px; + margin-left: 10px; + .map-item { + border: solid 1px @main_color_o; + min-width: 401px; + min-height: 69px; + float: none !important; + } + .add-map-item { + width: auto; + float: none; + &:nth-child(1) { + position: relative; + top: 6px; + } + .add-btn { + float: none; + } + } + + } + + [ng-switch-when="list"] { + float: left; + margin-top: 8px; + margin-left: 10px; + min-width: 280px; + .dt-list-item { + border: solid 1px @main_color_o; + } + .list-value-items { + width: 280px; + } + } +} + + + + diff --git a/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.ts b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.ts new file mode 100644 index 0000000000..aee4b3b6af --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.ts @@ -0,0 +1,184 @@ +/** + * Created by obarda on 1/27/2016. + */ +'use strict'; +import {ValidationUtils} from "app/utils"; +import { DataTypesService } from "app/services"; +import { DataTypePropertyModel } from "app/models/data-type-properties"; +import {DataTypesMap, PropertyModel} from "app/models"; + +export interface ISelectDataTypeFieldsStructureScope extends ng.IScope { + parentFormObj:ng.IFormController; + dataTypeProperties:Array<DataTypePropertyModel>; + typeName:string; + valueObjRef:any; + propertyNameValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + currentTypeDefaultValue:any; + types:DataTypesMap; + expandByDefault:boolean; + expand:boolean; + expanded:boolean; + dataTypesService:DataTypesService; + path:string; + isParentAlreadyInput:boolean; + + expandAndCollapse():void; + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + isAlreadyInput(property:PropertyModel):boolean; + setSelectedType(property:PropertyModel):void; + onValueChange(propertyName:string, type:string):void; +} + + +export class SelectDataTypeFieldsStructureDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private PropertyNameValidationPattern:RegExp, + private ValidationUtils:ValidationUtils) { + } + + scope = { + valueObjRef: '=', + typeName: '=', + parentFormObj: '=', + fieldsPrefixName: '=', + readOnly: '=', + defaultValue: '@', + expandByDefault: '=', + path: '@', + isParentAlreadyInput: '=' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./select-data-type-fields-structure.html'); + }; + // public types=Utils.Constants.PROPERTY_DATA.TYPES; + + //get data type properties array and return object with the properties and their default value + //(for example: get: [{name:"prop1",defaultValue:1 ...},{name:"prop2", defaultValue:"bla bla" ...}] + // return: {prop1: 1, prop2: "bla bla"} + private getDefaultValue = (dataTypeProperties:Array<DataTypePropertyModel>):any => { + let defaultValue = {}; + for (let i = 0; i < dataTypeProperties.length; i++) { + if (dataTypeProperties[i].type != 'string') { + if (!angular.isUndefined(dataTypeProperties[i].defaultValue)) { + defaultValue[dataTypeProperties[i].name] = JSON.parse(dataTypeProperties[i].defaultValue); + } + } else { + defaultValue[dataTypeProperties[i].name] = dataTypeProperties[i].defaultValue; + } + } + return defaultValue; + }; + + private initDataOnScope = (scope:ISelectDataTypeFieldsStructureScope, $attr:any):void => { + scope.dataTypesService = this.DataTypesService; + scope.dataTypeProperties = angular.copy(this.DataTypesService.getFirsLevelOfDataTypeProperties(scope.typeName)); + if ($attr.defaultValue) { + scope.currentTypeDefaultValue = JSON.parse($attr.defaultValue); + } else { + scope.currentTypeDefaultValue = this.getDefaultValue(scope.dataTypeProperties); + } + + if (!scope.valueObjRef) { + scope.valueObjRef = {}; + } + + _.forEach(scope.currentTypeDefaultValue, (value, key)=> { + if (angular.isUndefined(scope.valueObjRef[key])) { + if (typeof scope.currentTypeDefaultValue[key] == 'object') { + angular.copy(scope.currentTypeDefaultValue[key], scope.valueObjRef[key]); + } else { + scope.valueObjRef[key] = scope.currentTypeDefaultValue[key]; + } + } + }); + }; + + private rerender = (scope:any):void => { + scope.expanded = false; + scope.expand = false; + if (scope.expandByDefault) { + scope.expandAndCollapse(); + } + }; + + link = (scope:ISelectDataTypeFieldsStructureScope, element:any, $attr:any) => { + scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + + scope.$watchCollection('[typeName,fieldsPrefixName]', (newData:any):void => { + this.rerender(scope); + }); + + + scope.expandAndCollapse = ():void => { + if (!scope.expanded) { + this.initDataOnScope(scope, $attr); + scope.expanded = true; + } + scope.expand = !scope.expand; + }; + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + /* + check if property is alrady declered on the service by meatching the input name & the property name + + */ + scope.isAlreadyInput = (property:PropertyModel):boolean => { + if (scope.path) { + if (scope.isParentAlreadyInput) { + return true; + } + let parentInputName = this.DataTypesService.selectedInstance.normalizedName + '_' + scope.path.replace('#', '_');// set the input parent as he need to declared as input + let inputName = parentInputName + '_' + property.name;// set the input name as he need to declared as input + let selectedProperty = _.find(this.DataTypesService.selectedComponentInputs, (componentInput)=> { + if (componentInput.name == parentInputName) { //check if the parent(all the complex) is already declared + scope.isParentAlreadyInput = true; + return true; + } else if (componentInput.name.substring(0, inputName.length) == inputName) { //check if specific property inside the complex + return true; + } + //return componentInput.name == parentInputName || componentInput.name.substring(0,inputName.length) == inputName;//check if the parent(all the complex) is already declared or specific property inside the complex + }); + if (selectedProperty) { + return true; + } + } + return false; + }; + + scope.setSelectedType = (property:PropertyModel):void=> { + scope.dataTypesService.selectedInput = property; + scope.dataTypesService.selectedPropertiesName = scope.path + '#' + property.name; + }; + + scope.onValueChange = (propertyName:string, type:string):void => { + scope.valueObjRef[propertyName] = !angular.isUndefined(scope.valueObjRef[propertyName]) ? scope.valueObjRef[propertyName] : scope.currentTypeDefaultValue[propertyName]; + if (scope.valueObjRef[propertyName] && type != 'string') { + scope.valueObjRef[propertyName] = JSON.parse(scope.valueObjRef[propertyName]); + } + }; + + + }; + + public static factory = (DataTypesService:DataTypesService, + PropertyNameValidationPattern:RegExp, + ValidationUtils:ValidationUtils)=> { + return new SelectDataTypeFieldsStructureDirective(DataTypesService, PropertyNameValidationPattern, ValidationUtils); + }; +} + +SelectDataTypeFieldsStructureDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'PropertyNameValidationPattern', 'ValidationUtils']; diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.html b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.html new file mode 100644 index 0000000000..f439147301 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.html @@ -0,0 +1,56 @@ +<div> + <div data-ng-if="!isSchemaTypeDataType"> + <div class="i-sdc-form-item list-new-item" data-ng-class="{error:(parentFormObj['listNewItem'+fieldsPrefixName].$dirty && parentFormObj['listNewItem'+fieldsPrefixName].$invalid)}"> + <input class="i-sdc-form-input" + data-tests-id="listNewItem{{fieldsPrefixName}}" + ng-if="!((schemaProperty.simpleType||schemaProperty.type) == 'boolean')" + data-ng-disabled="readOnly" + data-ng-model="listNewItem.value" + type="text" + name="listNewItem{{fieldsPrefixName}}" + data-ng-model-options="{ debounce: 200 }" + placeholder="Type a value and then click ADD" + data-ng-maxlength="maxLength" + maxlength="{{maxLength}}" + sdc-keyboard-events="" key-enter="schemaProperty.type && !parentFormObj['listNewItem'+fieldsPrefixName].$invalid && listNewItem.value && addListItem" + autofocus /> + <select class="i-sdc-form-select" + data-tests-id="listNewItem{{fieldsPrefixName}}" + ng-if="(schemaProperty.simpleType||schemaProperty.type) == 'boolean'" + data-ng-disabled="readOnly" + name="listNewItem{{fieldsPrefixName}}" + data-ng-model="listNewItem.value"> + <option value="true">true</option> + <option value="false">false</option> + </select> + <div class="input-error" data-ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$dirty && parentFormObj['listNewItem'+fieldsPrefixName].$invalid"> + <span ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span> + <span ng-show="parentFormObj['listNewItem'+fieldsPrefixName].$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span> + </div> + </div> + <!--<div class="add-btn add-list-item" data-tests-id="add-list-item{{fieldsPrefixName}}"--> + <!--data-ng-class="{'disabled': readOnly || !schemaProperty.type || parentFormObj['listNewItem'+fieldsPrefixName].$invalid || !listNewItem.value}" data-ng-click="addListItem()">Add</div>--> + <div class="list-value-items"> + <span class="list-value-item" data-ng-repeat="value in valueObjRef track by $index"> + {{value}} + <span ng-if="!readOnly" class="delete-list-item sprite-new small-x-button" data-ng-click="deleteListItem($index)"></span> + </span> + </div> + </div> + <div data-ng-if="isSchemaTypeDataType"> + <div class="dt-list"> + <div data-ng-repeat="value in valueObjRef track by $index" class="dt-list-item"> + <select-fields-structure value-obj-ref="valueObjRef[$index]" + type-name="schemaProperty.type" + parent-form-obj="parentFormObj" + fields-prefix-name="fieldsPrefixName+''+$index" + read-only="readOnly"> + <!--path="{{path}}"--> + </select-fields-structure> + </div> + <!--<div class="add-btn add-list-item" data-tests-id="add-list-item"--> + <!--data-ng-class="{'disabled': readOnly}" data-ng-click="listNewItem.value='{}';addListItem();">Add</div>--> + </div> + + </div> +</div> diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.less b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.less new file mode 100644 index 0000000000..71263f2642 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.less @@ -0,0 +1,85 @@ +.list-new-item{ + float: left; + width: 50%; + min-width: 221px; + margin-right: 15px; + input{ + min-width: 221px; + } +} + +.list-value-items{ + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; + border: 1px solid @main_color_o; + padding-bottom: 10px; + min-height: 100px; + clear: both; + background-color: white; + .list-value-item{ + display: inline-block; + background-color: @tlv_color_v; + margin: 10px 0 0 10px; + padding: 0 8px; + .delete-list-item{ + margin: 0 0 0 2px; + .hand; + } + } +} + +.add-btn { + .f-color.a; + .f-type._14_m; + .hand; + + &.add-list-item { + float: left; + margin-top: 5px; + width: 44px; + } + + &:before { + .sprite-new; + .plus-icon; + margin-right: 5px; + content: ""; + + } + &:hover { + .f-color.b; + &:before { + .sprite-new; + .plus-icon-hover; + } + } + +} + +.dt-list{ + display: table-caption; + .dt-list-item { + border-radius: 3px; + background-color: @tlv_color_v; + display: inline-block; + .delete-dt-list-item{ + float: right; + position: relative; + top: 5px; + right: 5px; + .sprite-new; + .delete-icon; + &:hover{ + .delete-icon-hover; + } + } + .data-type-name{ + margin-right: 16px; + } + } + &>.add-list-item{ + float:none; + } +} + diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.ts b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.ts new file mode 100644 index 0000000000..d277040798 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-list/select-type-list-directive.ts @@ -0,0 +1,108 @@ +/** + * Created by rcohen on 9/15/2016. + */ +'use strict'; +import {DataTypesService} from "app/services/data-types-service"; +import {SchemaProperty} from "app/models/aschema-property"; +import {ValidationUtils, PROPERTY_TYPES} from "app/utils"; + +export interface ISelectTypeListScope extends ng.IScope { + parentFormObj:ng.IFormController; + schemaProperty:SchemaProperty; + isSchemaTypeDataType:boolean; + valueObjRef:any; + propertyNameValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + listDefaultValue:any; + listNewItem:any; + maxLength:number; + dataTypesService:DataTypesService; + + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + addListItem():void; + deleteListItem(listItemIndex:number):void +} + +export class SelectTypeListDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private PropertyNameValidationPattern:RegExp, + private ValidationUtils:ValidationUtils) { + } + + scope = { + valueObjRef: '=',//ref to list object in the parent value object + schemaProperty: '=',//get the schema.property object + parentFormObj: '=',//ref to parent form (get angular form object) + fieldsPrefixName: '=',//prefix for form fields names + readOnly: '=',//is form read only + defaultValue: '@',//this list default value + maxLength: '=', + path: '@' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./select-type-list-directive.html'); + }; + + link = (scope:ISelectTypeListScope, element:any, $attr:any) => { + scope.dataTypesService = this.DataTypesService; + scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + + //reset valueObjRef when schema type is changed + scope.$watchCollection('schemaProperty.type', (newData:any):void => { + scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); + //insert 1 empty item dt by default + if (scope.isSchemaTypeDataType && (!scope.valueObjRef || !scope.valueObjRef.length)) { + scope.valueObjRef = scope.valueObjRef || []; + scope.valueObjRef.push({}); + } + }); + + //when user brows between properties in "edit property form" + scope.$watchCollection('fieldsPrefixName', (newData:any):void => { + scope.listNewItem = {value: ''}; + + if ($attr.defaultValue) { + scope.listDefaultValue = JSON.parse($attr.defaultValue); + } + }); + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + scope.addListItem = ():void => { + scope.valueObjRef = scope.valueObjRef || []; + let newVal = ((scope.schemaProperty.simpleType || scope.schemaProperty.type) == PROPERTY_TYPES.STRING ? scope.listNewItem.value : JSON.parse(scope.listNewItem.value)); + scope.valueObjRef.push(newVal); + scope.listNewItem.value = ""; + }; + + scope.deleteListItem = (listItemIndex:number):void => { + scope.valueObjRef.splice(listItemIndex, 1); + if (!scope.valueObjRef.length) { + if (scope.listDefaultValue) { + angular.copy(scope.listDefaultValue, scope.valueObjRef); + } + } + }; + }; + + public static factory = (DataTypesService:DataTypesService, + PropertyNameValidationPattern:RegExp, + ValidationUtils:ValidationUtils)=> { + return new SelectTypeListDirective(DataTypesService, PropertyNameValidationPattern, ValidationUtils); + }; +} + +SelectTypeListDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'PropertyNameValidationPattern', 'ValidationUtils']; + diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.html b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.html new file mode 100644 index 0000000000..a56428e5c2 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.html @@ -0,0 +1,56 @@ +<div> + <div data-ng-repeat="i in getNumber(mapKeys.length) track by $index" class="map-item" data-ng-class="{'primitive-value-map':!isSchemaTypeDataType}"> + <div class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapKey'+fieldsPrefixName+$index].$dirty && parentFormObj['mapKey'+fieldsPrefixName+$index].$invalid)}"> + <label class="i-sdc-form-label required">Key</label> + <input class="i-sdc-form-input" + data-tests-id="mapKey{{fieldsPrefixName}}{{$index}}" + data-ng-model="mapKeys[$index]" + type="text" + data-ng-maxlength="50" + maxlength="50" + name="mapKey{{fieldsPrefixName}}{{$index}}" + data-ng-model-options="{ debounce: 200 }" + data-ng-change="changeKeyOfMap(mapKeys[$index], $index,'mapKey'+fieldsPrefixName+$index);$event.stopPropagation();" + data-ng-disabled="readOnly" + data-required + autofocus/> + </div> + <div data-ng-if="!isSchemaTypeDataType" class="i-sdc-form-item map-item-field" data-ng-class="{error:(parentFormObj['mapValue'+fieldsPrefixName+$index].$dirty && parentFormObj['mapValue'+fieldsPrefixName+$index].$invalid)}"> + <label class="i-sdc-form-label required">Value</label> + <input class="i-sdc-form-input" + ng-if="!((schemaProperty.simpleType||schemaProperty.type) == 'boolean')" + data-ng-disabled="readOnly" + data-ng-model="valueObjRef[mapKeys[$index]]" + type="text" + name="mapValue{{fieldsPrefixName}}{{$index}}" + data-tests-id="mapValue{{fieldsPrefixName}}{{$index}}" + data-ng-change="!parentFormObj['mapValue'+fieldsPrefixName+$index].$error.pattern && parseToCorrectType(valueObjRef, key, (schemaProperty.simpleType||schemaProperty.type))" + data-ng-model-options="{ debounce: 200 }" + data-ng-maxlength="maxLength" + maxlength="{{maxLength}}" + data-required + autofocus /> + <select class="i-sdc-form-select" + data-tests-id="mapValue{{fieldsPrefixName}}{{$index}}" + ng-if="(schemaProperty.simpleType||schemaProperty.type) == 'boolean'" + data-ng-disabled="readOnly" + name="mapValue{{fieldsPrefixName}}{{$index}}" + data-ng-model="valueObjRef[mapKeys[$index]]" + data-required> + <option value="true">true</option> + <option value="false">false</option> + </select> + </div> + <div data-ng-if="isSchemaTypeDataType" class="i-sdc-form-item map-item-field"> + <label class="i-sdc-form-label">Value</label> + <select-fields-structure value-obj-ref="valueObjRef[mapKeys[$index]]" + type-name="schemaProperty.type" + parent-form-obj="parentFormObj" + fields-prefix-name="'mapValue'+fieldsPrefixName+''+$index" + read-only="readOnly"> + <!--path="{{path + '#' + mapKeys[$index]}}"--> + </select-fields-structure> + </div> + </div> +</div> + diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.less b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.less new file mode 100644 index 0000000000..2480b626f2 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.less @@ -0,0 +1,83 @@ +.add-map-item{ + &:nth-child(odd){ + float: right; + } + &:nth-child(1){ + float: none; + .add-btn{ + float: none; + } + } + width: 400px; + .add-btn{ + width: 44px; + float: right; + } + &.schema-data-type{ + float:none; + .add-btn{ + float: none; + } + } +} + +.add-btn { + .f-color.a; + .f-type._14_m; + .hand; + + &:before { + .sprite-new; + .plus-icon; + margin-right: 5px; + content: ""; + + } + &:hover { + .f-color.b; + &:before { + .sprite-new; + .plus-icon-hover; + } + } + +} + +.map-item{ + min-width: 389px; + min-height: 65px; + background-color: @tlv_color_v; + border-radius: 3px; + margin-bottom: 8px; + float: left; + display: flex; + &:nth-child(even).primitive-value-map{ + float: right; + } + .delete-map-item { + float: right; + position: relative; + top: 5px; + right: 5px; + .sprite-new; + .delete-icon; + &:hover{ + .delete-icon-hover; + } + } + .map-item-field { + margin: 7px 12px !important; + float: left; + min-width: 170px; + min-height: 50px; + select{ + width:171px; + } + input[type="text"]{ + width: 170px; + } + &>.data-type-fields-structure{ + padding: 0; + } + } +} diff --git a/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.ts b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.ts new file mode 100644 index 0000000000..19df8dfb71 --- /dev/null +++ b/catalog-ui/src/app/directives/select-property-types/select-type-map/select-type-map-directive.ts @@ -0,0 +1,139 @@ +/** + * Created by rcohen on 9/15/2016. + */ +'use strict'; +import {SchemaProperty} from "app/models"; +import {DataTypesService} from "app/services"; +import {ValidationUtils, PROPERTY_TYPES} from "app/utils"; + +export interface ISelectTypeMapScope extends ng.IScope { + parentFormObj:ng.IFormController; + schemaProperty:SchemaProperty; + isSchemaTypeDataType:boolean; + valueObjRef:any; + mapKeys:Array<string>;//array of map keys + MapKeyValidationPattern:RegExp; + fieldsPrefixName:string; + readOnly:boolean; + mapDefaultValue:any; + maxLength:number; + dataTypesService:DataTypesService; + + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + changeKeyOfMap(newKey:string, index:number, fieldName:string):void; + deleteMapItem(index:number):void; + addMapItemFields():void; + parseToCorrectType(objectOfValues:any, locationInObj:string, type:string):void; + getNumber(num:number):Array<any>; +} + + +export class SelectTypeMapDirective implements ng.IDirective { + + constructor(private DataTypesService:DataTypesService, + private MapKeyValidationPattern:RegExp, + private ValidationUtils:ValidationUtils, + private $timeout:ng.ITimeoutService) { + } + + scope = { + valueObjRef: '=',//ref to map object in the parent value object + schemaProperty: '=',//get the schema.property object + parentFormObj: '=',//ref to parent form (get angular form object) + fieldsPrefixName: '=',//prefix for form fields names + readOnly: '=',//is form read only + defaultValue: '@',//this map default value + maxLength: '=', + path: '@' + }; + + restrict = 'E'; + replace = true; + template = ():string => { + return require('./select-type-map-directive.html'); + }; + + link = (scope:ISelectTypeMapScope, element:any, $attr:any) => { + + scope.dataTypesService = this.DataTypesService; + scope.MapKeyValidationPattern = this.MapKeyValidationPattern; + + //reset valueObjRef and mapKeys when schema type is changed + scope.$watchCollection('schemaProperty.type', (newData:any):void => { + scope.isSchemaTypeDataType = this.DataTypesService.isDataTypeForSchemaType(scope.schemaProperty); + if (scope.valueObjRef) { + scope.mapKeys = Object.keys(scope.valueObjRef); + } + }); + + //when user brows between properties in "edit property form" + scope.$watchCollection('fieldsPrefixName', (newData:any):void => { + if (!scope.valueObjRef) { + scope.valueObjRef = {}; + } + scope.mapKeys = Object.keys(scope.valueObjRef); + + if ($attr.defaultValue) { + scope.mapDefaultValue = JSON.parse($attr.defaultValue); + } + }); + + //return dummy array in order to prevent rendering map-keys ng-repeat again when a map key is changed + scope.getNumber = (num:number):Array<any> => { + return new Array(num); + }; + + scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + scope.changeKeyOfMap = (newKey:string, index:number, fieldName:string):void => { + let oldKey = Object.keys(scope.valueObjRef)[index]; + let existsKeyIndex = Object.keys(scope.valueObjRef).indexOf(newKey); + if (existsKeyIndex > -1 && existsKeyIndex != index) { + scope.parentFormObj[fieldName].$setValidity('keyExist', false); + } else { + scope.parentFormObj[fieldName].$setValidity('keyExist', true); + if (!scope.parentFormObj[fieldName].$invalid) { + angular.copy(JSON.parse(JSON.stringify(scope.valueObjRef).replace('"' + oldKey + '":', '"' + newKey + '":')), scope.valueObjRef);//update key + } + } + }; + + scope.deleteMapItem = (index:number):void=> { + delete scope.valueObjRef[scope.mapKeys[index]]; + scope.mapKeys.splice(index, 1); + if (!scope.mapKeys.length) {//only when user removes all pairs of key-value fields - put the default + if (scope.mapDefaultValue) { + angular.copy(scope.mapDefaultValue, scope.valueObjRef); + scope.mapKeys = Object.keys(scope.valueObjRef); + } + } + }; + + scope.addMapItemFields = ():void => { + scope.valueObjRef[''] = null; + scope.mapKeys = Object.keys(scope.valueObjRef); + }; + + scope.parseToCorrectType = (objectOfValues:any, locationInObj:string, type:string):void => { + if (objectOfValues[locationInObj] && type != PROPERTY_TYPES.STRING) { + objectOfValues[locationInObj] = JSON.parse(objectOfValues[locationInObj]); + } + } + }; + + public static factory = (DataTypesService:DataTypesService, + MapKeyValidationPattern:RegExp, + ValidationUtils:ValidationUtils, + $timeout:ng.ITimeoutService)=> { + return new SelectTypeMapDirective(DataTypesService, MapKeyValidationPattern, ValidationUtils, $timeout); + }; +} + +SelectTypeMapDirective.factory.$inject = ['Sdc.Services.DataTypesService', 'MapKeyValidationPattern', 'ValidationUtils', '$timeout']; diff --git a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.html b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.html index 7d8a883b33..7d8a883b33 100644 --- a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.html +++ b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.html diff --git a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.less b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.less index 094c3f70ba..094c3f70ba 100644 --- a/catalog-ui/app/scripts/directives/structure-tree/structure-tree-directive.less +++ b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.less diff --git a/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.ts b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.ts new file mode 100644 index 0000000000..4d6fbee4db --- /dev/null +++ b/catalog-ui/src/app/directives/structure-tree/structure-tree-directive.ts @@ -0,0 +1,195 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {RelationshipModel, Component, ComponentInstance} from "app/models"; +import {Dictionary} from "app/utils"; + + +export interface IStructureTreeScope extends ng.IScope { + + component:Component; + structureTree:StructureTree; +} + +class StructureTree { + + serviceRoot:ResourceInstanceNode; + + constructor(private uniqueId:string, private resourceInstanceName:string, private resourceInstanceIcon:string, private certified:boolean) { + this.serviceRoot = new ResourceInstanceNode(uniqueId, resourceInstanceName, resourceInstanceIcon, certified); + } + +} + +class ResourceInstanceNode { + id:string; + icon:string; + name:string; + resourceInstancesList:Array<ResourceInstanceNode>; + isAlreadyInTree:boolean; + certified:boolean; + + + constructor(private uniqueId:string, private resourceInstanceName:string, private resourceInstanceIcon:string, certified:boolean) { + this.id = uniqueId; + this.name = resourceInstanceName; + this.icon = resourceInstanceIcon; + this.resourceInstancesList = []; + this.isAlreadyInTree = false; + this.certified = certified; + } +} + +export class StructureTreeDirective implements ng.IDirective { + + + constructor() { + } + + scope = { + component: '=', + }; + restrict = 'E'; + template = ():string => { + return require('./structure-tree-directive.html'); + }; + + link = (scope:IStructureTreeScope, $elem:any) => { + + let RESOURCE_INSTANCE_LIST:string = "resourceInstancesChildesList"; + let resourceInstanceMap:Dictionary<string, ResourceInstanceNode>; + let relations:Array<RelationshipModel>; + //************* Start Building Tree Functions *******************// + + //remove unnecessary instances + let initResourceInstanceMap = ():void => { + + resourceInstanceMap = new Dictionary<string, ResourceInstanceNode>(); + + _.forEach(scope.component.componentInstances, (resourceInstance:ComponentInstance)=> { + if (_.some(Object.keys(resourceInstance.capabilities), (key:string)=> { + return 'tosca.capabilities.container' == key.toLowerCase(); + }) || _.some(Object.keys(resourceInstance.requirements), (key:string)=> { + return 'tosca.capabilities.container' == key.toLowerCase(); + })) { + + let isCertified = 0 === (parseFloat(resourceInstance.componentVersion) % 1); + let node:ResourceInstanceNode = new ResourceInstanceNode(resourceInstance.uniqueId, + resourceInstance.name, + resourceInstance.icon, + isCertified); + resourceInstanceMap.setValue(resourceInstance.uniqueId, node); + } + }); + }; + + //remove unnecessary relations + let initRelations = ():void => { + relations = _.filter(scope.component.componentInstancesRelations, (relation:RelationshipModel)=> { + return resourceInstanceMap.containsKey(relation.fromNode) && resourceInstanceMap.containsKey(relation.toNode); + }); + }; + + let buildTree = ():void => { + if (scope.component) { + scope.structureTree = new StructureTree(scope.component.uniqueId, scope.component.name, scope.component.icon, 'CERTIFIED' === scope.component.lifecycleState); + initResourceInstanceMap(); + initRelations(); + + let parentNodesList = _.groupBy(relations, (node:any)=> { + return node.fromNode; + }); + + for (let parent in parentNodesList) { + _.forEach(parentNodesList[parent], (childNode)=> { + parentNodesList[parent][RESOURCE_INSTANCE_LIST] = []; + parentNodesList[parent][RESOURCE_INSTANCE_LIST].push(mergeAllSubtrees(childNode, parentNodesList)); + }); + } + + //add the resourceInstanceList for the service root node + for (let parent in parentNodesList) { + let resourceInstanceNode:ResourceInstanceNode = resourceInstanceMap.getValue(parent); + resourceInstanceNode.resourceInstancesList = parentNodesList[parent]; + resourceInstanceNode.resourceInstancesList = parentNodesList[parent][RESOURCE_INSTANCE_LIST]; + resourceInstanceNode.isAlreadyInTree = true; + scope.structureTree.serviceRoot.resourceInstancesList.push(resourceInstanceNode); + } + + // Add all node that have no connection to the rootNode + resourceInstanceMap.forEach((key:string, value:ResourceInstanceNode) => { + if (!value.isAlreadyInTree) { + scope.structureTree.serviceRoot.resourceInstancesList.push(value); + } + }); + } + }; + + //this recursion is merging all the subtrees + let mergeAllSubtrees = (connectionData:any, parentNodesList:any):ResourceInstanceNode => { + let resourceInstanceNode:ResourceInstanceNode = resourceInstanceMap.getValue(connectionData.toNode); + resourceInstanceNode.isAlreadyInTree = true; + if (parentNodesList[resourceInstanceNode.id]) { + if (parentNodesList[resourceInstanceNode.id][RESOURCE_INSTANCE_LIST]) { + resourceInstanceNode.resourceInstancesList = parentNodesList[resourceInstanceNode.id][RESOURCE_INSTANCE_LIST]; + } + else { + _.forEach(parentNodesList[resourceInstanceNode.id], (children)=> { + resourceInstanceNode.resourceInstancesList.push(mergeAllSubtrees(children, parentNodesList)); + }); + } + delete parentNodesList[resourceInstanceNode.id]; + } + return resourceInstanceNode; + }; + //************* End Building Tree Functions *******************// + + //************* Start Watchers *******************// + scope.$watch('component.name', ():void => { + if (scope.structureTree) + scope.structureTree.serviceRoot.name = scope.component.name; + }); + + scope.$watch('component.icon', ():void => { + if (scope.structureTree) + scope.structureTree.serviceRoot.icon = scope.component.icon; + }); + + scope.$watchCollection('component.componentInstancesRelations', ():void => { + buildTree(); + }); + + scope.$watchCollection('component.componentInstances', ():void => { + buildTree(); + }); + + //************* End Watchers *******************// + + buildTree(); + + }; + + + public static factory = () => { + return new StructureTreeDirective(); + }; +} + +StructureTreeDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/tag/tag-directive.html b/catalog-ui/src/app/directives/tag/tag-directive.html index 28c22a7978..28c22a7978 100644 --- a/catalog-ui/app/scripts/directives/tag/tag-directive.html +++ b/catalog-ui/src/app/directives/tag/tag-directive.html diff --git a/catalog-ui/app/scripts/directives/tag/tag-directive.less b/catalog-ui/src/app/directives/tag/tag-directive.less index f72e366ac6..f72e366ac6 100644 --- a/catalog-ui/app/scripts/directives/tag/tag-directive.less +++ b/catalog-ui/src/app/directives/tag/tag-directive.less diff --git a/catalog-ui/src/app/directives/tag/tag-directive.ts b/catalog-ui/src/app/directives/tag/tag-directive.ts new file mode 100644 index 0000000000..77a26fc6f7 --- /dev/null +++ b/catalog-ui/src/app/directives/tag/tag-directive.ts @@ -0,0 +1,49 @@ +'use strict'; + +export class TagData { + tag:string; + tooltip:string; + id:string; +} + +export interface ITagScope extends ng.IScope { + tagData:TagData; + onDelete:Function; + delete:Function; + hideTooltip:boolean; + hideDelete:boolean; + sdcDisable:boolean; +} + +export class TagDirective implements ng.IDirective { + + constructor() { + } + + scope = { + tagData: '=', + onDelete: '&', + hideTooltip: '=', + hideDelete: '=', + sdcDisable: '=' + }; + + replace = true; + restrict = 'EA'; + template = ():string => { + return require('./tag-directive.html'); + }; + + link = (scope:ITagScope) => { + scope.delete = ()=> { + scope.onDelete({'uniqueId': scope.tagData.id}); + } + }; + + public static factory = ()=> { + return new TagDirective(); + }; + +} + +TagDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.html b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.html index 1c99a18ab5..1c99a18ab5 100644 --- a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.html +++ b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.html diff --git a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.less b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.less index a14db7c6ee..e432581f3b 100644 --- a/catalog-ui/app/scripts/directives/user-header-details/user-header-details-directive.less +++ b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.less @@ -8,7 +8,7 @@ } .w-sdc-header-user-icon { - background: no-repeat url('../../../styles/images/anonymous.jpg'); + background: no-repeat url('/assets/styles/images/anonymous.jpg'); border-radius: 50%; height: 47px; width: 47px; diff --git a/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.ts b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.ts new file mode 100644 index 0000000000..a1a54b0517 --- /dev/null +++ b/catalog-ui/src/app/directives/user-header-details/user-header-details-directive.ts @@ -0,0 +1,52 @@ +'use strict'; +import {User, IUser, IAppConfigurtaion} from "app/models"; +import {IUserResourceClass, IUserResource} from "app/services"; +export interface IUserHeaderDetailsScope extends ng.IScope { + name:string; + role:string; + iconUrl:string; + UserResourceClass:IUserResourceClass; + user:IUser; + sdcConfig:IAppConfigurtaion; + initUser:Function; +} + +export class UserHeaderDetailsDirective implements ng.IDirective { + + constructor(private $http:ng.IHttpService, private sdcConfig:IAppConfigurtaion, private UserResourceClass:IUserResourceClass) { + } + + scope = { + iconUrl: '=?' + }; + + replace = true; + restrict = 'E'; + template = ():string => { + return require('./user-header-details-directive.html'); + }; + + link = (scope:IUserHeaderDetailsScope) => { + + scope.initUser = ():void => { + let defaultUserId:string; + let user:IUserResource = this.UserResourceClass.getLoggedinUser(); + if (!user) { + defaultUserId = this.$http.defaults.headers.common[this.sdcConfig.cookie.userIdSuffix]; + user = this.UserResourceClass.get({id: defaultUserId}, ():void => { + scope.user = new User(user); + }); + } else { + scope.user = new User(user); + } + }; + scope.initUser(); + }; + + public static factory = ($http:ng.IHttpService, sdcConfig:IAppConfigurtaion, UserResourceClass:IUserResourceClass)=> { + return new UserHeaderDetailsDirective($http, sdcConfig, UserResourceClass); + }; + +} + +UserHeaderDetailsDirective.factory.$inject = ['$http', 'sdcConfig', 'Sdc.Services.UserResourceService']; diff --git a/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.html b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.html new file mode 100644 index 0000000000..b351273c08 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.html @@ -0,0 +1,19 @@ +<div class="main-wrap" data-tests-id="list-of-{{title}}"> + <div class="header"> + <div class="title">{{title}}</div> + <div class="buttons"> + <span class="order-by hand sprite-new" + data-ng-show="expandCollapseListData.expandCollapse" + data-ng-class="{'asc':!desc, 'desc':desc }" + data-ng-click="swapOrderBy()"></span> + <span class="search hand sprite-new search-icon" + data-ng-class="{'selected':showSearchBox}" + data-ng-show="expandCollapseListData.expandCollapse" + data-ng-click="showHideSearchBox()"></span> + <span class="hand sprite-new expand-list" + data-ng-class="{'open':expandCollapseListData.expandCollapse}" + data-ng-click="expandCollapseListData.expandCollapse=!expandCollapseListData.expandCollapse"></span> + </div> + </div> + <input type="text" id="list-search-box" class="search-box" data-ng-if="expandCollapseListData.expandCollapse && showSearchBox" data-ng-model="expandCollapseListData.filter" autofocus/> +</div> diff --git a/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.less b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.less new file mode 100644 index 0000000000..2a80f28007 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.less @@ -0,0 +1,43 @@ +.main-wrap{ + text-align: center; + .header{ + background-color: @tlv_color_w; + height: 42px; + border-bottom: 1px solid rgba(0, 159, 219, 0.6); + border-top: 1px solid rgba(0, 159, 219, 0.6); + .title{ + .f-type._14_m; + color: @main_color_l; + font-weight: 400; + line-height: 42px; + padding-left: 18px; + float: left; + } + .buttons{ + float: right; + padding-right: 11px; + line-height: 42px; + span{ + vertical-align: middle; + } + .search,.order-by{ + margin-right: 5px; + } + //temporary/// + .search{ + display: none; + } + ////////////// + } + } + + .search-box{ + border-radius: 2px; + height: 30px; + width:275px; + border: 1px @tlv_color_x solid; + margin: 8px 0; + padding: 0 5px; + } +} + diff --git a/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.ts b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.ts new file mode 100644 index 0000000000..73cb2def0b --- /dev/null +++ b/catalog-ui/src/app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.ts @@ -0,0 +1,66 @@ +/** + * Created by rcohen on 12/5/2016. + */ +'use strict'; + +export class ExpandCollapseListData { + filter:string;//variable for filter text + orderByField:string;//order by field name + expandCollapse:boolean;//boolean param for expand collapse the list +} + +export interface IExpandCollapseListHeaderScope extends ng.IScope { + title:string;//the title on the header + expandCollapseListData:ExpandCollapseListData; + showSearchBox:boolean; + desc:boolean;//order by desc or asc + + swapOrderBy():void; + showHideSearchBox():void; +} + +export class ExpandCollapseListHeaderDirective implements ng.IDirective { + + constructor(private $timeout:ng.ITimeoutService) { + } + + scope = { + title: '@', + expandCollapseListData: '=' + }; + + public replace = false; + public restrict = 'AE'; + public transclude = true; + + template = ():string => { + return require('./expand-collapse-list-header.html'); + }; + + link = (scope:IExpandCollapseListHeaderScope, $elem:any) => { + scope.swapOrderBy = ():void => { + if (scope.expandCollapseListData.orderByField.charAt(0) === '-') { + scope.expandCollapseListData.orderByField = scope.expandCollapseListData.orderByField.substr(1); + } else { + scope.expandCollapseListData.orderByField = '-' + scope.expandCollapseListData.orderByField; + } + scope.desc = !scope.desc; + }; + + scope.showHideSearchBox = ():void => { + scope.showSearchBox = !scope.showSearchBox; + if (scope.showSearchBox) { + this.$timeout(function () { + angular.element("#list-search-box").focus(); + }, 0); + } + }; + }; + + public static factory = ($timeout:ng.ITimeoutService)=> { + return new ExpandCollapseListHeaderDirective($timeout); + }; + +} + +ExpandCollapseListHeaderDirective.factory.$inject = ['$timeout']; diff --git a/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts new file mode 100644 index 0000000000..2a2432fcea --- /dev/null +++ b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collaps-menu-box.ts @@ -0,0 +1,47 @@ +'use strict'; +import {MenuItem, MenuItemGroup} from "app/utils"; + +export interface IExpandCollapseMenuBoxDirectiveScope extends ng.IScope { + menuItemsGroup:MenuItemGroup; + menuTitle:string; + parentScope:ng.IScope; + onMenuItemClick(menuItem:MenuItem):void; +} + +export class ExpandCollapseMenuBoxDirective implements ng.IDirective { + + constructor() { + } + + scope = { + menuTitle: '@', + menuItemsGroup: '=', + parentScope: '=' + }; + + public replace = false; + public restrict = 'AE'; + public transclude = true; + + template = ():string => { + return require('./expand-collapse-menu-box.html'); + }; + + link = (scope:IExpandCollapseMenuBoxDirectiveScope) => { + scope.onMenuItemClick = (menuItem:MenuItem):void => { + let onSuccess = ():void => { + scope.menuItemsGroup.selectedIndex = scope.menuItemsGroup.menuItems.indexOf(menuItem); + }; + let onFailed = ():void => { + }; + scope.parentScope[menuItem.action](menuItem.state).then(onSuccess, onFailed); + } + }; + + public static factory = ()=> { + return new ExpandCollapseMenuBoxDirective(); + }; + +} + +ExpandCollapseMenuBoxDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.html b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.html index bbd7e59e7c..f90f00f230 100644 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.html +++ b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.html @@ -1,11 +1,13 @@ <div class="expand-collapse-menu-box"> <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content" class="expand-collapse-menu-box-title"> - <div class="expand-collapse-menu-box-title-icon"></div> - <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="menuTitle" tooltips tooltip-content="{{menuTitle}}"></span> + <div class="expand-collapse-header"> + <div class="expand-collapse-menu-box-title-icon"></div> + <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="menuTitle" tooltips tooltip-content="{{menuTitle}}"></span> + </div> </expand-collapse> <div class="w-sdc-designer-sidebar-section-content" > - <div class="i-sdc-designer-sidebar-section-content-item expand-collapse-menu-box-item" + <div class="i-sdc-designer-sidebar-section-content-item expand-collapse-menu-box-item second-level" ng-class="{'selected': $index == menuItemsGroup.selectedIndex}" ng-repeat="(key, menuItem) in menuItemsGroup.menuItems track by $index"> <div class="expand-collapse-menu-box-item-text" ng-click="onMenuItemClick(menuItem)" ng-class="{'disabled': menuItem.isDisabled }" data-tests-id="{{menuItem.text}}step" >{{menuItem.text}}</div> </div> diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less index d8ceeaea71..13ec1c99be 100644 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less +++ b/catalog-ui/src/app/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less @@ -1,14 +1,21 @@ .expand-collapse-menu-box { line-height: 20px; - padding: 13px 0px 5px 10px; - background-color: @func_color_r; - margin: 3px 3px 5px 0px; + //padding: 13px 0px 5px 10px; + background-color: @tlv_color_t; + //margin: 3px 3px 5px 0px; + .expand-collapse-header{ + border-bottom: 1px solid @main_color_o; + height: @action_nav_height; + background-color:@main_color_p; + display:flex; + align-items:center; + } .expand-collapse-menu-box-title { .f-type._18_m; - color: @main_color_m; - font-weight: bold; + color: @main_color_a; + //font-weight: bold; .hand; .w-sdc-designer-sidebar-section-title-text{ max-width: 185px; @@ -16,6 +23,7 @@ text-overflow: ellipsis; display: inline-block; white-space: nowrap; + padding: 8px 0; } &.expanded { @@ -31,23 +39,27 @@ margin-right: 6px; transition: .3s all; position: relative; - + vertical-align: text-top; + margin-left: 14px; + vertical-align: 14px; } .w-sdc-designer-sidebar-section-content { overflow: hidden; - padding-top: 13px; + //padding-top: 13px; .expand-collapse-menu-box-item { .hand; padding-left: 14px; - margin: 0px 0px 10px 10px; + //margin: 0px 0px 10px 10px; font-family: @font-omnes-medium; color: @main_color_m; line-height: 18px; &.selected { - padding-left: 10px; - font-weight: bold; - border-left: 4px solid @main_color_a; + //padding-left: 10px; + //font-weight: bold; + //border-left: 4px solid @main_color_a; + background-color: #009fdb; + color: #ffffff; } } diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.html b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.html index a2358ea2b7..a2358ea2b7 100644 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.html +++ b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.html diff --git a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.less b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.less index d0d8fa3251..e6b7b7d516 100644 --- a/catalog-ui/app/scripts/directives/utils/expand-collapse/expand-collapse.less +++ b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.less @@ -8,3 +8,4 @@ text-decoration: underline; text-align: left; } + diff --git a/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.ts b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.ts new file mode 100644 index 0000000000..3993f06036 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/expand-collapse/expand-collapse.ts @@ -0,0 +1,115 @@ +'use strict'; +export interface IExpandCollapseScope extends ng.IScope { + toggle():void; + collapsed:boolean; + expandedSelector:string; + content:string; + isCloseOnInit:boolean; + loadDataFunction:Function; + isLoadingData:boolean; +} + +export class ExpandCollapseDirective implements ng.IDirective { + + constructor() { + } + + scope = { + expandedSelector: '@', + loadDataFunction: '&?', + isCloseOnInit: '=?' + }; + + public replace = false; + public restrict = 'AE'; + public transclude = true; + + template = ():string => { + return require('./expand-collapse.html'); + }; + + link = (scope:IExpandCollapseScope, $elem:any) => { + scope.collapsed = false; + scope.isLoadingData = false; + $elem.addClass('expanded'); + + + if (scope.isCloseOnInit) { + window.setTimeout(function () { + toggle(); + }, 0); + } + // + // $elem.click(function () { + // toggle(); + // }); + $elem.bind('click', function() { + toggle(); + }) + let expand = ():void => { + $elem.addClass('expanded'); + scope.collapsed = false; + + let element = $(scope.expandedSelector)[0]; + let prevWidth = element.style.height; + element.style.height = 'auto'; + let endWidth = getComputedStyle(element).height; + element.style.height = prevWidth; + element.offsetHeight; // force repaint + element.style.transition = 'height .3s ease-in-out'; + element.style.height = endWidth; + element.hidden = false; + element.addEventListener('transitionend', function transitionEnd(event) { + if (event['propertyName'] == 'height') { + element.style.transition = ''; + element.style.height = 'auto'; + element.removeEventListener('transitionend', transitionEnd, false); + } + }, false) + }; + + let collapse = ():void => { + $elem.removeClass('expanded'); + scope.collapsed = true; + + let element = $(scope.expandedSelector)[0]; + element.style.height = getComputedStyle(element).height; + element.style.transition = 'height .5s ease-in-out'; + element.offsetHeight; // force repaint + element.style.height = '0px'; + element.hidden = true; + }; + + let toggle = ():void => { + if (scope.collapsed === true) { + if (scope.loadDataFunction) { + scope.isLoadingData = true; + let onSuccess = () => { + window.setTimeout(function () { + expand(); + scope.isLoadingData = false; + }, 0); + }; + scope.loadDataFunction().then(onSuccess); + } + else { + if (scope.isLoadingData === false) { + expand(); + } + } + + } else { + if (scope.isLoadingData === false) { + collapse(); + } + } + } + + }; + + public static factory = ()=> { + return new ExpandCollapseDirective(); + }; +} + +ExpandCollapseDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts b/catalog-ui/src/app/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts new file mode 100644 index 0000000000..71a963a492 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/sdc-keyboard-events/sdc-keyboard-events.ts @@ -0,0 +1,84 @@ +'use strict'; + +export interface ISdcKeyboardEventsScope extends ng.IScope { + keyEnter:Function; + keyShift:Function; + keyCtrl:Function; + keyEscape:Function; + keySpace:Function; +} + +export class SdcKeyboardEventsDirective implements ng.IDirective { + + constructor() { + } + + scope = { + keyEnter: '=', + keyShift: '=', + keyCtrl: '=', + keyEscape: '=', + keySpace: '=' + }; + + public replace = false; + public restrict = 'A'; + public transclude = false; + + link = (scope:ISdcKeyboardEventsScope, element:ng.IAugmentedJQuery, attrs:angular.IAttributes) => { + + element.bind("keydown keypress", function (event) { + //console.log(event.which); + switch (event.which) { + case 13: // enter key + scope.$apply(function () { + if (scope.keyEnter) { + scope.keyEnter(); + event.preventDefault(); + } + }); + break; + case 16: // shift key + scope.$apply(function () { + if (scope.keyShift) { + scope.keyShift(); + event.preventDefault(); + } + }); + break; + case 17: // ctrl key + scope.$apply(function () { + if (scope.keyCtrl) { + scope.keyCtrl(); + event.preventDefault(); + } + }); + break; + case 27: // escape key + scope.$apply(function () { + if (scope.keyEscape) { + scope.keyEscape(); + event.preventDefault(); + } + }); + break; + case 32: // space key + scope.$apply(function () { + if (scope.keySpace) { + scope.keySpace(); + event.preventDefault(); + } + }); + break; + } + }); + + }; + + public static factory = ()=> { + return new SdcKeyboardEventsDirective(); + }; + +} + +SdcKeyboardEventsDirective.factory.$inject = []; diff --git a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.html b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.html index fb1ada69c3..fb1ada69c3 100644 --- a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.html +++ b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.html diff --git a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.less b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.less index 942196e663..942196e663 100644 --- a/catalog-ui/app/scripts/directives/utils/sdc-tags/sdc-tags.less +++ b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.less diff --git a/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.ts b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.ts new file mode 100644 index 0000000000..082a77dd9f --- /dev/null +++ b/catalog-ui/src/app/directives/utils/sdc-tags/sdc-tags.ts @@ -0,0 +1,75 @@ +'use strict'; + +export interface ISdcTagsScope extends ng.IScope { + tags:Array<string>; + specialTag:string; + newTag:string; + formElement:ng.IFormController; + elementName:string; + pattern:any; + sdcDisabled:boolean; + maxTags:number; + deleteTag(tag:string):void; + addTag(tag:string):void; + validateName():void; +} + +export class SdcTagsDirective implements ng.IDirective { + + constructor() { + } + + scope = { + tags: '=', + specialTag: '=', + pattern: '=', + sdcDisabled: '=', + formElement: '=', + elementName: '@', + maxTags: '@' + }; + + public replace = false; + public restrict = 'E'; + public transclude = false; + + template = ():string => { + return require('./sdc-tags.html'); + }; + + link = (scope:ISdcTagsScope, element:ng.INgModelController) => { + + scope.deleteTag = (tag:string):void => { + scope.tags.splice(scope.tags.indexOf(tag), 1); + }; + + scope.addTag = ():void => { + let valid = scope.formElement[scope.elementName].$valid; + if (valid && + scope.tags.length < scope.maxTags && + scope.newTag && + scope.newTag !== '' && + scope.tags.indexOf(scope.newTag) === -1 && + scope.newTag !== scope.specialTag) { + scope.tags.push(scope.newTag); + scope.newTag = ''; + } + }; + + scope.validateName = ():void => { + if (scope.tags.indexOf(scope.newTag) > -1) { + scope.formElement[scope.elementName].$setValidity('nameExist', false); + } else { + scope.formElement[scope.elementName].$setValidity('nameExist', true); + } + } + + }; + + public static factory = ()=> { + return new SdcTagsDirective(); + }; + +} + +SdcTagsDirective.factory.$inject = []; diff --git a/catalog-ui/src/app/directives/utils/smart-tooltip/smart-tooltip.ts b/catalog-ui/src/app/directives/utils/smart-tooltip/smart-tooltip.ts new file mode 100644 index 0000000000..d0177b4094 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/smart-tooltip/smart-tooltip.ts @@ -0,0 +1,61 @@ +'use strict'; + +export interface ISmartTooltipScope extends ng.IScope { + sdcSmartToolip; +} + +export class SmartTooltipDirective implements ng.IDirective { + + constructor(private $compile:ng.ICompileService) { + } + + public replace = false; + public restrict = 'A'; + public transclude = false; + + public link = (scope:ISmartTooltipScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + + if ($elem[0].hasAttribute('style') === false) { + $elem[0].setAttribute("style", "overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"); + } else { + let styles = $elem.attr('style'); + $elem[0].setAttribute("style", styles + ";overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"); + } + + $elem.bind('mouseenter', () => { + if ($elem[0].offsetWidth < $elem[0].scrollWidth && !$elem.attr('tooltips')) { + $attrs.$set('tooltips', 'tooltips'); + if ($attrs['sdcSmartTooltip'] && $attrs['sdcSmartTooltip'].length > 0) { + $elem.attr('tooltip-content', $attrs['sdcSmartTooltip']); + } else { + $attrs.$set('tooltip-content', $elem.text()); + } + + //One possible problem arises when the ngIf is placed on the root element of the template. + //ngIf removes the node and places a comment in it's place. Then it watches over the expression and adds/removes the actual HTML element as necessary. + //The problem seems to be that if it is placed on the root element of the template, then a single comment is what is left from the + //whole template (even if only temporarily), which gets ignored (I am not sure if this is browser-specific behaviour), resulting in an empty template. + + // Remove ng-if attribute and its value (if we reach here, we pass ng-if (ng-if===true), so we can remove it). + $elem.removeAttr('ng-if'); + $elem.removeAttr('data-ng-if'); + + // Remove me (the directive from the element) + let template = $elem[0].outerHTML; + template = template.replace('sdc-smart-tooltip=""', ''); + template = template.replace('sdc-smart-tooltip="' + $elem.text() + '"', ''); + //console.log(template); + + let el = this.$compile(template)(scope); + console.log(el); + $elem.replaceWith(el); + } + }); + }; + + public static factory = ($compile:ng.ICompileService)=> { + return new SmartTooltipDirective($compile); + }; +} + +SmartTooltipDirective.factory.$inject = ['$compile']; diff --git a/catalog-ui/src/app/directives/utils/validation-on-load/validation-on-load.ts b/catalog-ui/src/app/directives/utils/validation-on-load/validation-on-load.ts new file mode 100644 index 0000000000..d489efa928 --- /dev/null +++ b/catalog-ui/src/app/directives/utils/validation-on-load/validation-on-load.ts @@ -0,0 +1,48 @@ +'use strict'; + +export interface IValidationOnLoadScope extends ng.IScope { + formToValidate:ng.IFormController; +} + +export class ValidationOnLoadDirective implements ng.IDirective { + + constructor(private $timeout:ng.ITimeoutService) { + } + + scope = { + formToValidate: '=' + }; + + public replace = false; + public restrict = 'A'; + + + public link = (scope:IValidationOnLoadScope, $elem:ng.IAugmentedJQuery, $attrs:angular.IAttributes) => { + + let init = ()=> { + //validate errors + if (scope.formToValidate.$error) { + angular.forEach(scope.formToValidate.$error, (value, key)=> { + //skip on the required error if its a new form + if (key != 'required') { + angular.forEach(value, function (field) { + field.$setDirty();//trigger to show the error label + }); + } + }) + } + }; + + this.$timeout(()=> { + init(); + }, 0); + + }; + + public static factory = ($timeout:ng.ITimeoutService)=> { + return new ValidationOnLoadDirective($timeout); + }; + +} + +ValidationOnLoadDirective.factory.$inject = ['$timeout']; diff --git a/catalog-ui/src/app/filters.ts b/catalog-ui/src/app/filters.ts new file mode 100644 index 0000000000..3a71c73289 --- /dev/null +++ b/catalog-ui/src/app/filters.ts @@ -0,0 +1,15 @@ +/** + * Created by ob0695 on 2/26/2017. + */ +export * from './filters/catalog-status-filter'; +export * from './filters/category-type-filter'; +export * from './filters/clear-whitespaces-filter'; +export * from './filters/entity-filter'; +export * from './filters/graph-resource-name-filter'; +export * from './filters/resource-name-filter'; +export * from './filters/resource-type-filter'; +export * from './filters/string-to-date-filter'; +export * from './filters/tests-id-filter'; +export * from './filters/trim-filter'; +export * from './filters/truncate-filter'; + diff --git a/catalog-ui/src/app/filters/catalog-status-filter.ts b/catalog-ui/src/app/filters/catalog-status-filter.ts new file mode 100644 index 0000000000..c28ec1d1e5 --- /dev/null +++ b/catalog-ui/src/app/filters/catalog-status-filter.ts @@ -0,0 +1,18 @@ +/** + * Created by obarda on 19/08/2015. + */ +export class CatalogStatusFilter { + + constructor() { + let filter = <CatalogStatusFilter>( (statuses:any) => { + let filtered = []; + angular.forEach(statuses, function (status) { + filtered.push(status); + }); + return filtered; + }); + + return filter; + } +} + diff --git a/catalog-ui/src/app/filters/category-type-filter.ts b/catalog-ui/src/app/filters/category-type-filter.ts new file mode 100644 index 0000000000..66663263c3 --- /dev/null +++ b/catalog-ui/src/app/filters/category-type-filter.ts @@ -0,0 +1,28 @@ +import {ComponentType} from "../utils/constants"; +import {CacheService} from "../services/cache-service"; +export class CategoryTypeFilter { + + static $inject = ['Sdc.Services.CacheService']; + + constructor(cacheService:CacheService) { + let filter = <CategoryTypeFilter>(categories:any, selectedType:Array<string>, selectedSubResourceTypes:Array<string>) => { + + if (selectedType.indexOf(ComponentType.RESOURCE) === -1 && selectedSubResourceTypes.length > 0) { + selectedType = selectedType.concat([ComponentType.RESOURCE]); + } + + if (!selectedType.length) + return categories; + + let filteredCategories:any = []; + selectedType.forEach((type:string) => { + filteredCategories = filteredCategories.concat(cacheService.get(type.toLowerCase() + 'Categories')); + }); + + return _.filter(categories, function (category:any) { + return filteredCategories.indexOf(category) != -1; + }); + }; + return filter; + } +} diff --git a/catalog-ui/src/app/filters/clear-whitespaces-filter.ts b/catalog-ui/src/app/filters/clear-whitespaces-filter.ts new file mode 100644 index 0000000000..ea6129e22b --- /dev/null +++ b/catalog-ui/src/app/filters/clear-whitespaces-filter.ts @@ -0,0 +1,16 @@ +export class ClearWhiteSpacesFilter { + + constructor() { + let filter = <ClearWhiteSpacesFilter>( (text:string) => { + if (!angular.isString(text)) { + return text; + } + + return text.replace(/ /g, ''); // remove also whitespaces inside + }); + + return filter; + } +} + + diff --git a/catalog-ui/app/scripts/filters/entity-filter.ts b/catalog-ui/src/app/filters/entity-filter.ts index ce60d69833..97d9b85f9b 100644 --- a/catalog-ui/app/scripts/filters/entity-filter.ts +++ b/catalog-ui/src/app/filters/entity-filter.ts @@ -1,38 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../references"/> -module Sdc.Filters { - - export class EntityFilter{ +import {Component, Resource} from "../models"; +export class EntityFilter { constructor() { - let filter = <EntityFilter>( (components:Array<Models.Components.Component>, filter:any) => { + let filter = <EntityFilter>( (components:Array<Component>, filter:any) => { - let filteredComponents:Array<Models.Components.Component> = components; + let filteredComponents:Array<Component> = components; // filter by type // -------------------------------------------------------------------------- - if ((filter.selectedComponentTypes && filter.selectedComponentTypes.length>0) || (filter.selectedResourceSubTypes && filter.selectedResourceSubTypes.length>0)) { + if ((filter.selectedComponentTypes && filter.selectedComponentTypes.length > 0) || (filter.selectedResourceSubTypes && filter.selectedResourceSubTypes.length > 0)) { let filteredTypes = []; - angular.forEach(components, (component:Models.Components.Component):void => { + angular.forEach(components, (component:Component):void => { // Filter by component type let typeLower:string = component.componentType.toLowerCase(); let typeFirstCapital:string = typeLower.charAt(0).toUpperCase() + typeLower.slice(1); @@ -43,7 +22,7 @@ module Sdc.Filters { // Filter by resource sub type, only in case the resource checkbox was not selected (because in this case we already added all the components in above section). if (component.isResource() && filter.selectedComponentTypes.indexOf("Resource") === -1 && filter.selectedResourceSubTypes.length > 0) { //filteredComponents.pop(); // Remove the last inserted component. - let resource:Sdc.Models.Components.Resource = <Sdc.Models.Components.Resource>component; + let resource:Resource = <Resource>component; if (filter.selectedResourceSubTypes.indexOf(resource.getComponentSubType()) !== -1) { filteredTypes.push(component); } @@ -54,9 +33,9 @@ module Sdc.Filters { // filter by categories & subcategories & groupings // -------------------------------------------------------------------------- - if (filter.selectedCategoriesModel && filter.selectedCategoriesModel.length>0) { + if (filter.selectedCategoriesModel && filter.selectedCategoriesModel.length > 0) { let filteredCategories = []; - angular.forEach(filteredComponents, (component:Models.Components.Component):void => { + angular.forEach(filteredComponents, (component:Component):void => { if (component.categories && filter.selectedCategoriesModel.indexOf(component.categories[0].uniqueId) !== -1) { filteredCategories.push(component); } else if (component.categories && component.categories[0].subcategories && filter.selectedCategoriesModel.indexOf(component.categories[0].subcategories[0].uniqueId) !== -1) { @@ -72,16 +51,16 @@ module Sdc.Filters { // -------------------------------------------------------------------------- if (filter.selectedStatuses && filter.selectedStatuses.length > 0) { //convert array of array to string array - let selectedStatuses:Array<string> = [].concat.apply([],filter.selectedStatuses); + let selectedStatuses:Array<string> = [].concat.apply([], filter.selectedStatuses); let filteredStatuses = []; - angular.forEach(filteredComponents, (component:Models.Components.Component):void => { + angular.forEach(filteredComponents, (component:Component):void => { if (selectedStatuses.indexOf(component.lifecycleState) > -1) { filteredStatuses.push(component); } //if status DISTRIBUTED && CERTIFIED are selected the component will added in CERTIFIED status , not need to add twice - if(selectedStatuses.indexOf('DISTRIBUTED') > -1 && !(selectedStatuses.indexOf('CERTIFIED') > -1)){ - if( component.distributionStatus && component.distributionStatus.indexOf('DISTRIBUTED') > -1 && component.lifecycleState.indexOf('CERTIFIED') > -1){ + if (selectedStatuses.indexOf('DISTRIBUTED') > -1 && !(selectedStatuses.indexOf('CERTIFIED') > -1)) { + if (component.distributionStatus && component.distributionStatus.indexOf('DISTRIBUTED') > -1 && component.lifecycleState.indexOf('CERTIFIED') > -1) { filteredStatuses.push(component); } } @@ -92,13 +71,13 @@ module Sdc.Filters { // filter by statuses and distributed // -------------------------------------------------------------------------- if (filter.distributed != undefined && filter.distributed.length > 0) { - let filterDistributed: Array<any> = filter.distributed; + let filterDistributed:Array<any> = filter.distributed; let filteredDistributed = []; angular.forEach(filteredComponents, (entity) => { filterDistributed.forEach((distribute) => { let distributeItem = distribute.split(','); distributeItem.forEach((item) => { - if (item !== undefined && entity.distributionStatus === item){ + if (item !== undefined && entity.distributionStatus === item) { filteredDistributed.push(entity); } }) @@ -107,11 +86,9 @@ module Sdc.Filters { filteredComponents = filteredDistributed; } - return filteredComponents; - }); + return filteredComponents; + }); - return filter; + return filter; } - } - } diff --git a/catalog-ui/src/app/filters/graph-resource-name-filter.ts b/catalog-ui/src/app/filters/graph-resource-name-filter.ts new file mode 100644 index 0000000000..a4698612f6 --- /dev/null +++ b/catalog-ui/src/app/filters/graph-resource-name-filter.ts @@ -0,0 +1,22 @@ +export class GraphResourceNameFilter { + + constructor() { + let filter = <GraphResourceNameFilter>( (name:string) => { + let context = document.createElement("canvas").getContext("2d"); + context.font = "13px Arial"; + + if (67 < context.measureText(name).width) { + let newLen = name.length - 3; + let newName = name.substring(0, newLen); + + while (59 < (context.measureText(newName).width)) { + newName = newName.substring(0, (--newLen)); + } + return newName + '...'; + } + + return name; + }); + return filter; + } +} diff --git a/catalog-ui/src/app/filters/resource-name-filter.ts b/catalog-ui/src/app/filters/resource-name-filter.ts new file mode 100644 index 0000000000..cd0189dc9a --- /dev/null +++ b/catalog-ui/src/app/filters/resource-name-filter.ts @@ -0,0 +1,21 @@ +export class ResourceNameFilter { + + + constructor() { + let filter = <ResourceNameFilter>( (name:string) => { + if (name) { + //let newName:string = _.last(name.split('.')); + let newName = + _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.')) + .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.')) + .split('nodes.module.')).split('cp.')).split('vl.')); + if (newName) { + return newName; + } + return name; + } + }); + + return filter; + } +} diff --git a/catalog-ui/src/app/filters/resource-type-filter.ts b/catalog-ui/src/app/filters/resource-type-filter.ts new file mode 100644 index 0000000000..f2d06f0edd --- /dev/null +++ b/catalog-ui/src/app/filters/resource-type-filter.ts @@ -0,0 +1,17 @@ +import {CacheService} from "../services/cache-service"; + +export class ResourceTypeFilter { + static '$inject' = ['Sdc.Services.CacheService']; + + constructor(cacheService:CacheService) { + let filter = <ResourceTypeFilter>(resourceType:string) => { + let uiConfiguration:any = cacheService.get('UIConfiguration'); + + if (uiConfiguration.resourceTypes && uiConfiguration.resourceTypes[resourceType]) { + return uiConfiguration.resourceTypes[resourceType]; + } + return resourceType; + } + return filter; + } +} diff --git a/catalog-ui/src/app/filters/string-to-date-filter.ts b/catalog-ui/src/app/filters/string-to-date-filter.ts new file mode 100644 index 0000000000..846180a2cc --- /dev/null +++ b/catalog-ui/src/app/filters/string-to-date-filter.ts @@ -0,0 +1,12 @@ +export class StringToDateFilter { + + constructor() { + let filter = <StringToDateFilter>( (date:string) => { + if (date) { + return new Date(date.replace(" UTC", '').replace(" ", 'T') + '+00:00'); + } + }); + return filter; + } +} + diff --git a/catalog-ui/src/app/filters/tests-id-filter.ts b/catalog-ui/src/app/filters/tests-id-filter.ts new file mode 100644 index 0000000000..0e5af31169 --- /dev/null +++ b/catalog-ui/src/app/filters/tests-id-filter.ts @@ -0,0 +1,11 @@ +export class TestsIdFilter { + + constructor() { + let filter = <TestsIdFilter>( (testId:string) => { + return testId.replace(/\s/g, '_').toLowerCase(); + }); + + return filter; + } +} + diff --git a/catalog-ui/src/app/filters/trim-filter.ts b/catalog-ui/src/app/filters/trim-filter.ts new file mode 100644 index 0000000000..f174034748 --- /dev/null +++ b/catalog-ui/src/app/filters/trim-filter.ts @@ -0,0 +1,15 @@ +export class TrimFilter { + + constructor() { + let filter = <TrimFilter>( (text:string) => { + if (!angular.isString(text)) { + return text; + } + + return text.replace(/^\s+|\s+$/g, ''); // you could use .trim, but it's not going to work in IE<9 + }); + + return filter; + } +} + diff --git a/catalog-ui/src/app/filters/truncate-filter.ts b/catalog-ui/src/app/filters/truncate-filter.ts new file mode 100644 index 0000000000..e660871e3b --- /dev/null +++ b/catalog-ui/src/app/filters/truncate-filter.ts @@ -0,0 +1,26 @@ +export class TruncateFilter { + constructor() { + let filter = <TruncateFilter>(str:string, length:number) => { + if (str.length <= length) { + return str; + } + + //if(str[length - 1] === ' '){ + // return str.substring(0, length - 1) + '...'; + //} + + let char; + let index = length; + while (char !== ' ' && index !== 0) { + index--; + char = str[index]; + } + if (index === 0) { + return (index === 0) ? str : str.substring(0, length - 3) + '...'; + } + return (index === 0) ? str : str.substring(0, index) + '...'; + }; + return filter; + } + +} diff --git a/catalog-ui/src/app/models.ts b/catalog-ui/src/app/models.ts new file mode 100644 index 0000000000..5b286d0667 --- /dev/null +++ b/catalog-ui/src/app/models.ts @@ -0,0 +1,84 @@ +/** + * Created by ob0695 on 2/23/2017. + */ +import from = require("core-js/fn/array/from"); +export * from './models/activity'; +export * from './models/additional-information'; +export * from './models/app-config'; +export * from './models/validation-config'; +export * from './models/artifacts'; +export * from './models/aschema-property'; +export * from './models/schema-attribute'; +export * from './models/attributes'; +export * from './models/capability'; +export * from './models/category'; +export * from './models/comments'; +export * from './models/components/component'; +export * from './models/components/displayComponent'; +export * from './models/components/product'; +export * from './models/components/resource'; +export * from './models/components/service'; +export * from './models/componentsInstances/componentInstance'; +export * from './models/componentsInstances/productInstance'; +export * from './models/componentsInstances/resourceInstance'; +export * from './models/componentsInstances/serviceInstance'; +export * from './models/csar-component'; +//export * from './models/data-type-properties'; +export * from './models/properties-inputs/property-be-model'; +export * from './models/properties-inputs/property-fe-model'; +export * from './models/properties-inputs/property-fe-map'; +export * from './models/properties-inputs/derived-fe-property'; +export * from './models/properties-inputs/input-fe-model'; +export * from './models/data-types-map'; +export * from './models/data-types'; +export * from './models/distribution'; +export * from './models/export-excel'; +export * from './models/file-download'; +export * from './models/graph/graph-links/common-base-link'; +export * from './models/graph/graph-links/common-ci-link-base'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-link-base'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-simple-link'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-vl-link'; +export * from './models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link'; +export * from './models/graph/graph-links/links-factory'; +export * from './models/graph/graph-links/module-graph-links/module-ci-link-base'; +export * from './models/graph/graph-links/module-graph-links/module-ci-vl-link'; +export * from './models/graph/graphTooltip'; +export * from './models/graph/assetPopoverObj'; +export * from './models/graph/link-menu'; +export * from './models/graph/match-relation'; +export * from './models/graph/nodes/base-common-node'; +export * from './models/graph/nodes/common-ci-node-base'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-base'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-cp'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-service'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-vf'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc'; +export * from './models/graph/nodes/composition-graph-nodes/composition-ci-node-vl'; +export * from './models/graph/nodes/modules-graph-nodes/module-node-base'; +export * from './models/graph/nodes/nodes-factory'; +export * from './models/graph/point'; +export * from './models/graph/relationMenuObjects'; +export * from './models/graph/relationship'; +export * from './models/heat-parameters'; +export * from './models/input-property-base'; +export * from './models/inputs-and-properties'; +export * from './models/inputs'; +export * from './models/instance-inputs-properties-map'; +export * from './models/left-panel'; +export * from './models/member'; +export * from './models/modules/base-module'; +export * from './models/properties'; +export * from './models/requirement'; +export * from './models/tab'; +export * from './models/tooltip-data'; +export * from './models/user'; +export * from './models/validate'; +export * from './models/component-metadata'; + +export * from './models/button'; +export * from './models/filter-properties-assignment-data' diff --git a/catalog-ui/src/app/models/activity.ts b/catalog-ui/src/app/models/activity.ts new file mode 100644 index 0000000000..d60e69258c --- /dev/null +++ b/catalog-ui/src/app/models/activity.ts @@ -0,0 +1,27 @@ +/** + * Created by obarda on 19/11/2015. + */ +'use strict'; + +/*this is in uppercase because of the server response*/ +export class Activity { + TIMESTAMP:string; + ACTION:string; + MODIFIER:string; + STATUS:string; + DESC:string; + COMMENT:string; + //custom data + public dateFormat:string; + + constructor() { + } + + public toJSON = ():any => { + this.dateFormat = undefined; + return this; + }; + +} + + diff --git a/catalog-ui/src/app/models/additional-information.ts b/catalog-ui/src/app/models/additional-information.ts new file mode 100644 index 0000000000..0fc850a227 --- /dev/null +++ b/catalog-ui/src/app/models/additional-information.ts @@ -0,0 +1,20 @@ +'use strict'; +export interface IAdditionalInformationModel { + uniqueId:string; + key:string; + value:string; +} + + +export class AdditionalInformationModel implements IAdditionalInformationModel { + uniqueId:string; + key:string; + value:string; + + constructor() { + this.uniqueId = ''; + this.key = ''; + this.value = ''; + + } +} diff --git a/catalog-ui/src/app/models/app-config.ts b/catalog-ui/src/app/models/app-config.ts new file mode 100644 index 0000000000..a80dd40da8 --- /dev/null +++ b/catalog-ui/src/app/models/app-config.ts @@ -0,0 +1,226 @@ +'use strict'; +export interface IApi { + baseUrl:string; + + //***** NEW API *******// + GET_component:string; + PUT_component:string; + GET_component_validate_name:string; + POST_changeLifecycleState:string; + component_api_root:string; + //*********// + + GET_user:string; + GET_user_authorize:string; + GET_all_users:string; + POST_create_user; + DELETE_delete_user; + POST_edit_user_role; + GET_resource:string; + GET_resources_latestversion_notabstract:string; + GET_resources_certified_not_abstract:string; + GET_resources_certified_abstract:string; + PUT_resource:string; + GET_resource_property:string; + GET_resource_artifact:string; + GET_download_instance_artifact:string; + POST_instance_artifact:string; + GET_resource_additional_information:string; + GET_service_artifact:string; + GET_resource_interface_artifact:string; + GET_resource_api_artifact:string; + GET_resource_validate_name:string; + GET_resource_artifact_types:string; + GET_activity_log:string; + GET_configuration_ui:string; + GET_service:string; + PUT_product:string; + GET_product:string; + GET_ecomp_menu_items:string; + GET_product_validate_name:string; + GET_service_validate_name:string; + GET_service_distributions:string; + GET_service_distributions_components:string; + POST_service_distribution_deploy:string; + GET_element:string; + GET_catalog:string; + GET_resource_category:string; + GET_service_category:string; + resource_instance:string; + GET_resource_instance_property:string; + GET_relationship:string; + GET_lifecycle_state_resource:string; + GET_lifecycle_state_CHECKIN:string; + GET_lifecycle_state_CERTIFICATIONREQUEST:string; + GET_lifecycle_state_UNDOCHECKOUT:string; + root:string; + PUT_service:string; + GET_download_artifact:string; + GET_SDC_Version:string; + GET_categories:string; + POST_category:string; + POST_subcategory:string; + POST_change_instance_version:string; + GET_requirements_capabilities:string; + GET_onboarding:string; + GET_component_from_csar_uuid:string; + kibana:string; + + //Added by Ikram -- starts + GET_product_category:string; + GET_product_category_temp:string; + GET_product_sub_category:string; + //Added by Ikram -- ends + +} + +export interface ILogConfig { + minLogLevel:string; + prefix:string; +} + +export interface ICookie { + junctionName:string; + prefix:string; + userIdSuffix:string; + userFirstName:string; + userLastName:string; + userEmail:string; +} +export interface IUserTypes { + admin:any; + designer:any; + tester:any; +} + +export interface IConfigStatuses { + inDesign:IConfigStatus; + readyForCertification:IConfigStatus; + inCertification:IConfigStatus; + certified:IConfigStatus; + distributed:IConfigStatus; +} + +export interface IConfigStatus { + name:string; + values:Array<string>; +} + +export interface IConfigRoles { + ADMIN:IConfigRole; + DESIGNER:IConfigRole; + TESTER:IConfigRole; + OPS:IConfigRole; + GOVERNOR:IConfigRole; + PRODUCT_MANAGER:IConfigRole; + PRODUCT_STRATEGIST:IConfigRole; +} + +export interface IConfigRole { + pages:Array<string>; + states:IConfigState; +} + +export interface IConfigState { + NOT_CERTIFIED_CHECKOUT:Array<IConfigDistribution>; + NOT_CERTIFIED_CHECKIN:Array<IConfigDistribution>; + READY_FOR_CERTIFICATION:Array<IConfigDistribution>; + CERTIFICATION_IN_PROGRESS:Array<IConfigDistribution>; + CERTIFIED:Array<IConfigDistribution>; +} + +export interface IConfigDistribution { + DISTRIBUTION_NOT_APPROVED:Array<ConfigMenuItem>; + DISTRIBUTION_APPROVED:Array<ConfigMenuItem>; + DISTRIBUTED:Array<ConfigMenuItem>; + DISTRIBUTION_REJECTED:Array<ConfigMenuItem>; +} + +export interface IConfirmationMessage { + showComment:boolean; + title:string; + message:string; +} + +export interface IConfirmationMessages { + checkin:IConfirmationMessage; + checkout:IConfirmationMessage; + certify:IConfirmationMessage; + failCertification:IConfirmationMessage; + certificationRequest:IConfirmationMessage; + approve:IConfirmationMessage; + reject:IConfirmationMessage; +} + +export interface IAlertMessage { + title:string; + message:string; +} + +export interface IAlertMessages { + deleteInstance:IAlertMessage; + exitWithoutSaving:IConfirmationMessage; +} + +class ConfigMenuItem { + text:string; + action:string; + url:string; + disable:boolean = false; +} + +export interface IAppConfigurtaion { + environment:string; + api:IApi; + hostedApplications:Array<IHostedApplication>; + resourceTypesFilter:IResourceTypesFilter; + logConfig:ILogConfig; + cookie:ICookie; + imagesPath:string; + toscaFileExtension:string; + csarFileExtension:string; + testers:Array<ITester> + tutorial:any; + roles:Array<string>; + cpEndPointInstances:Array<string>; + openSource:boolean; + showOutlook:boolean; + validationConfigPath:string; +} + +export interface IResourceTypesFilter { + resource:Array<string>; +} + +export interface IHostedApplication { + moduleName:string; + navTitle:string; + defaultState:string; + exists?:boolean; + state:IHostedApplicationState; +} + +export interface IHostedApplicationState { + name:string; + url:string; + relativeHtmlPath:string; + controllerName:string; +} + +export interface ITester { + email:string; +} + +export interface IAppMenu { + roles:IConfigRoles; + confirmationMessages:IConfirmationMessages; + alertMessages:IAlertMessages; + statuses:IConfigStatuses; + catalogMenuItem:any; + categoriesDictionary:any; + canvas_buttons:Object; + component_workspace_menu_option:any; + LifeCycleStatuses:any; + DistributionStatuses:any; + ChangeLifecycleStateButton:any; +} diff --git a/catalog-ui/src/app/models/artifacts.ts b/catalog-ui/src/app/models/artifacts.ts new file mode 100644 index 0000000000..63e4b594f1 --- /dev/null +++ b/catalog-ui/src/app/models/artifacts.ts @@ -0,0 +1,101 @@ +'use strict'; + +import {ArtifactType} from './../utils'; +import {HeatParameterModel} from "./heat-parameters"; + +//this object contains keys, each key contain ArtifactModel +export class ArtifactGroupModel { + + constructor(artifacts?:ArtifactGroupModel) { + _.forEach(artifacts, (artifact:ArtifactModel, key) => { + this[key] = new ArtifactModel(artifact); + }); + } + + public filteredByType(type:string):ArtifactGroupModel { + let tmpArtifactGroupModel = new ArtifactGroupModel(); + _.each(Object.keys(this), (key)=>{ + if (this[key].artifactType === type) { + tmpArtifactGroupModel[key] = this[key]; + } + }); + return tmpArtifactGroupModel; + }; +} + +export class ArtifactModel { + + artifactDisplayName:string; + artifactGroupType:string; + uniqueId:string; + artifactName:string; + artifactLabel:string; + artifactType:string; + artifactUUID:string; + artifactVersion:string; + creatorFullName:string; + creationDate:number; + lastUpdateDate:number; + description:string; + mandatory:boolean; + serviceApi:boolean; + payloadData:string; + timeout:number; + esId:string; + "Content-MD5":string; + artifactChecksum:string; + apiUrl:string; + heatParameters:Array<HeatParameterModel>; + generatedFromId:string; + + //custom properties + selected:boolean; + originalDescription:string; + envArtifact:ArtifactModel; + + constructor(artifact?:ArtifactModel) { + if (artifact) { + this.artifactDisplayName = artifact.artifactDisplayName; + this.artifactGroupType = artifact.artifactGroupType; + this.uniqueId = artifact.uniqueId; + this.artifactName = artifact.artifactName; + this.artifactLabel = artifact.artifactLabel; + this.artifactType = artifact.artifactType; + this.artifactUUID = artifact.artifactUUID; + this.artifactVersion = artifact.artifactVersion; + this.creatorFullName = artifact.creatorFullName; + this.creationDate = artifact.creationDate; + this.lastUpdateDate = artifact.lastUpdateDate; + this.description = artifact.description; + this.mandatory = artifact.mandatory; + this.serviceApi = artifact.serviceApi; + this.payloadData = artifact.payloadData; + this.timeout = artifact.timeout; + this.esId = artifact.esId; + this["Content-MD5"] = artifact["Content-MD5"]; + this.artifactChecksum = artifact.artifactChecksum; + this.apiUrl = artifact.apiUrl; + this.heatParameters = _.sortBy(artifact.heatParameters, 'name'); + this.generatedFromId = artifact.generatedFromId; + this.selected = artifact.selected ? artifact.selected : false; + this.originalDescription = artifact.description; + } + } + + public isHEAT = ():boolean => { + return ArtifactType.HEAT === this.artifactType || ArtifactType.HEAT_VOL === this.artifactType || ArtifactType.HEAT_NET === this.artifactType; + }; + + public isThirdParty = ():boolean => { + return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, this.artifactType); + }; + + public toJSON = ():any => { + this.selected = undefined; + this.originalDescription = undefined; + this.envArtifact = undefined; + return this; + }; +} + + diff --git a/catalog-ui/src/app/models/aschema-property.ts b/catalog-ui/src/app/models/aschema-property.ts new file mode 100644 index 0000000000..a430a8cc0e --- /dev/null +++ b/catalog-ui/src/app/models/aschema-property.ts @@ -0,0 +1,56 @@ +/** + * Created by osonsino on 16/05/2016. + */ +'use strict'; +import { PROPERTY_DATA } from "app/utils"; + +export class SchemaPropertyGroupModel { + property:SchemaProperty; + + constructor(schemaProperty?:SchemaProperty) { + this.property = schemaProperty; + } +} + +export class SchemaProperty { + + type:string; + required:boolean; + definition:boolean; + description:string; + password:boolean; + //custom properties + simpleType:string; + isSimpleType: boolean; + isDataType: boolean; + private _derivedFromSimpleTypeName:string; + get derivedFromSimpleTypeName():string { + return this._derivedFromSimpleTypeName; + } + set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) { + this._derivedFromSimpleTypeName = derivedFromSimpleTypeName; + } + + constructor(schemaProperty?:SchemaProperty) { + if (schemaProperty) { + this.type = schemaProperty.type; + this.required = schemaProperty.required; + this.definition = schemaProperty.definition; + this.description = schemaProperty.description; + this.password = schemaProperty.password; + this.simpleType = schemaProperty.simpleType; + this.isSimpleType = (-1 < PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type)); + this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1; + } + } + + public toJSON = ():any => { + this.simpleType = undefined; + this.isSimpleType = undefined; + this.isDataType = undefined; + this._derivedFromSimpleTypeName = undefined; + return this; + }; +} + + diff --git a/catalog-ui/src/app/models/attributes.ts b/catalog-ui/src/app/models/attributes.ts new file mode 100644 index 0000000000..f2562e98bf --- /dev/null +++ b/catalog-ui/src/app/models/attributes.ts @@ -0,0 +1,119 @@ +'use strict'; +import {SchemaAttributeGroupModel, SchemaAttribute} from "./schema-attribute"; +import {SchemaPropertyGroupModel, SchemaProperty} from "./aschema-property"; + +export class AttributesGroup { + constructor(attributesObj?:AttributesGroup) { + _.forEach(attributesObj, (attributes:Array<AttributeModel>, instance) => { + this[instance] = []; + _.forEach(attributes, (attribute:AttributeModel):void => { + attribute.resourceInstanceUniqueId = instance; + attribute.readonly = true; + this[instance].push(new AttributeModel(attribute)); + }); + }); + } +} + +export interface IAttributeModel { + + //server data + uniqueId:string; + name:string; + defaultValue:string; + description:string; + type:string; + schema:SchemaAttributeGroupModel; + status:string; + value:string; + hidden:boolean; + parentUniqueId:string; + //custom data + resourceInstanceUniqueId:string; + readonly:boolean; + valueUniqueUid:string; +} + +export class AttributeModel implements IAttributeModel { + + //server data + uniqueId:string; + name:string; + defaultValue:string; + description:string; + type:string; + schema:SchemaAttributeGroupModel; + status:string; + value:string; + hidden:boolean; + parentUniqueId:string; + //custom data + resourceInstanceUniqueId:string; + readonly:boolean; + valueUniqueUid:string; + + constructor(attribute?:AttributeModel) { + if (attribute) { + this.uniqueId = attribute.uniqueId; + this.name = attribute.name; + this.defaultValue = attribute.defaultValue; + this.description = attribute.description; + this.type = attribute.type; + this.status = attribute.status; + this.schema = attribute.schema; + this.value = attribute.value; + this.hidden = attribute.hidden; + this.parentUniqueId = attribute.parentUniqueId; + this.resourceInstanceUniqueId = attribute.resourceInstanceUniqueId; + this.readonly = attribute.readonly; + this.valueUniqueUid = attribute.valueUniqueUid; + } + + if (!this.schema || !this.schema.property) { + this.schema = new SchemaPropertyGroupModel(new SchemaProperty()); + } else { + //forcing creating new object, so editing different one than the object in the table + this.schema = new SchemaAttributeGroupModel(new SchemaAttribute(this.schema.property)); + } + + this.convertValueToView(); + } + + public convertToServerObject:Function = ():string => { + if (this.defaultValue && this.type === 'map') { + this.defaultValue = '{' + this.defaultValue + '}'; + } + if (this.defaultValue && this.type === 'list') { + this.defaultValue = '[' + this.defaultValue + ']'; + } + this.defaultValue = this.defaultValue != "" && this.defaultValue != "[]" && this.defaultValue != "{}" ? this.defaultValue : null; + + return JSON.stringify(this); + }; + + + public convertValueToView() { + //unwrapping value {} or [] if type is complex + if (this.defaultValue && (this.type === 'map' || this.type === 'list') && + ['[', '{'].indexOf(this.defaultValue.charAt(0)) > -1 && + [']', '}'].indexOf(this.defaultValue.slice(-1)) > -1) { + this.defaultValue = this.defaultValue.slice(1, -1); + } + + //also for value - for the modal in canvas + if (this.value && (this.type === 'map' || this.type === 'list') && + ['[', '{'].indexOf(this.value.charAt(0)) > -1 && + [']', '}'].indexOf(this.value.slice(-1)) > -1) { + this.value = this.value.slice(1, -1); + } + } + + public toJSON = ():any => { + if (!this.resourceInstanceUniqueId) { + this.value = undefined; + } + this.readonly = undefined; + this.resourceInstanceUniqueId = undefined; + return this; + }; +} diff --git a/catalog-ui/src/app/models/button.ts b/catalog-ui/src/app/models/button.ts new file mode 100644 index 0000000000..8fbaf9091c --- /dev/null +++ b/catalog-ui/src/app/models/button.ts @@ -0,0 +1,20 @@ +/** + * Created by rc2122 on 5/10/2017. + */ +export class ButtonModel { + text: string; + cssClass: string; + callback: Function; + getDisabled:Function; + constructor(text?:string, cssClass?:string, callback?:Function, getDisabled?:Function){ + this.text = text; + this.cssClass = cssClass; + this.callback = callback; + this.getDisabled = getDisabled; + + } +} + +export class ButtonsModelMap { + [buttonName: string]: ButtonModel; +} diff --git a/catalog-ui/src/app/models/capability.ts b/catalog-ui/src/app/models/capability.ts new file mode 100644 index 0000000000..94995bca55 --- /dev/null +++ b/catalog-ui/src/app/models/capability.ts @@ -0,0 +1,95 @@ +/** + * Created by obarda on 4/20/2016. + */ +'use strict'; +import {PropertyModel} from "./properties"; + +//this is an object contains keys, when each key has matching array. +// for example: key = tosca.capabilities.network.Linkable and the match array is array of capabilities objects +export class CapabilitiesGroup { + constructor(capabilityGroupObj?:CapabilitiesGroup) { + _.forEach(capabilityGroupObj, (capabilitiesArrayObj:Array<Capability>, instance) => { + this[instance] = []; + _.forEach(capabilitiesArrayObj, (capability:Capability):void => { + this[instance].push(new Capability(capability)); + }); + }); + } + + public findValueByKey(keySubstring:string):Array<Capability> { + let key:string = _.find(Object.keys(this), (key)=> { + return _.includes(key.toLowerCase(), keySubstring); + }); + return this[key]; + } +} + +export class Capability { + + //server data + name:string; + ownerId:string; + ownerName:string; + type:string; + uniqueId:string; + capabilitySources:Array<String>; + minOccurrences:string; + maxOccurrences:string; + properties:Array<PropertyModel>; + description:string; + validSourceTypes:Array<string>; + //custom + selected:boolean; + filterTerm:string; + + constructor(capability?:Capability) { + + if (capability) { + //server data + this.name = capability.name; + this.ownerId = capability.ownerId; + this.ownerName = capability.ownerName; + this.type = capability.type; + this.uniqueId = capability.uniqueId; + this.capabilitySources = capability.capabilitySources; + this.minOccurrences = capability.minOccurrences; + this.maxOccurrences = capability.maxOccurrences; + this.properties = capability.properties; + this.description = capability.description; + this.validSourceTypes = capability.validSourceTypes; + this.selected = capability.selected; + this.initFilterTerm(); + + } + } + + public getFullTitle():string { + let maxOccurrences:string = this.maxOccurrences === 'UNBOUNDED' ? '∞' : this.maxOccurrences; + return this.ownerName + ': ' + this.name + ': [' + this.minOccurrences + ', ' + maxOccurrences + ']'; + } + + public toJSON = ():any => { + this.selected = undefined; + this.filterTerm = undefined; + return this; + }; + + private initFilterTerm = ():void => { + this.filterTerm = this.name + " " + + (this.type ? (this.type.replace("tosca.capabilities.", "") + " " ) : "") + + (this.description || "") + " " + + (this.ownerName || "") + " " + + (this.validSourceTypes ? (this.validSourceTypes.join(',') + " ") : "") + + this.minOccurrences + "," + this.maxOccurrences; + if (this.properties && this.properties.length) { + _.forEach(this.properties, (prop:PropertyModel)=> { + this.filterTerm += " " + prop.name + + " " + (prop.description || "") + + " " + prop.type + + (prop.schema && prop.schema.property ? (" " + prop.schema.property.type) : ""); + }); + } + } +} + + diff --git a/catalog-ui/src/app/models/categories.ts b/catalog-ui/src/app/models/categories.ts new file mode 100644 index 0000000000..2aad61194f --- /dev/null +++ b/catalog-ui/src/app/models/categories.ts @@ -0,0 +1,10 @@ +import {IMainCategory} from "./category"; +/** + * Created by ob0695 on 5/8/2017. + */ +export class Categories { + + resourceCategories:Array<IMainCategory>; + productCategories:Array<IMainCategory>; + serviceCategories:Array<IMainCategory>; +} diff --git a/catalog-ui/src/app/models/category.ts b/catalog-ui/src/app/models/category.ts new file mode 100644 index 0000000000..fcfe61bfd6 --- /dev/null +++ b/catalog-ui/src/app/models/category.ts @@ -0,0 +1,47 @@ +'use strict'; + + + +export class ICategoryBase { + + //server properties + name:string; + normalizedName:string; + uniqueId:string; + icons:Array<string>; + + //custom properties + filterTerms:string; + isDisabled:boolean; + filteredGroup:Array<IGroup>; + + constructor(category?:ICategoryBase) { + if (category) { + this.name = category.name; + this.normalizedName = category.normalizedName; + this.icons = category.icons; + this.filterTerms = category.filterTerms; + this.isDisabled = category.isDisabled; + this.filteredGroup = category.filteredGroup; + } + } +} + +export class IMainCategory extends ICategoryBase { + subcategories:Array<ISubCategory>; + + constructor(); + constructor(category?:IMainCategory) { + super(category); + if (category) { + this.subcategories = category.subcategories; + } + } +} + +export class ISubCategory extends ICategoryBase { + groupings:Array<ICategoryBase>; +} + +export interface IGroup extends ICategoryBase { +} diff --git a/catalog-ui/src/app/models/comments.ts b/catalog-ui/src/app/models/comments.ts new file mode 100644 index 0000000000..b61713cc2c --- /dev/null +++ b/catalog-ui/src/app/models/comments.ts @@ -0,0 +1,11 @@ +'use strict'; + +export class AsdcComment { + public userRemarks:string; + + constructor() { + } +} + + + diff --git a/catalog-ui/src/app/models/component-metadata.ts b/catalog-ui/src/app/models/component-metadata.ts new file mode 100644 index 0000000000..9476d75bd0 --- /dev/null +++ b/catalog-ui/src/app/models/component-metadata.ts @@ -0,0 +1,89 @@ +import {IMainCategory} from "./category"; +/** + * Created by obarda on 4/18/2017. + */ +export class ComponentMetadata { + + public abstract:string; + public uniqueId:string; + public uuid:string; + public invariantUUID:string; + public name:string; + public version:string; + public creationDate:number; + public lastUpdateDate:number; + public description:string; + public lifecycleState:string; + public tags:Array<string>; + public icon:string; + public contactId:string; + public allVersions:any; + public creatorUserId:string; + public creatorFullName:string; + public lastUpdaterUserId:string; + public lastUpdaterFullName:string; + public componentType:string; + public categories:Array<IMainCategory>; + public highestVersion:boolean; + public normalizedName:string; + public systemName:string; + + //Resource only + public resourceType: string; + public csarUUID:string; + public csarVersion:string; + public derivedList: string[]; + public vendorName:string; + public vendorRelease:string; + public derivedFrom: Array<string>; + + //Service only + public projectCode:string; + public distributionStatus:string; + public ecompGeneratedNaming: boolean; + public namingPolicy: string; + + + //backend lifecycleState + public state:string; + + deserialize (response): ComponentMetadata { + this.abstract = response.abstract; + this.uniqueId = response.uniqueId; + this.uuid = response.uuid; + this.invariantUUID = response.invariantUUID; + this.contactId = response.contactId; + this.categories = response.categories; + this.creatorUserId = response.creatorUserId; + this.creationDate = response.creationDate; + this.creatorFullName = response.creatorFullName; + this.description = response.description; + this.icon = response.icon; + this.lastUpdateDate = response.lastUpdateDate; + this.lastUpdaterUserId = response.lastUpdaterUserId; + this.lastUpdaterFullName = response.lastUpdaterFullName; + this.lifecycleState = response.lifecycleState; + this.name = response.name; + this.version = response.version; + this.tags = angular.copy(response.tags, this.tags); + this.allVersions = response.allVersions; + this.componentType = response.componentType; + this.distributionStatus = response.distributionStatus; + this.highestVersion = response.highestVersion; + this.vendorName = response.vendorName; + this.vendorRelease = response.vendorRelease; + this.derivedList = response.derivedList; + this.normalizedName = response.normalizedName; + this.systemName = response.systemName; + this.projectCode = response.projectCode; + this.resourceType = response.resourceType; + this.csarUUID = response.csarUUID; + this.csarVersion = response.version; + this.state = response.state; + this.ecompGeneratedNaming = response.ecompGeneratedNaming; + this.namingPolicy = response.namingPolicy; + this.derivedFrom = response.derivedFrom; + return this; + } + +} diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts new file mode 100644 index 0000000000..898285f032 --- /dev/null +++ b/catalog-ui/src/app/models/components/component.ts @@ -0,0 +1,911 @@ +'use strict'; + +import {AsdcComment, ArtifactModel, ArtifactGroupModel, IFileDownload, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance, + InputModel, DisplayModule, Module, IValidate, RelationshipModel, IMainCategory, RequirementsGroup, CapabilitiesGroup, AdditionalInformationModel, + Resource, IAppMenu, Product, Service} from "../../models"; + +import {IComponentService} from "../../services/components/component-service"; +import {CommonUtils} from "../../utils/common-utils"; +import {QueueUtils} from "../../utils/functions"; +import {ArtifactGroupType} from "../../utils/constants"; +import {ComponentMetadata} from "../component-metadata"; + +// import {} +export interface IComponent { + + //---------------------------------------------- API CALLS ----------------------------------------------------// + + //Component API + getComponent():ng.IPromise<Component>; + updateComponent():ng.IPromise<Component>; + createComponentOnServer():ng.IPromise<Component>; + changeLifecycleState(state:string, commentObj:AsdcComment):ng.IPromise<Component>; + validateName(newName:string):ng.IPromise<IValidate>; + updateRequirementsCapabilities():ng.IPromise<any>; + + //Artifacts API + addOrUpdateArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + updateMultipleArtifacts(artifacts:Array<ArtifactModel>):ng.IPromise<any>; + deleteArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>; + downloadInstanceArtifact(artifactId:string):ng.IPromise<IFileDownload>; + downloadArtifact(artifactId:string):ng.IPromise<IFileDownload>; + getArtifactByGroupType(artifactGroupType:string):ng.IPromise<ArtifactGroupModel>; + + + //Property API + addOrUpdateProperty(property:PropertyModel):ng.IPromise<PropertyModel>; + deleteProperty(propertyId:string):ng.IPromise<PropertyModel>; + updateInstanceProperty(property:PropertyModel):ng.IPromise<PropertyModel>; + + //Attribute API + deleteAttribute(attributeId:string):ng.IPromise<AttributeModel>; + addOrUpdateAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>; + updateInstanceAttribute(attribute:AttributeModel):ng.IPromise<AttributeModel>; + + + + + //Component Instance API + createComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>; + deleteComponentInstance(componentInstanceId:string):ng.IPromise<ComponentInstance>; + addOrUpdateInstanceArtifact(artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + deleteInstanceArtifact(artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel>; + uploadInstanceEnvFile(artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + changeComponentInstanceVersion(componentUid:string):ng.IPromise<Component>; + updateComponentInstance(componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>; + updateMultipleComponentInstances(instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>>; + + //Inputs API + getComponentInstanceInputProperties(componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> + getComponentInstanceProperties(componentInstanceId:string):ng.IPromise<Array<PropertyModel>> + getComponentInputs(componentId:string):ng.IPromise<Array<InputModel>>; + + createRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>; + deleteRelation(link:RelationshipModel):ng.IPromise<RelationshipModel>; + + + //Modules + getModuleForDisplay(moduleId:string):ng.IPromise<DisplayModule>; + getModuleInstanceForDisplay(componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule>; + updateGroupMetadata(group:Module):ng.IPromise<Module>; + //---------------------------------------------- HELP FUNCTIONS ----------------------------------------------------// + + getComponentSubType():string; + isAlreadyCertified():boolean; + isProduct():boolean; + isService():boolean; + isResource():boolean; + isComplex():boolean; + getAdditionalInformation():Array<AdditionalInformationModel>; + getAllVersionsAsSortedArray():Array<any>; + getStatus(sdcMenu:IAppMenu):string; +} + + +export abstract class Component implements IComponent { + + //server data + public abstract:string; + public uniqueId:string; + public uuid:string; + public invariantUUID:string; + public name:string; + public version:string; + public creationDate:number; + public lastUpdateDate:number; + public description:string; + public lifecycleState:string; + public tags:Array<string>; + public icon:string; + public contactId:string; + public allVersions:any; + public creatorUserId:string; + public creatorFullName:string; + public lastUpdaterUserId:string; + public lastUpdaterFullName:string; + public componentType:string; + public deploymentArtifacts:ArtifactGroupModel; + public artifacts:ArtifactGroupModel; + public toscaArtifacts:ArtifactGroupModel; + public distributionStatus:string; + public categories:Array<IMainCategory>; + public componentInstancesProperties:PropertiesGroup; + public componentInstancesAttributes:AttributesGroup; + public componentInstancesRelations:Array<RelationshipModel>; + public componentInstances:Array<ComponentInstance>; + public inputs:Array<InputModel>; + public capabilities:CapabilitiesGroup; + public requirements:RequirementsGroup; + public additionalInformation:any; + public properties:Array<PropertyModel>; + public attributes:Array<AttributeModel>; + public highestVersion:boolean; + public vendorName:string; + public vendorRelease:string; + public derivedList:Array<any>; + public interfaces:any; + public normalizedName:string; + public systemName:string; + public projectCode:string; + public groups:Array<Module>; + //custom properties + public componentService:IComponentService; + public filterTerm:string; + public iconSprite:string; + public selectedInstance:ComponentInstance; + public mainCategory:string; + public subCategory:string; + public selectedCategory:string; + public showMenu:boolean; + + + constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) { + if (component) { + this.abstract = component.abstract; + this.uniqueId = component.uniqueId; + this.uuid = component.uuid; + this.invariantUUID = component.invariantUUID; + this.additionalInformation = component.additionalInformation; + this.artifacts = new ArtifactGroupModel(component.artifacts); + this.toscaArtifacts = new ArtifactGroupModel(component.toscaArtifacts); + this.contactId = component.contactId; + this.categories = component.categories; + this.creatorUserId = component.creatorUserId; + this.creationDate = component.creationDate; + this.creatorFullName = component.creatorFullName; + this.description = component.description; + this.icon = component.icon; + this.lastUpdateDate = component.lastUpdateDate; + this.lastUpdaterUserId = component.lastUpdaterUserId; + this.lastUpdaterFullName = component.lastUpdaterFullName; + this.lifecycleState = component.lifecycleState; + this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(component.componentInstancesRelations); + this.componentInstancesProperties = new PropertiesGroup(component.componentInstancesProperties); + this.componentInstancesAttributes = new AttributesGroup(component.componentInstancesAttributes); + this.name = component.name; + this.version = component.version; + this.tags = []; + angular.copy(component.tags, this.tags); + this.capabilities = new CapabilitiesGroup(component.capabilities); + this.requirements = new RequirementsGroup(component.requirements); + this.allVersions = component.allVersions; + this.deploymentArtifacts = new ArtifactGroupModel(component.deploymentArtifacts); + this.componentType = component.componentType; + this.distributionStatus = component.distributionStatus; + this.highestVersion = component.highestVersion; + this.vendorName = component.vendorName; + this.vendorRelease = component.vendorRelease; + this.derivedList = component.derivedList; + this.interfaces = component.interfaces; + this.normalizedName = component.normalizedName; + this.systemName = component.systemName; + this.projectCode = component.projectCode; + this.inputs = component.inputs; + this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances); + this.properties = CommonUtils.initProperties(component.properties, this.uniqueId); + this.attributes = CommonUtils.initAttributes(component.attributes, this.uniqueId); + this.selectedInstance = component.selectedInstance; + this.iconSprite = component.iconSprite; + this.showMenu = true; + this.groups = CommonUtils.initModules(component.groups); + } + + //custom properties + this.componentService = componentService; + } + + public setUniqueId = (uniqueId:string):void => { + this.uniqueId = uniqueId; + }; + + public setSelectedInstance = (componentInstance:ComponentInstance):void => { + this.selectedInstance = componentInstance; + }; + + + //------------------------------------------ API Calls ----------------------------------------------------------------// + public changeLifecycleState = (state:string, commentObj:AsdcComment):ng.IPromise<Component> => { + return this.componentService.changeLifecycleState(this, state, JSON.stringify(commentObj)); + }; + + public getComponent = ():ng.IPromise<Component> => { + return this.componentService.getComponent(this.uniqueId); + }; + + public createComponentOnServer = ():ng.IPromise<Component> => { + this.handleTags(); + return this.componentService.createComponent(this); + }; + + public updateComponent = ():ng.IPromise<Component> => { + this.handleTags(); + return this.componentService.updateComponent(this); + }; + + public validateName = (newName:string, subtype?:string):ng.IPromise<IValidate> => { + return this.componentService.validateName(newName, subtype); + }; + + public downloadArtifact = (artifactId:string):ng.IPromise<IFileDownload> => { + return this.componentService.downloadArtifact(this.uniqueId, artifactId); + }; + + public addOrUpdateArtifact = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let onSuccess = (artifactObj:ArtifactModel):void => { + let newArtifact = new ArtifactModel(artifactObj); + let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType); + artifacts[artifactObj.artifactLabel] = newArtifact; + deferred.resolve(newArtifact); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + this.componentService.addOrUpdateArtifact(this.uniqueId, artifact).then(onSuccess, onError); + return deferred.promise; + }; + + public updateMultipleArtifacts = (artifacts:Array<ArtifactModel>):ng.IPromise<any>=> { + let deferred = this.$q.defer(); + let onSuccess = (response:any):void => { + deferred.resolve(response); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + let q = new QueueUtils(this.$q); + + _.forEach(artifacts, (artifact)=> { + q.addBlockingUIAction(()=> this.addOrUpdateArtifact(artifact).then(onSuccess, onError)); + }); + return deferred.promise; + }; + + + public deleteArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let onSuccess = (artifactObj:ArtifactModel):void => { + let newArtifact = new ArtifactModel(artifactObj); + let artifacts = this.getArtifactsByType(artifactObj.artifactGroupType); + if (newArtifact.mandatory || newArtifact.serviceApi) { + artifacts[newArtifact.artifactLabel] = newArtifact; + } + else { + delete artifacts[artifactLabel]; + } + deferred.resolve(newArtifact); + }; + this.componentService.deleteArtifact(this.uniqueId, artifactId, artifactLabel).then(onSuccess); + return deferred.promise; + }; + + public getArtifactByGroupType = (artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:ArtifactGroupModel):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getArtifactByGroupType(this.uniqueId, artifactGroupType).then(onSuccess, onFailed); + return deferred.promise; + }; + + public getComponentInstanceArtifactsByGroupType = (componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:ArtifactGroupModel):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstanceArtifactsByGroupType(this.uniqueId, componentInstanceId, artifactGroupType).then(onSuccess, onFailed); + return deferred.promise; + }; + + public addOrUpdateProperty = (property:PropertyModel):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + + let onError = (error:any):void => { + deferred.reject(error); + }; + + if (!property.uniqueId) { + let onSuccess = (property:PropertyModel):void => { + let newProperty = new PropertyModel(property); + this.properties.push(newProperty); + deferred.resolve(newProperty); + }; + this.componentService.addProperty(this.uniqueId, property).then(onSuccess, onError); + } + else { + let onSuccess = (newProperty:PropertyModel):void => { + // find exist instance property in parent component for update the new value ( find bu uniqueId ) + let existProperty:PropertyModel = <PropertyModel>_.find(this.properties, {uniqueId: newProperty.uniqueId}); + let propertyIndex = this.properties.indexOf(existProperty); + newProperty.readonly = this.uniqueId != newProperty.parentUniqueId; + this.properties[propertyIndex] = newProperty; + deferred.resolve(newProperty); + }; + this.componentService.updateProperty(this.uniqueId, property).then(onSuccess, onError); + } + return deferred.promise; + }; + + public addOrUpdateAttribute = (attribute:AttributeModel):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + + let onError = (error:any):void => { + deferred.reject(error); + }; + + if (!attribute.uniqueId) { + let onSuccess = (attribute:AttributeModel):void => { + let newAttribute = new AttributeModel(attribute); + this.attributes.push(newAttribute); + deferred.resolve(newAttribute); + }; + this.componentService.addAttribute(this.uniqueId, attribute).then(onSuccess, onError); + } + else { + let onSuccess = (newAttribute:AttributeModel):void => { + let existAttribute:AttributeModel = <AttributeModel>_.find(this.attributes, {uniqueId: newAttribute.uniqueId}); + let attributeIndex = this.attributes.indexOf(existAttribute); + newAttribute.readonly = this.uniqueId != newAttribute.parentUniqueId; + this.attributes[attributeIndex] = newAttribute; + deferred.resolve(newAttribute); + }; + this.componentService.updateAttribute(this.uniqueId, attribute).then(onSuccess, onError); + } + return deferred.promise; + }; + + public deleteProperty = (propertyId:string):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + let onSuccess = ():void => { + console.log("Property deleted"); + delete _.remove(this.properties, {uniqueId: propertyId})[0]; + deferred.resolve(); + }; + let onFailed = ():void => { + console.log("Failed to delete property"); + deferred.reject(); + }; + this.componentService.deleteProperty(this.uniqueId, propertyId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public deleteAttribute = (attributeId:string):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + let onSuccess = ():void => { + console.log("Attribute deleted"); + delete _.remove(this.attributes, {uniqueId: attributeId})[0]; + }; + let onFailed = ():void => { + console.log("Failed to delete attribute"); + }; + this.componentService.deleteAttribute(this.uniqueId, attributeId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public updateInstanceProperty = (property:PropertyModel):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + let onSuccess = (newProperty:PropertyModel):void => { + // find exist instance property in parent component for update the new value ( find bu uniqueId & path) + let existProperty:PropertyModel = <PropertyModel>_.find(this.componentInstancesProperties[newProperty.resourceInstanceUniqueId], { + uniqueId: newProperty.uniqueId, + path: newProperty.path + }); + let index = this.componentInstancesProperties[newProperty.resourceInstanceUniqueId].indexOf(existProperty); + this.componentInstancesProperties[newProperty.resourceInstanceUniqueId][index] = newProperty; + deferred.resolve(newProperty); + }; + let onFailed = (error:any):void => { + console.log('Failed to update property value'); + deferred.reject(error); + }; + this.componentService.updateInstanceProperty(this.uniqueId, property).then(onSuccess, onFailed); + return deferred.promise; + }; + + public updateInstanceAttribute = (attribute:AttributeModel):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + let onSuccess = (newAttribute:AttributeModel):void => { + let existAttribute:AttributeModel = <AttributeModel>_.find(this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId], {uniqueId: newAttribute.uniqueId}); + let index = this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId].indexOf(existAttribute); + this.componentInstancesAttributes[newAttribute.resourceInstanceUniqueId][index] = newAttribute; + deferred.resolve(newAttribute); + }; + let onFailed = (error:any):void => { + console.log('Failed to update attribute value'); + deferred.reject(error); + }; + this.componentService.updateInstanceAttribute(this.uniqueId, attribute).then(onSuccess, onFailed); + return deferred.promise; + }; + + public downloadInstanceArtifact = (artifactId:string):ng.IPromise<IFileDownload> => { + return this.componentService.downloadInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId); + }; + + public deleteInstanceArtifact = (artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let onSuccess = (artifactObj:ArtifactModel):void => { + let newArtifact = new ArtifactModel(artifactObj); + let artifacts = this.selectedInstance.deploymentArtifacts; + if (newArtifact.mandatory || newArtifact.serviceApi) {//????????? + artifacts[newArtifact.artifactLabel] = newArtifact; + } + else { + delete artifacts[artifactLabel]; + } + deferred.resolve(newArtifact); + }; + this.componentService.deleteInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifactId, artifactLabel).then(onSuccess); + return deferred.promise; + }; + + public addOrUpdateInstanceArtifact = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let onSuccess = (artifactObj:ArtifactModel):void => { + switch (artifactObj.artifactGroupType) { + case ArtifactGroupType.DEPLOYMENT: + this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj; + break; + case ArtifactGroupType.INFORMATION: + this.selectedInstance.artifacts[artifactObj.artifactLabel] = artifactObj; + break; + } + deferred.resolve(artifactObj); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + if (artifact.uniqueId) { + this.componentService.updateInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); + } else { + this.componentService.addInstanceArtifact(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); + } + return deferred.promise; + }; + + public uploadInstanceEnvFile = (artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let onSuccess = (artifactObj:ArtifactModel):void => { + this.selectedInstance.deploymentArtifacts[artifactObj.artifactLabel] = artifactObj; + deferred.resolve(artifactObj); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + this.componentService.uploadInstanceEnvFile(this.uniqueId, this.selectedInstance.uniqueId, artifact).then(onSuccess, onError); + return deferred.promise; + }; + + //this function will update the instance version than the function call getComponent to update the current component and return the new instance version + public changeComponentInstanceVersion = (componentUid:string):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + let onFailed = (error:any):void => { + deferred.reject(error); + }; + let onSuccess = (componentInstance:ComponentInstance):void => { + let onSuccess = (component:Component):void => { + component.setSelectedInstance(componentInstance); + deferred.resolve(component); + }; + this.getComponent().then(onSuccess, onFailed); + }; + this.componentService.changeResourceInstanceVersion(this.uniqueId, this.selectedInstance.uniqueId, componentUid).then(onSuccess, onFailed); + return deferred.promise; + }; + + public createComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + let onSuccess = (instance:ComponentInstance):void => { + this.componentInstances.push(instance); + deferred.resolve(instance); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.createComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed); + return deferred.promise; + }; + + public updateComponentInstance = (componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + let onSuccess = (updatedInstance:ComponentInstance):void => { + let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => { + return instance.uniqueId === updatedInstance.uniqueId; + }); + + let index = this.componentInstances.indexOf(componentInstance); + this.componentInstances[index] = componentInstance; + deferred.resolve(updatedInstance); + + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.updateComponentInstance(this.uniqueId, componentInstance).then(onSuccess, onFailed); + return deferred.promise; + }; + + public updateMultipleComponentInstances = (instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>> => { + let deferred = this.$q.defer(); + let onSuccess = (updatedInstances:Array<ComponentInstance>):void => { + _.forEach(updatedInstances, (updatedComponentInstance) => { + let componentInstance:ComponentInstance = _.find(this.componentInstances, (instance:ComponentInstance) => { + return instance.uniqueId === updatedComponentInstance.uniqueId; + }); + + let index = this.componentInstances.indexOf(componentInstance); + this.componentInstances[index] = componentInstance; + + }); + deferred.resolve(updatedInstances); + + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.updateMultipleComponentInstances(this.uniqueId, instances).then(onSuccess, onFailed); + return deferred.promise; + }; + + public deleteComponentInstance = (componentInstanceId:string):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + let onSuccess = ():void => { + let onSuccess = (component:Component):void => { + this.componentInstances = CommonUtils.initComponentInstances(component.componentInstances); + this.componentInstancesProperties = new PropertiesGroup(component.componentInstancesProperties); + this.componentInstancesAttributes = new AttributesGroup(component.componentInstancesAttributes); + this.groups = component.groups; + this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(component.componentInstancesRelations); + deferred.resolve(); + }; + this.getComponent().then(onSuccess); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.deleteComponentInstance(this.uniqueId, componentInstanceId).then(onSuccess, onFailed); + return deferred.promise; + }; + + + public createRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => { + let deferred = this.$q.defer(); + let onSuccess = (relation:RelationshipModel):void => { + console.info('Link created successfully', relation); + if (!this.componentInstancesRelations) { + this.componentInstancesRelations = []; + } + this.componentInstancesRelations.push(new RelationshipModel(relation)); + deferred.resolve(relation); + }; + let onFailed = (error:any):void => { + console.info('Failed to create relation', error); + deferred.reject(error); + }; + this.componentService.createRelation(this.uniqueId, relation).then(onSuccess, onFailed); + return deferred.promise; + }; + + public deleteRelation = (relation:RelationshipModel):ng.IPromise<RelationshipModel> => { + let deferred = this.$q.defer(); + let onSuccess = (responseRelation:RelationshipModel):void => { + console.log("Link Deleted In Server"); + let relationToDelete = _.find(this.componentInstancesRelations, (item) => { + return item.fromNode === relation.fromNode && item.toNode === relation.toNode && _.some(item.relationships, (relationship)=> { + return angular.equals(relation.relationships[0], relationship); + }); + }); + let index = this.componentInstancesRelations.indexOf(relationToDelete); + if (relationToDelete != undefined && index > -1) { + if (relationToDelete.relationships.length == 1) { + this.componentInstancesRelations.splice(index, 1); + } else { + this.componentInstancesRelations[index].relationships = + _.reject(this.componentInstancesRelations[index].relationships, relation.relationships[0]); + } + } else { + console.error("Error while deleting relation - the return delete relation from server was not found in UI") + } + deferred.resolve(relation); + }; + let onFailed = (error:any):void => { + console.error("Failed To Delete Link"); + deferred.reject(error); + }; + this.componentService.deleteRelation(this.uniqueId, relation).then(onSuccess, onFailed); + return deferred.promise; + }; + + public updateRequirementsCapabilities = ():ng.IPromise<any> => { + let deferred = this.$q.defer(); + let onSuccess = (response:any):void => { + this.capabilities = response.capabilities; + this.requirements = response.requirements; + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getRequirementsCapabilities(this.uniqueId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public getModuleForDisplay = (moduleId:string):ng.IPromise<DisplayModule> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:DisplayModule):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getModuleForDisplay(this.uniqueId, moduleId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public getModuleInstanceForDisplay = (componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:DisplayModule):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstanceModule(this.uniqueId, componentInstanceId, moduleId).then(onSuccess, onFailed); + return deferred.promise; + }; + + + // this function get all instances filtered by inputs and properties (optional) - if no search string insert - this function will + // get all the instances of the component (in service only VF instances) + public getComponentInstancesFilteredByInputsAndProperties = (searchText?:string):ng.IPromise<Array<ComponentInstance>> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:Array<ComponentInstance>):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstancesFilteredByInputsAndProperties(this.uniqueId, searchText).then(onSuccess, onFailed); + return deferred.promise; + }; + + + // get inputs for instance - Pagination function + public getComponentInputs = ():ng.IPromise<Array<InputModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (inputsRes:Array<InputModel>):void => { + this.inputs = inputsRes; + deferred.resolve(inputsRes); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInputs(this.uniqueId).then(onSuccess, onFailed); + return deferred.promise; + }; + + + // get inputs instance - Pagination function + public getComponentInstanceInputs = (componentInstanceId:string, originComponentUid:string):ng.IPromise<Array<InputModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:Array<InputModel>):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstanceInputs(this.uniqueId, componentInstanceId, originComponentUid).then(onSuccess, onFailed); + return deferred.promise; + }; + + // get inputs inatnce - Pagination function + public getComponentInstanceInputProperties = (componentInstanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:Array<PropertyModel>):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstanceInputProperties(this.uniqueId, componentInstanceId, inputId).then(onSuccess, onFailed); + return deferred.promise; + }; + + // get inputs inatnce - Pagination function + public getComponentInstanceProperties = (componentInstanceId:string):ng.IPromise<Array<PropertyModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (response:Array<PropertyModel>):void => { + deferred.resolve(response); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInstanceProperties(this.uniqueId, componentInstanceId).then(onSuccess, onFailed); + return deferred.promise; + }; + + + public updateGroupMetadata = (module:Module):ng.IPromise<Module> => { + + let deferred = this.$q.defer(); + + let onSuccess = (updatedModule:Module):void => { + let groupIndex:number = _.indexOf(this.groups, _.find(this.groups, (module:Module) => { + return module.uniqueId === updatedModule.uniqueId; + })); + + if (groupIndex !== -1) { + this.groups[groupIndex] = updatedModule; + } + deferred.resolve(updatedModule); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + + this.componentService.updateGroupMetadata(this.uniqueId, module).then(onSuccess, onFailed); + + return deferred.promise; + }; + + //------------------------------------------ Help Functions ----------------------------------------------------------------// + + public isProduct = ():boolean => { + return this instanceof Product; + }; + + public isService = ():boolean => { + return this instanceof Service; + }; + + public isResource = ():boolean => { + return this instanceof Resource; + }; + + public getComponentSubType = ():string => { + return this.componentType; + }; + + public isAlreadyCertified = ():boolean => { + return parseInt(this.version) >= 1; + }; + + public isComplex = ():boolean => { + return true; + }; + + //sort string version value from hash to sorted version (i.e 1.9 before 1.11) + private sortVersions = (v1:string, v2:string):number => { + let ver1 = v1.split('.'); + let ver2 = v2.split('.'); + let diff = parseInt(_.first(ver1)) - parseInt(_.first(ver2)); + if (!diff) { + return parseInt(_.last(ver1)) - parseInt(_.last(ver2)); + } + return diff; + }; + + public getAllVersionsAsSortedArray = ():Array<any> => { + let res = []; + if (this.allVersions) { + let keys = Object.keys(this.allVersions).sort(this.sortVersions); + _.forEach(keys, (key)=> { + res.push({ + versionNumber: key, + versionId: this.allVersions[key] + }) + }); + } + return res; + }; + + public isLatestVersion = ():boolean => { + if (this.allVersions) { + return this.version === _.last(Object.keys(this.allVersions).sort(this.sortVersions)); + } else { + return true; + } + + }; + + public getAdditionalInformation = ():Array<AdditionalInformationModel> => { + let additionalInformationObject:any = _.find(this.additionalInformation, (obj:any):boolean => { + return obj.parentUniqueId == this.uniqueId; + }); + if (additionalInformationObject) { + return additionalInformationObject.parameters; + } + return []; + }; + + public handleTags = ():void => { + let isContainTag = _.find(this.tags, (tag)=> { + return tag === this.name; + }); + if (!isContainTag) { + this.tags.push(this.name); + } + }; + + public getArtifactsByType = (artifactGroupType:string):ArtifactGroupModel => { + switch (artifactGroupType) { + case ArtifactGroupType.DEPLOYMENT: + return this.deploymentArtifacts; + case ArtifactGroupType.INFORMATION: + return this.artifacts; + } + }; + + public getStatus = (sdcMenu:IAppMenu):string => { + let status:string = sdcMenu.LifeCycleStatuses[this.lifecycleState].text; + if (this.lifecycleState == "CERTIFIED" && sdcMenu.DistributionStatuses[this.distributionStatus]) { + status = sdcMenu.DistributionStatuses[this.distributionStatus].text; + } + return status; + }; + + public abstract setComponentDisplayData():void; + public abstract getTypeUrl():string; + + public setComponentMetadata(componentMetadata: ComponentMetadata) { + this.abstract = componentMetadata.abstract; + this.uniqueId = componentMetadata.uniqueId; + this.uuid = componentMetadata.uuid; + this.invariantUUID = componentMetadata.invariantUUID; + this.contactId = componentMetadata.contactId; + this.categories = componentMetadata.categories; + this.creatorUserId = componentMetadata.creatorUserId; + this.creationDate = componentMetadata.creationDate; + this.creatorFullName = componentMetadata.creatorFullName; + this.description = componentMetadata.description; + this.icon = componentMetadata.icon; + this.lastUpdateDate = componentMetadata.lastUpdateDate; + this.lastUpdaterUserId = componentMetadata.lastUpdaterUserId; + this.lastUpdaterFullName = componentMetadata.lastUpdaterFullName; + this.lifecycleState = componentMetadata.lifecycleState; + this.name = componentMetadata.name; + this.version = componentMetadata.version; + this.tags = angular.copy(componentMetadata.tags, this.tags); + this.allVersions = componentMetadata.allVersions; + this.componentType = componentMetadata.componentType; + this.distributionStatus = componentMetadata.distributionStatus; + this.highestVersion = componentMetadata.highestVersion; + this.vendorName = componentMetadata.vendorName; + this.vendorRelease = componentMetadata.vendorRelease; + this.derivedList = componentMetadata.derivedList; + this.normalizedName = componentMetadata.normalizedName; + this.systemName = componentMetadata.systemName; + this.projectCode = componentMetadata.projectCode; + this.categories = componentMetadata.categories; + + } + + public toJSON = ():any => { + this.componentService = undefined; + this.filterTerm = undefined; + this.iconSprite = undefined; + this.mainCategory = undefined; + this.subCategory = undefined; + this.selectedInstance = undefined; + this.showMenu = undefined; + this.$q = undefined; + this.selectedCategory = undefined; + return this; + }; +} + diff --git a/catalog-ui/src/app/models/components/displayComponent.ts b/catalog-ui/src/app/models/components/displayComponent.ts new file mode 100644 index 0000000000..8b2b522fd9 --- /dev/null +++ b/catalog-ui/src/app/models/components/displayComponent.ts @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 7/5/2016. + */ + +'use strict'; +import {ComponentType} from "../../utils/constants"; +import {ComponentMetadata} from "../component-metadata"; +import {RequirementsGroup} from "../requirement"; +import {CapabilitiesGroup} from "../capability"; + +export class LeftPaletteComponent { + + uniqueId:string; + displayName:string; + version:string; + mainCategory:string; + subCategory:string; + iconClass:string; + componentSubType:string; + searchFilterTerms:string; + certifiedIconClass:string; + icon:string; + isRequirmentAndCapabilitiesLoaded:boolean; + + uuid:string; + name:string; + lifecycleState:string; + allVersions:any; + componentType:string; + systemName:string; + + capabilities:CapabilitiesGroup; + requirements:RequirementsGroup; + + constructor(public component:ComponentMetadata) { + this.icon = component.icon; + this.version = component.version; + this.uniqueId = component.uniqueId; + this.isRequirmentAndCapabilitiesLoaded = false; + this.uuid = component.uuid; + this.name = component.name; + this.allVersions = component.allVersions; + this.componentType = component.componentType; + this.systemName = component.systemName; + + if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) { + this.mainCategory = component.categories[0].name; + this.subCategory = component.categories[0].subcategories[0].name; + } else { + this.mainCategory = 'Generic'; + this.subCategory = 'Generic'; + } + + this.componentSubType = component.resourceType ? component.resourceType: 'SERVICE'; + this.initDisplayName(component.name); + this.searchFilterTerms = (this.displayName + ' ' + component.description + ' ' + component.tags.join(' ')).toLowerCase() + ' ' + component.version; + this.initIconSprite(component.icon); + this.certifiedIconClass = component.lifecycleState != 'CERTIFIED' ? 'non-certified' : ''; + if (component.icon === 'vl' || component.icon === 'cp') { + this.certifiedIconClass = this.certifiedIconClass + " " + 'smaller-icon'; + } + } + + public initDisplayName = (name:string):void => { + let newName = + _.last(_.last(_.last(_.last(_.last(_.last(_.last(_.last(name.split('tosca.nodes.')) + .split('network.')).split('relationships.')).split('org.openecomp.')).split('resource.nfv.')) + .split('nodes.module.')).split('cp.')).split('vl.')); + if (newName) { + this.displayName = newName; + } else { + this.displayName = name; + } + }; + + public initIconSprite = (icon:string):void => { + switch (this.componentSubType) { + case ComponentType.SERVICE: + this.iconClass = "sprite-services-icons " + icon; + break; + case ComponentType.PRODUCT: + this.iconClass = "sprite-product-icons " + icon; + break; + default: + this.iconClass = "sprite-resource-icons " + icon; + } + } + + public getComponentSubType = ():string => { + return this.componentSubType; + }; +} diff --git a/catalog-ui/src/app/models/components/product.ts b/catalog-ui/src/app/models/components/product.ts new file mode 100644 index 0000000000..0f2c00e822 --- /dev/null +++ b/catalog-ui/src/app/models/components/product.ts @@ -0,0 +1,105 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {Component} from "./component"; +import {IProductService} from "../../services/components/product-service"; +import {IGroup, ISubCategory, IMainCategory, ICategoryBase} from "../category"; +import {ComponentMetadata} from "../component-metadata"; + +export class Product extends Component { + + public contacts:Array<string>; + public componentService:IProductService; + public fullName:string; + + constructor(componentService:IProductService, $q:ng.IQService, component?:Product) { + super(componentService, $q, component); + + if (component) { + this.fullName = component.fullName; + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; + this.contacts = component.contacts; + } + this.componentService = componentService; + this.iconSprite = "sprite-product-icons"; + } + + public deleteGroup = (uniqueId:string):void => { + _.forEach(this.categories, (category:IMainCategory) => { + _.forEach(category.subcategories, (subcategory:ISubCategory) => { + subcategory.groupings = _.reject(subcategory.groupings, (group:IGroup) => { + return group.uniqueId === uniqueId; + }); + if (subcategory.groupings.length == 0) { // if there is no groups, delete the subcategory + category.subcategories = _.reject(category.subcategories, (subcategoryObj:ISubCategory) => { + return subcategoryObj.uniqueId === subcategory.uniqueId; + }); + if (category.subcategories.length == 0) { // if there is no subcategory, delete the category + this.categories = _.reject(this.categories, (categoryObj:IMainCategory) => { + return categoryObj.uniqueId === category.uniqueId; + }); + } + } + }); + }); + }; + + private getCategoryObjectById = (categoriesArray:Array<ICategoryBase>, categoryUniqueId:string):ICategoryBase => { + let categorySelected = _.find(categoriesArray, (category) => { + return category.uniqueId === categoryUniqueId; + }); + return categorySelected; + }; + + public addGroup = (category:IMainCategory, subcategory:ISubCategory, group:IGroup):void => { + if (!this.categories) { + this.categories = new Array<IMainCategory>(); + } + let existingCategory:IMainCategory = <IMainCategory>this.getCategoryObjectById(this.categories, category.uniqueId); + let newGroup = angular.copy(group); + newGroup.filterTerms = undefined; + newGroup.isDisabled = undefined; + if (!existingCategory) { + let newCategory:IMainCategory = angular.copy(category); + newCategory.filteredGroup = undefined; + newCategory.subcategories = []; + let newSubcategory:ISubCategory = angular.copy(subcategory); + newSubcategory.groupings = []; + newSubcategory.groupings.push(newGroup); + newCategory.subcategories.push(newSubcategory); + this.categories.push(newCategory); + } + else { + let existingSubcategory:ISubCategory = <ISubCategory> this.getCategoryObjectById(existingCategory.subcategories, subcategory.uniqueId); + if (!existingSubcategory) { + let newSubcategory:ISubCategory = angular.copy(subcategory); + newSubcategory.groupings = []; + newSubcategory.groupings.push(newGroup); + existingCategory.subcategories.push(newSubcategory); + + } else { + let existingGroup:IGroup = <IGroup> this.getCategoryObjectById(existingSubcategory.groupings, group.uniqueId); + if (!existingGroup) { + existingSubcategory.groupings.push(newGroup); + } + } + } + }; + + getTypeUrl():string { + return 'products/'; + } + + public setComponentMetadata(componentMetadata:ComponentMetadata) { + super.setComponentMetadata(componentMetadata); + this.setComponentDisplayData(); + }; + + setComponentDisplayData():void { + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; + this.iconSprite = "sprite-product-icons"; + } +} + + diff --git a/catalog-ui/src/app/models/components/resource.ts b/catalog-ui/src/app/models/components/resource.ts new file mode 100644 index 0000000000..e594451e1a --- /dev/null +++ b/catalog-ui/src/app/models/components/resource.ts @@ -0,0 +1,157 @@ +/** + * Created by obarda on 2/3/2016. + */ +'use strict'; +import {InstancesInputsOrPropertiesMapData} from "../instance-inputs-properties-map"; +import {PropertyModel} from "../properties"; +import {DisplayModule} from "../modules/base-module"; +import {InputModel} from "../inputs"; +import {ResourceType} from "../../utils/constants"; +import {Component} from "./component"; +import {FileUploadModel} from "../../directives/file-upload/file-upload"; +import {IResourceService} from "../../services/components/resource-service"; +import {ComponentMetadata} from "../component-metadata"; + +export class Resource extends Component { + + public interfaces:any; + public derivedFrom:Array<string>; + public componentService:IResourceService; + public resourceType:string; + public payloadData:string; + public payloadName:string; + public importedFile:FileUploadModel; + + // Onboarding parameters + public csarUUID:string; + public csarVersion:string; + public csarPackageType:string; + public packageId:string; + + constructor(componentService:IResourceService, $q:ng.IQService, component?:Resource) { + super(componentService, $q, component); + if (component) { + + this.interfaces = component.interfaces; + this.derivedFrom = component.derivedFrom; + this.payloadData = component.payloadData ? component.payloadData : undefined; + this.payloadName = component.payloadName ? component.payloadName : undefined; + this.resourceType = component.resourceType; + this.csarUUID = component.csarUUID; + this.csarVersion = component.csarVersion; + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType; + if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) { + component.mainCategory = component.categories[0].name; + component.subCategory = component.categories[0].subcategories[0].name; + this.selectedCategory = component.mainCategory + "_#_" + component.subCategory; + this.importedFile = component.importedFile; + } + } else { + this.resourceType = ResourceType.VF; + } + + this.componentService = componentService; + this.iconSprite = "sprite-resource-icons"; + } + + public setComponentMetadata(componentMetadata: ComponentMetadata) { + super.setComponentMetadata(componentMetadata); + this.resourceType = componentMetadata.resourceType; + this.csarUUID = componentMetadata.csarUUID; + this.csarVersion = componentMetadata.csarVersion; + this.derivedFrom = componentMetadata.derivedFrom; + this.setComponentDisplayData(); + }; + + public getComponentSubType = ():string => { + return this.resourceType; + }; + + public isComplex = ():boolean => { + return this.resourceType === ResourceType.VF; + }; + + public isVl = ():boolean => { + return ResourceType.VL == this.resourceType; + }; + + public isCsarComponent = ():boolean => { + return !!this.csarUUID; + }; + + public createComponentOnServer = ():ng.IPromise<Component> => { + let deferred = this.$q.defer(); + let onSuccess = (component:Resource):void => { + this.payloadData = undefined; + this.payloadName = undefined; + deferred.resolve(component); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + + this.handleTags(); + if (this.importedFile) { + this.payloadData = this.importedFile.base64; + this.payloadName = this.importedFile.filename; + } + this.componentService.createComponent(this).then(onSuccess, onError); + return deferred.promise; + }; + + + public updateResourceGroupProperties = (module:DisplayModule, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> => { + let deferred = this.$q.defer(); + let onSuccess = (updatedProperties:Array<PropertyModel>):void => { + _.forEach(updatedProperties, (property:PropertyModel) => { // Replace all updated properties on the module we needed to update + _.extend(_.find(module.properties, {uniqueId: property.uniqueId}), property); + + }); + //_.extend(_.findWhere(this.groups, {uniqueId: module.uniqueId }), module); // replace the module on the component so all data will be updates if the module sent to the function is a copy + deferred.resolve(updatedProperties); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + + this.componentService.updateResourceGroupProperties(this.uniqueId, module.uniqueId, properties).then(onSuccess, onError); + return deferred.promise; + }; + + // For now we only implement the logic in service level + public createInputsFormInstances = (instanceInputsPropertiesMap:InstancesInputsOrPropertiesMapData):ng.IPromise<Array<InputModel>> => { + let deferred = this.$q.defer(); + return deferred.promise; + }; + + getTypeUrl():string { + return 'resources/'; + } + + + setComponentDisplayData():void { + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType; + if (this.categories && this.categories[0] && this.categories[0].subcategories && this.categories[0].subcategories[0]) { + this.mainCategory = this.categories[0].name; + this.subCategory = this.categories[0].subcategories[0].name; + this.selectedCategory = this.mainCategory + "_#_" + this.subCategory; + this.iconSprite = "sprite-resource-icons"; + } + }; + + public toJSON = ():any => { + this.componentService = undefined; + this.filterTerm = undefined; + this.iconSprite = undefined; + this.mainCategory = undefined; + this.subCategory = undefined; + this.selectedInstance = undefined; + this.showMenu = undefined; + this.$q = undefined; + this.selectedCategory = undefined; + this.importedFile = undefined; + return this; + }; +} + + diff --git a/catalog-ui/src/app/models/components/service.ts b/catalog-ui/src/app/models/components/service.ts new file mode 100644 index 0000000000..a4dd3155d7 --- /dev/null +++ b/catalog-ui/src/app/models/components/service.ts @@ -0,0 +1,150 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {IServiceService} from "../../services/components/service-service"; +import {Component, PropertyModel, DisplayModule, InputsAndProperties, InputModel, InstancesInputsOrPropertiesMapData, InstancesInputsPropertiesMap, + Distribution, DistributionComponent, ArtifactGroupModel} from "../../models"; +import {ArtifactGroupType} from "../../utils/constants"; +import {ComponentMetadata} from "../component-metadata"; + +export class Service extends Component { + + public serviceApiArtifacts:ArtifactGroupModel; + public componentService:IServiceService; + public ecompGeneratedNaming:boolean; + public namingPolicy:string; + + constructor(componentService:IServiceService, $q:ng.IQService, component?:Service) { + super(componentService, $q, component); + this.ecompGeneratedNaming = true; + if (component) { + this.serviceApiArtifacts = new ArtifactGroupModel(component.serviceApiArtifacts); + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; + this.ecompGeneratedNaming = component.ecompGeneratedNaming; + this.namingPolicy = component.namingPolicy; + if (component.categories && component.categories[0]) { + this.mainCategory = component.categories[0].name; + this.selectedCategory = this.mainCategory; + } + } + this.componentService = componentService; + this.iconSprite = "sprite-services-icons"; + } + + public getDistributionsList = ():ng.IPromise<Array<Distribution>> => { + return this.componentService.getDistributionsList(this.uuid); + }; + + public getDistributionsComponent = (distributionId:string):ng.IPromise<Array<DistributionComponent>> => { + return this.componentService.getDistributionComponents(distributionId); + }; + + public markAsDeployed = (distributionId:string):ng.IPromise<any> => { + return this.componentService.markAsDeployed(this.uniqueId, distributionId); + }; + + /* we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service + * we also need to remove already selected inputs (the inputs that already create on server, and disabled in the view - but they are selected so they are still in the view model + */ + public createInputsFormInstances = (instancesInputsMap:InstancesInputsOrPropertiesMapData, instancePropertiesMap:InstancesInputsOrPropertiesMapData):ng.IPromise<Array<InputModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (inputsCreated:Array<InputModel>):void => { + this.inputs = inputsCreated.concat(this.inputs); + deferred.resolve(inputsCreated); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + + let propertiesAndInputsMap:InstancesInputsPropertiesMap = new InstancesInputsPropertiesMap(instancesInputsMap, instancePropertiesMap); + propertiesAndInputsMap = propertiesAndInputsMap.cleanUnnecessaryDataBeforeSending(); // We need to create a copy of the map, without the already selected inputs / properties, and to send the clean map + this.componentService.createInputsFromInstancesInputs(this.uniqueId, propertiesAndInputsMap).then(onSuccess, onFailed); + return deferred.promise; + }; + + // we need to change the name of the input to vfInstanceName + input name before sending to server in order to create the inputs on the service + public getServiceInputInputsAndProperties = (inputId:string):ng.IPromise<Array<InputModel>> => { + let deferred = this.$q.defer(); + let onSuccess = (inputsAndProperties:InputsAndProperties):void => { + let input:InputModel = _.find(this.inputs, (input:InputModel) => { + return input.uniqueId === inputId; + }); + input.inputs = inputsAndProperties.inputs; + input.properties = inputsAndProperties.properties; + deferred.resolve(inputsAndProperties); + }; + let onFailed = (error:any):void => { + deferred.reject(error); + }; + this.componentService.getComponentInputInputsAndProperties(this.uniqueId, inputId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public deleteServiceInput = (inputId:string):ng.IPromise<InputModel> => { + let deferred = this.$q.defer(); + + let onSuccess = (deletedInput:InputModel):void => { + delete _.remove(this.inputs, {uniqueId: deletedInput.uniqueId})[0]; + deferred.resolve(deletedInput); + }; + + let onFailed = (error:any):void => { + deferred.reject(error); + }; + + this.componentService.deleteComponentInput(this.uniqueId, inputId).then(onSuccess, onFailed); + return deferred.promise; + }; + + public getArtifactsByType = (artifactGroupType:string):ArtifactGroupModel => { + switch (artifactGroupType) { + case ArtifactGroupType.DEPLOYMENT: + return this.deploymentArtifacts; + case ArtifactGroupType.INFORMATION: + return this.artifacts; + case ArtifactGroupType.SERVICE_API: + return this.serviceApiArtifacts; + } + }; + + public updateGroupInstanceProperties = (resourceInstanceId:string, group:DisplayModule, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> => { + + let deferred = this.$q.defer(); + let onSuccess = (updatedProperties:Array<PropertyModel>):void => { + _.forEach(updatedProperties, (property:PropertyModel) => { // Replace all updated properties on the we needed to update + _.extend(_.find(group.properties, {uniqueId: property.uniqueId}), property); + }); + deferred.resolve(updatedProperties); + }; + let onError = (error:any):void => { + deferred.reject(error); + }; + + this.componentService.updateGroupInstanceProperties(this.uniqueId, resourceInstanceId, group.groupInstanceUniqueId, properties).then(onSuccess, onError); + return deferred.promise; + }; + + getTypeUrl():string { + return 'services/'; + } + + + public setComponentMetadata(componentMetadata: ComponentMetadata) { + super.setComponentMetadata(componentMetadata); + this.ecompGeneratedNaming = componentMetadata.ecompGeneratedNaming; + this.namingPolicy = componentMetadata.namingPolicy; + this.setComponentDisplayData(); + } + + setComponentDisplayData():void { + this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version; + if (this.categories && this.categories[0]) { + this.mainCategory = this.categories[0].name; + this.selectedCategory = this.mainCategory; + } + this.iconSprite = "sprite-services-icons"; + } +} + diff --git a/catalog-ui/src/app/models/componentsInstances/componentInstance.ts b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts new file mode 100644 index 0000000000..22c6232548 --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/componentInstance.ts @@ -0,0 +1,113 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {ArtifactGroupModel, CapabilitiesGroup,RequirementsGroup, PropertyModel, InputModel, Module} from "../../models"; +import {ResourceType} from "../../utils/constants"; + +export class ComponentInstance { + + public componentUid:string; + public componentName:string; + public posX:number; + public posY:number; + public componentVersion:string; + public description:string; + public icon:string; + public name:string; + public normalizedName:string; + public originType:string; + public deploymentArtifacts:ArtifactGroupModel; + public artifacts:ArtifactGroupModel; + public propertyValueCounter:number; + public uniqueId:string; + public creationTime:number; + public modificationTime:number; + public capabilities:CapabilitiesGroup; + public requirements:RequirementsGroup; + public customizationUUID:string; + //custom properties + public certified:boolean; + public iconSprite:string; + public inputs:Array<InputModel>; + public properties:Array<PropertyModel>; + public groupInstances:Array<Module>; + + constructor(componentInstance?:ComponentInstance) { + + if (componentInstance) { + this.componentUid = componentInstance.componentUid; + this.componentName = componentInstance.componentName; + + this.componentVersion = componentInstance.componentVersion; + this.description = componentInstance.description; + this.icon = componentInstance.icon; + this.name = componentInstance.name; + this.normalizedName = componentInstance.normalizedName; + this.originType = componentInstance.originType; + this.deploymentArtifacts = new ArtifactGroupModel(componentInstance.deploymentArtifacts); + this.artifacts = new ArtifactGroupModel(componentInstance.artifacts); + this.uniqueId = componentInstance.uniqueId; + this.creationTime = componentInstance.creationTime; + this.modificationTime = componentInstance.modificationTime; + this.propertyValueCounter = componentInstance.propertyValueCounter; + this.capabilities = new CapabilitiesGroup(componentInstance.capabilities); + this.requirements = new RequirementsGroup(componentInstance.requirements); + this.certified = componentInstance.certified; + this.customizationUUID = componentInstance.customizationUUID; + this.updatePosition(componentInstance.posX, componentInstance.posY); + this.groupInstances = componentInstance.groupInstances; + } + } + + public isUcpe = ():boolean => { + if (this.originType === 'VF' && this.capabilities && this.capabilities['tosca.capabilities.Container'] && this.name.toLowerCase().indexOf('ucpe') > -1) { + return true; + } + return false; + }; + + public isVl = ():boolean => { + return this.originType === 'VL'; + }; + + public isComplex = () : boolean => { + return this.originType === ResourceType.VF; + } + + public setInstanceRC = ():void=> { + _.forEach(this.requirements, (requirementValue:Array<any>, requirementKey)=> { + _.forEach(requirementValue, (requirement)=> { + if (!requirement.ownerName) { + requirement['ownerId'] = this.uniqueId; + requirement['ownerName'] = this.name; + } + }); + }); + _.forEach(this.capabilities, (capabilityValue:Array<any>, capabilityKey)=> { + _.forEach(capabilityValue, (capability)=> { + if (!capability.ownerName) { + capability['ownerId'] = this.uniqueId; + capability['ownerName'] = this.name; + } + }); + }); + }; + + public updatePosition(posX:number, posY:number) { + this.posX = posX; + this.posY = posY; + } + + public toJSON = ():any => { + let temp = angular.copy(this); + temp.certified = undefined; + temp.iconSprite = undefined; + temp.inputs = undefined; + temp.groupInstances = undefined; + temp.properties = undefined; + temp.requirements = undefined; + temp.capabilities = undefined; + return temp; + }; +} diff --git a/catalog-ui/src/app/models/componentsInstances/productInstance.ts b/catalog-ui/src/app/models/componentsInstances/productInstance.ts new file mode 100644 index 0000000000..7b73f83988 --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/productInstance.ts @@ -0,0 +1,13 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {ComponentInstance} from "./componentInstance"; + +export class ProductInstance extends ComponentInstance { + + constructor(componentInstance?:ProductInstance) { + super(componentInstance); + this.iconSprite = "sprite-product-icons"; + } +} diff --git a/catalog-ui/src/app/models/componentsInstances/resourceInstance.ts b/catalog-ui/src/app/models/componentsInstances/resourceInstance.ts new file mode 100644 index 0000000000..be4bde9af9 --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/resourceInstance.ts @@ -0,0 +1,15 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {ComponentInstance} from "./componentInstance"; + +export class ResourceInstance extends ComponentInstance { + + constructor(componentInstance?:ResourceInstance) { + super(componentInstance); + + this.iconSprite = "sprite-resource-icons"; + } +} + diff --git a/catalog-ui/src/app/models/componentsInstances/serviceInstance.ts b/catalog-ui/src/app/models/componentsInstances/serviceInstance.ts new file mode 100644 index 0000000000..060519b83d --- /dev/null +++ b/catalog-ui/src/app/models/componentsInstances/serviceInstance.ts @@ -0,0 +1,14 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {ComponentInstance} from "./componentInstance"; + +export class ServiceInstance extends ComponentInstance { + + constructor(componentInstance?:ServiceInstance) { + super(componentInstance); + this.iconSprite = "sprite-services-icons"; + } +} + diff --git a/catalog-ui/src/app/models/csar-component.ts b/catalog-ui/src/app/models/csar-component.ts new file mode 100644 index 0000000000..301da959f7 --- /dev/null +++ b/catalog-ui/src/app/models/csar-component.ts @@ -0,0 +1,15 @@ +'use strict'; + +export interface ICsarComponent { + displayName:string; + description:string; + vspName:string; + version:string; + packageId:string; + category:string; + subCategory:string + vendorName:string; + packageType:string; + vendorRelease:string; +} + diff --git a/catalog-ui/src/app/models/data-type-properties.ts b/catalog-ui/src/app/models/data-type-properties.ts new file mode 100644 index 0000000000..a36e87b0fc --- /dev/null +++ b/catalog-ui/src/app/models/data-type-properties.ts @@ -0,0 +1,39 @@ +/** + * Created by rcohen on 9/25/2016. + */ +'use strict'; +import {SchemaPropertyGroupModel} from "./aschema-property"; +import {PropertyModel} from "./properties"; + +export class DataTypePropertyModel extends PropertyModel{ + //custom + simpleType:string; + valueObjectRef:any; + childrenProperties:Array<DataTypePropertyModel>; + isAllChildrenLevelsCalculated:boolean; + treeNodeId:string; + parent:DataTypePropertyModel; + expandedChildPropertyId:string; + + constructor(property?:PropertyModel); + constructor(name:string, type:string, treeNodeId:string, parent:DataTypePropertyModel, valueObjectRef:any, schema?:SchemaPropertyGroupModel); + constructor(nameOrPropertyObj?:string | PropertyModel, type?:string, treeNodeId?:string, parent?:DataTypePropertyModel, valueObjectRef?:any, schema?:SchemaPropertyGroupModel){ + super(typeof nameOrPropertyObj === "string" ? null : nameOrPropertyObj); + if ( typeof nameOrPropertyObj === "string" ) { + this.name = nameOrPropertyObj; + this.type = type; + this.treeNodeId = treeNodeId; + this.parent = parent; + this.valueObjectRef = valueObjectRef; + this.schema = schema; + } + } + + public updateExpandedChildPropertyId = (childPropertyId:string):void =>{ + if(this.expandedChildPropertyId == childPropertyId){ + this.expandedChildPropertyId = ""; + }else{ + this.expandedChildPropertyId = childPropertyId; + } + } +} diff --git a/catalog-ui/src/app/models/data-types-map.ts b/catalog-ui/src/app/models/data-types-map.ts new file mode 100644 index 0000000000..8aa38e26e7 --- /dev/null +++ b/catalog-ui/src/app/models/data-types-map.ts @@ -0,0 +1,17 @@ +/** + * Created by rcohen on 9/25/2016. + */ +'use strict'; +import {DataTypeModel} from "./data-types"; + +export class DataTypesMapData { + [dataTypeId:string]:Array<DataTypeModel>; +} + +export class DataTypesMap { + dataTypesMap:DataTypesMapData; + + constructor(dataTypesMap:DataTypesMapData) { + this.dataTypesMap = dataTypesMap; + } +} diff --git a/catalog-ui/src/app/models/data-types.ts b/catalog-ui/src/app/models/data-types.ts new file mode 100644 index 0000000000..060ebf7e7d --- /dev/null +++ b/catalog-ui/src/app/models/data-types.ts @@ -0,0 +1,34 @@ +/** + * Created by rcohen on 9/25/2016. + */ +'use strict'; +import {PropertyBEModel} from "./properties-inputs/property-be-model"; + +export class DataTypeModel { + + //server data + name:string; + uniqueId:string; + derivedFromName:string; + derivedFrom:DataTypeModel; + creationTime:string; + modificationTime:string; + properties: Array<PropertyBEModel>; + + constructor(dataType:DataTypeModel) { + if (dataType) { + this.uniqueId = dataType.uniqueId; + this.name = dataType.name; + this.derivedFromName = dataType.derivedFromName; + this.creationTime = dataType.creationTime; + this.modificationTime = dataType.modificationTime; + this.properties = dataType.properties; + } + } + + public toJSON = ():any => { + + return this; + }; +} + diff --git a/catalog-ui/src/app/models/distribution.ts b/catalog-ui/src/app/models/distribution.ts new file mode 100644 index 0000000000..b6854c68a2 --- /dev/null +++ b/catalog-ui/src/app/models/distribution.ts @@ -0,0 +1,43 @@ +'use strict'; + +export class DistributionStatuses { + public omfComponentID:string; + public url:string; + public timestamp:string; + public status:string; + + constructor() { + } +} + + +export class DistributionComponent { + public omfComponentID:string; + public url:string; + public timestamp:string; + public status:string; + + constructor() { + } +} + +export class Distribution { + public distributionID:string; + public timestamp:string; + public userId:string; + public deployementStatus:string; + public distributionComponents:Array<DistributionComponent>; + public statusCount:any; + //custom data + public dateFormat:string; + + constructor() { + } + + public toJSON = ():any => { + this.dateFormat = undefined; + return this; + }; +} + + diff --git a/catalog-ui/src/app/models/export-excel.ts b/catalog-ui/src/app/models/export-excel.ts new file mode 100644 index 0000000000..7d0bc56a7b --- /dev/null +++ b/catalog-ui/src/app/models/export-excel.ts @@ -0,0 +1,12 @@ +/** + * Created by rcohen on 11/7/2016. + */ +'use strict'; + +export class ExportExcel { + fileName:string; + metaData:Array<string>;//array of text rows that display on the top of table + dataObj:any;//array of JSONs - the table data + tableHeaders:Array<string>; + groupByField:string;//[optional] get field name in order to split data to some tables group by this field +} diff --git a/catalog-ui/src/app/models/file-download.ts b/catalog-ui/src/app/models/file-download.ts new file mode 100644 index 0000000000..d63963e1ba --- /dev/null +++ b/catalog-ui/src/app/models/file-download.ts @@ -0,0 +1,6 @@ +'use strict'; + +export interface IFileDownload { + artifactName:string; + base64Contents:string; +} diff --git a/catalog-ui/src/app/models/filter-properties-assignment-data.ts b/catalog-ui/src/app/models/filter-properties-assignment-data.ts new file mode 100644 index 0000000000..067ac630de --- /dev/null +++ b/catalog-ui/src/app/models/filter-properties-assignment-data.ts @@ -0,0 +1,10 @@ +/** + * Created by rc2122 on 5/16/2017. + */ +export class FilterPropertiesAssignmentData { + propertyName:string; + selectedTypes:Array<string>; + constructor(){ + this.selectedTypes = []; + } +} diff --git a/catalog-ui/app/scripts/filters/trim-filter.ts b/catalog-ui/src/app/models/graph/assetPopoverObj.ts index fd231abc8d..c4fea9b994 100644 --- a/catalog-ui/app/scripts/filters/trim-filter.ts +++ b/catalog-ui/src/app/models/graph/assetPopoverObj.ts @@ -17,22 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Filters { - export class TrimFilter { +'use strict'; - constructor() { - let filter = <TrimFilter>( (text:string) => { - if (!angular.isString(text)) { - return text; - } +export class AssetPopoverObj { - return text.replace(/^\s+|\s+$/g, ''); // you could use .trim, but it's not going to work in IE<9 - }); + nodeId:string; + displayName:string; + menuPosition:Cy.Position; + menuSide:string; + isViewOnly:boolean; + VLArray:Array<any>; + CPArray:Array<any>; - return filter; - } + constructor(nodeId:string, displayName:string, menuPosition:Cy.Position, menuSide:string, isViewOnly?:boolean, VLArray?:Array<any>, CPArray?:Array<any>) { + this.nodeId = nodeId; + this.displayName = displayName; + this.menuPosition = {x: menuPosition.x, y: menuPosition.y}; + this.menuSide = menuSide; + this.isViewOnly = isViewOnly || false; + this.VLArray = VLArray || []; + this.CPArray = CPArray || []; } } diff --git a/catalog-ui/app/scripts/models/graph/graph-links/module-graph-links/module-ci-link-base.ts b/catalog-ui/src/app/models/graph/graph-links/common-base-link.ts index b85e7673f5..4d6d989daf 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/module-graph-links/module-ci-link-base.ts +++ b/catalog-ui/src/app/models/graph/graph-links/common-base-link.ts @@ -20,19 +20,31 @@ /** * Created by obarda on 6/29/2016. */ -/// <reference path="../../../../references"/> -module Sdc.Models { - export interface IModuleCiLinkBase extends ICommonCiLinkBase{ +export class CommonLinkBase { - } + img:string; + color:string; + classes:string; - export class ModuleCiLinkBase extends CommonCiLinkBase implements IModuleCiLinkBase { + //this is cytoscapejs fields + public source:string; + public target:string; + public type:string; + public isSdcElement:boolean; - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.color = Utils.Constants.GraphColors.BASE_LINK; - } + constructor() { + this.isSdcElement = true; + this.type = 'sdc-link'; } + + public setImage = (imgUrl:string) => { + this.img = imgUrl; + }; + + public setColor = (color:string) => { + this.color = color; + }; + } diff --git a/catalog-ui/app/scripts/models/graph/nodes/modules-graph-nodes/module-node-base.ts b/catalog-ui/src/app/models/graph/graph-links/common-ci-link-base.ts index cd6ab3ba85..12e66c86f9 100644 --- a/catalog-ui/app/scripts/models/graph/nodes/modules-graph-nodes/module-node-base.ts +++ b/catalog-ui/src/app/models/graph/graph-links/common-ci-link-base.ts @@ -17,36 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +import {Relationship, RelationshipModel} from "../relationship"; +import {CommonLinkBase} from "./common-base-link"; /** * Created by obarda on 6/29/2016. */ -/// <reference path="../../../../references"/> -module Sdc.Models.Graph { - 'use strict'; +export interface ICommonCiLinkBase { - export interface IModuleNodeBase { - } - - export class ModuleNodeBase extends CommonNodeBase implements IModuleNodeBase { +} - module:Module; +export class CommonCiLinkBase extends CommonLinkBase implements ICommonCiLinkBase { - constructor(module:Module) { - super(); - this.module = module; - this.init(); - } + relation:RelationshipModel; - private init() { - - this.id = this.module.uniqueId; - this.name = this.module.name; - this.displayName = this.module.name; - this.isGroup = true; - this.img = Utils.Constants.IMAGE_PATH + Utils.Constants.ImagesUrl.MODULE_ICON; - this.classes = "module-node"; - } + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(); + if (relation) { + if (singleRelationship) { + this.relation = new RelationshipModel(relation, singleRelationship); + } else { + this.relation = new RelationshipModel(relation); + } + this.source = relation.fromNode; + this.target = relation.toNode; + } else { + this.relation = new RelationshipModel(); } + } } diff --git a/catalog-ui/app/scripts/services/configuration-ui-service.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-link-base.ts index 51eb3dcd9c..04b28c7ceb 100644 --- a/catalog-ui/app/scripts/services/configuration-ui-service.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-link-base.ts @@ -17,33 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Services { - 'use strict' +import {ICommonCiLinkBase, CommonCiLinkBase} from "../common-ci-link-base"; +import {RelationshipModel, Relationship} from "../../relationship"; - interface IConfigurationUiService { - getConfigurationUi(): ng.IPromise<any>; - } - - export class ConfigurationUiService implements IConfigurationUiService{ +export interface ICompositionCiLinkBase extends ICommonCiLinkBase { + updateLinkDirection():void; +} - static '$inject' = ['$http', '$q','sdcConfig']; - private api: Models.IApi; +export class CompositionCiLinkBase extends CommonCiLinkBase implements ICompositionCiLinkBase { - constructor(private $http: ng.IHttpService, private $q: ng.IQService, sdcConfig: Models.IAppConfigurtaion){ - this.api = sdcConfig.api; - } + type:string; + visible:boolean; - getConfigurationUi = (): ng.IPromise<any> =>{ - let defer = this.$q.defer<any>(); - this.$http.get(this.api.root+this.api.GET_configuration_ui) - .success((result: any) => { - defer.resolve(result); - }); - return defer.promise; + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.visible = true; } - } + public setRelation = (relation:RelationshipModel) => { + this.relation = relation; + }; + updateLinkDirection():void { + this.source = this.relation.fromNode; + this.target = this.relation.toNode; + } } diff --git a/catalog-ui/app/scripts/filters/tests-id-filter.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.ts index 12c5e6fd79..e213fa9b33 100644 --- a/catalog-ui/app/scripts/filters/tests-id-filter.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-simple-link.ts @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -module Sdc.Filters { - export class TestsIdFilter{ +import {CompositionCiLinkBase} from "./composition-ci-link-base"; +import {Relationship, RelationshipModel} from "../../relationship"; +import {GraphColors} from "../../../../utils/constants"; - constructor() { - let filter = <TestsIdFilter>( (testId:string) => { - return testId.replace(/\s/g, '_').toLowerCase(); - }); +export class CompositionCiSimpleLink extends CompositionCiLinkBase { - return filter; - } + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.color = GraphColors.BASE_LINK; + this.classes = 'simple-link'; } - } diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link.ts index 7a30c20eee..b756dab129 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-host-link.ts @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +import {RelationshipModel, Relationship} from "../../relationship"; +import {CompositionCiLinkBase} from "./composition-ci-link-base"; /** * Created by obarda on 4/20/2016. */ -/// <reference path="../../../../references"/> -module Sdc.Models { - export class LinkUcpeHost extends CompositionCiLinkBase { +export class LinkUcpeHost extends CompositionCiLinkBase { - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.visible = false; - this.classes = "ucpe-host-link"; - } + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.visible = false; + this.classes = "ucpe-host-link"; } } diff --git a/catalog-ui/app/scripts/models/data-types-map.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts index d1bee48e41..fc8631781a 100644 --- a/catalog-ui/app/scripts/models/data-types-map.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-ucpe-link.ts @@ -17,23 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/** - * Created by rcohen on 9/25/2016. - */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - export class DataTypesMapData { - [dataTypeId:string]: Array<DataTypeModel>; - } +import {RelationshipModel, Relationship} from "../../relationship"; +import {CompositionCiLinkBase} from "./composition-ci-link-base"; +import {GraphColors} from "../../../../utils/constants"; +export class CompositionCiUcpeLink extends CompositionCiLinkBase { - export class DataTypesMap { - dataTypesMap:DataTypesMapData; + isFromUcpe:boolean; - constructor(dataTypesMap:DataTypesMapData) { - this.dataTypesMap = dataTypesMap; - } + constructor(relation?:RelationshipModel, from?:boolean, singleRelation?:Relationship) { + super(relation, singleRelation); + this.isFromUcpe = from; + this.target = relation.toNode; + this.source = singleRelation.requirementOwnerId; + this.relation.relationships = [singleRelation]; + this.color = GraphColors.BASE_LINK; } + updateLinkDirection():void { + } } diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-link.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-vl-link.ts index a347db6cb5..e0824ccbe8 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-link.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-vl-link.ts @@ -17,18 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../../../../references"/> -module Sdc.Models { - export class CompositionCiVLink extends CompositionCiLinkBase { +import {CompositionCiLinkBase} from "./composition-ci-link-base"; +import {RelationshipModel, Relationship} from "../../relationship"; +import {GraphColors} from "../../../../utils/constants"; - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.color = Utils.Constants.GraphColors.VL_LINK; - this.classes ='vl-link'; - } +export class CompositionCiVLink extends CompositionCiLinkBase { + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.color = GraphColors.VL_LINK; + this.classes = 'vl-link'; + } - } } diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link.ts b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link.ts index 2ebc796cb9..854eeecad5 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link.ts +++ b/catalog-ui/src/app/models/graph/graph-links/composition-graph-links/composition-ci-vl-ucpe-link.ts @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ +import {CompositionCiUcpeLink} from "./composition-ci-ucpe-link"; +import {Relationship, RelationshipModel} from "../../relationship"; +import {GraphColors} from "../../../../utils/constants"; /** * Created by obarda on 4/20/2016. */ -/// <reference path="../../../../references"/> -module Sdc.Models { - export class CompositionCiVlUcpeLink extends CompositionCiUcpeLink { +export class CompositionCiVlUcpeLink extends CompositionCiUcpeLink { - constructor(relation?:RelationshipModel, from?:boolean, singleRelation?:Relationship) { - super(relation, from, singleRelation); - this.color = Utils.Constants.GraphColors.VL_LINK; - } + constructor(relation?:RelationshipModel, from?:boolean, singleRelation?:Relationship) { + super(relation, from, singleRelation); + this.color = GraphColors.VL_LINK; } } diff --git a/catalog-ui/src/app/models/graph/graph-links/links-factory.ts b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts new file mode 100644 index 0000000000..7fdc0838ed --- /dev/null +++ b/catalog-ui/src/app/models/graph/graph-links/links-factory.ts @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 5/1/2016. + */ +'use strict'; +import {RelationshipModel, Relationship, CompositionCiLinkBase, CompositionCiNodeBase, LinkUcpeHost, CompositionCiUcpeLink, + CompositionCiVlUcpeLink, CompositionCiSimpleLink, ModuleCiLinkBase, ModuleCiVlLink, CompositionCiVLink} from "../../../models"; + +export class LinksFactory { + + constructor() { + } + + public createGraphLink = (cy:Cy.Instance, relation:RelationshipModel, singleRelation:Relationship):CompositionCiLinkBase => { + + let newRelation:CompositionCiLinkBase; + + let fromNode:CompositionCiNodeBase = cy.getElementById(relation.fromNode).data(); + let toNode:CompositionCiNodeBase = cy.getElementById(relation.toNode).data(); + + if ((relation.fromNode && fromNode.isUcpePart) || (relation.toNode && toNode.isUcpePart )) { //Link from or to node inside ucpe + + if (singleRelation && singleRelation.relationship.type && singleRelation.relationship.type == 'tosca.relationships.HostedOn') { + newRelation = new LinkUcpeHost(relation, singleRelation); + } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { + newRelation = new CompositionCiVlUcpeLink(relation, fromNode.isUcpePart, singleRelation); + } else { + newRelation = new CompositionCiUcpeLink(relation, fromNode.isUcpePart, singleRelation); + } + } else if (singleRelation.relationship.type && _.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { + newRelation = new CompositionCiVLink(relation, singleRelation); + } else { + newRelation = new CompositionCiSimpleLink(relation, singleRelation); + } + + return newRelation; + }; + + public createUcpeHostLink = (relation:RelationshipModel):LinkUcpeHost => { + return new LinkUcpeHost(relation); + }; + + public createVLLink = (relation:RelationshipModel):CompositionCiVLink => { + return new CompositionCiVLink(relation); + } + + + public createModuleGraphLinks = (relation:RelationshipModel, singleRelation:Relationship):ModuleCiLinkBase => { + + let newRelation:ModuleCiLinkBase; + + if (_.includes(singleRelation.relationship.type.toLowerCase(), 'link')) { + newRelation = new ModuleCiVlLink(relation, singleRelation); + } else { + newRelation = new ModuleCiLinkBase(relation, singleRelation); + } + + return newRelation; + }; + +} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/module-graph-links/module-ci-vl-link.ts b/catalog-ui/src/app/models/graph/graph-links/module-graph-links/module-ci-link-base.ts index a421610792..73cd2923eb 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/module-graph-links/module-ci-vl-link.ts +++ b/catalog-ui/src/app/models/graph/graph-links/module-graph-links/module-ci-link-base.ts @@ -20,18 +20,18 @@ /** * Created by obarda on 6/29/2016. */ -/// <reference path="../../../../references"/> -module Sdc.Models { +import {Relationship, RelationshipModel, ICommonCiLinkBase, CommonCiLinkBase} from "../../../../models"; +import {GraphColors} from "../../../../utils/constants"; - export interface IModuleCiVlLink extends ICommonCiLinkBase{ +export interface IModuleCiLinkBase extends ICommonCiLinkBase { - } +} - export class ModuleCiVlLink extends CommonCiLinkBase implements IModuleCiVlLink { +export class ModuleCiLinkBase extends CommonCiLinkBase implements IModuleCiLinkBase { - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.color = Utils.Constants.GraphColors.VL_LINK; - } + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.color = GraphColors.BASE_LINK; } + } diff --git a/catalog-ui/app/scripts/filters/product-category-name-filter.ts b/catalog-ui/src/app/models/graph/graph-links/module-graph-links/module-ci-vl-link.ts index afe8c7ef08..0bc675d465 100644 --- a/catalog-ui/app/scripts/filters/product-category-name-filter.ts +++ b/catalog-ui/src/app/models/graph/graph-links/module-graph-links/module-ci-vl-link.ts @@ -17,23 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -module Sdc.Filters { +import {Relationship, RelationshipModel, ICommonCiLinkBase, CommonCiLinkBase} from "../../../../models"; +import {GraphColors} from "../../../../utils/constants"; - export class ProductCategoryNameFilter{ +export interface IModuleCiVlLink extends ICommonCiLinkBase { - constructor() { - let filter = <CategoryNameFilter>( (name:string) => { - if(name){ - let newName:string = name.split('/')[1]; - if (newName){ - return newName; - } - return name; - } - }); +} - return filter; - } - } +export class ModuleCiVlLink extends CommonCiLinkBase implements IModuleCiVlLink { + constructor(relation?:RelationshipModel, singleRelationship?:Relationship) { + super(relation, singleRelationship); + this.color = GraphColors.VL_LINK; + } } diff --git a/catalog-ui/app/scripts/models/comments.ts b/catalog-ui/src/app/models/graph/graphTooltip.ts index 0f7643690d..790608e7f7 100644 --- a/catalog-ui/app/scripts/models/comments.ts +++ b/catalog-ui/src/app/models/graph/graphTooltip.ts @@ -17,17 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; +'use strict'; - export class AsdcComment{ - public userRemarks: string; +export class GraphTooltip { + position:Cy.Position; + isShow:boolean; + text:string; - constructor() { - } + constructor(); + constructor(position:Cy.Position, isShow:boolean, text:string); + constructor(position?:Cy.Position, isShow?:boolean, text?:string) { + this.position = position; + this.isShow = isShow; + this.text = text; } } - - diff --git a/catalog-ui/app/scripts/filters/clear-whitespaces-filter.ts b/catalog-ui/src/app/models/graph/link-menu.ts index 5c946e1715..b3352dd815 100644 --- a/catalog-ui/app/scripts/filters/clear-whitespaces-filter.ts +++ b/catalog-ui/src/app/models/graph/link-menu.ts @@ -17,23 +17,20 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Filters { +'use strict'; +import {Point} from "./point"; - export class ClearWhiteSpacesFilter { +export class LinkMenu { + position:Point; + isShow:boolean; + link:Cy.CollectionFirstEdge; - constructor() { - let filter = <ClearWhiteSpacesFilter>( (text:string) => { - if (!angular.isString(text)) { - return text; - } - - return text.replace(/ /g,''); // remove also whitespaces inside - }); - - return filter; - } + constructor(); + constructor(point:Point, isShow:boolean, link:Cy.CollectionFirstEdge); + constructor(point?:Point, isShow?:boolean, link?:Cy.CollectionFirstEdge) { + this.position = point ? point : new Point(); + this.isShow = isShow ? isShow : false; + this.link = link ? link : null; } } - diff --git a/catalog-ui/src/app/models/graph/match-relation.ts b/catalog-ui/src/app/models/graph/match-relation.ts new file mode 100644 index 0000000000..2de2e930b6 --- /dev/null +++ b/catalog-ui/src/app/models/graph/match-relation.ts @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {Requirement} from "../requirement"; +import {Capability} from "../capability"; +import {Relationship, RelationshipModel, RelationType} from "./relationship"; + +export class MatchBase { + requirement:Requirement; + isFromTo:boolean; + fromNode:string; + toNode:string; + + constructor(requirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) { + this.requirement = requirement; + this.isFromTo = isFromTo; + this.fromNode = fromNode; + this.toNode = toNode; + } + + public getDisplayText = (menuSide:string):string => { + return ''; + }; + + public isOwner = (id:string):boolean => { + return false; + } + +} + +export class MatchReqToReq extends MatchBase { + + secondRequirement:Requirement; + + constructor(requirement:Requirement, secondRequirement:Requirement, isFromTo:boolean, fromNode:string, toNode:string) { + super(requirement, isFromTo, fromNode, toNode); + this.secondRequirement = secondRequirement; + } + + public getDisplayText = (menuSide:string):string => { + if ('left' == menuSide) { + return this.requirement.getFullTitle(); + } + return this.secondRequirement.getFullTitle(); + }; + + public isOwner = (id:string):boolean => { + return this.secondRequirement.ownerId === id || this.requirement.ownerId === id; + } +} + +export class MatchReqToCapability extends MatchBase { + + capability:Capability; + + constructor(requirement:Requirement, capability:Capability, isFromTo:boolean, fromNode:string, toNode:string) { + super(requirement, isFromTo, fromNode, toNode); + this.capability = capability; + } + + public matchToRelation = ():Relationship => { + let relationship:Relationship = new Relationship(); + relationship.capability = this.capability.name; + relationship.capabilityOwnerId = this.capability.ownerId; + relationship.capabilityUid = this.capability.uniqueId; + relationship.relationship = new RelationType(this.capability.type); + relationship.requirement = this.requirement.name; + relationship.requirementOwnerId = this.requirement.ownerId; + relationship.requirementUid = this.requirement.uniqueId; + return relationship; + }; + + + public getDisplayText = (menuSide:string):string => { + if (this.isFromTo && 'left' == menuSide || !this.isFromTo && 'right' == menuSide) { + return this.requirement.getFullTitle(); + } + return this.capability.getFullTitle(); + + }; + + public isOwner = (id:string):boolean => { + return this.capability.ownerId === id || this.requirement.ownerId === id; + }; + + public matchToRelationModel = ():RelationshipModel => { + let relationshipModel:RelationshipModel = new RelationshipModel(); + let relationship:Relationship = this.matchToRelation(); + relationshipModel.setRelationshipModelParams(this.fromNode, this.toNode, [relationship]); + return relationshipModel; + }; +} + + diff --git a/catalog-ui/src/app/models/graph/nodes/base-common-node.ts b/catalog-ui/src/app/models/graph/nodes/base-common-node.ts new file mode 100644 index 0000000000..aee6b02086 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/base-common-node.ts @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 6/29/2016. + */ +'use strict'; +import {AngularJSBridge} from "../../../services/angular-js-bridge-service"; + +export abstract class CommonNodeBase { + + public displayName:string; + public name:string; + public img:string; + public certified:boolean; + public isGroup:boolean; + public imagesPath:string; + public isDraggable:boolean; //we need to to manage manually the dragging on the graph inside groups (ucpe-cp is not draggable) + + //cytoscape fields + public id:string; + public type:string; //type is for the edge edition extension, by type we put the green plus icon in position + public isSdcElement:boolean; //this fields is in order to filter sdc elements from all extensions elements + public classes:string; + public parent:string; + public allowConnection:boolean; //this is for egeEdition extension in order to decide if connection to a node is available + + constructor() { + + this.imagesPath = AngularJSBridge.getAngularConfig().imagesPath; + this.type = "basic-node"; + this.isSdcElement = true; + this.isDraggable = true; + this.allowConnection = true; + } + + public updateNameForDisplay = () => { + let context = document.createElement("canvas").getContext("2d"); + context.font = "13px Arial"; + + if (63 < context.measureText(this.name).width) { + let newLen = this.name.length - 3; + let newName = this.name.substring(0, newLen); + + while (60 < (context.measureText(newName).width)) { + newName = newName.substring(0, (--newLen)); + } + this.displayName = newName + '...'; + return; + } + + this.displayName = this.name; + }; +} diff --git a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-link-base.ts b/catalog-ui/src/app/models/graph/nodes/common-ci-node-base.ts index 3587198615..98fb583625 100644 --- a/catalog-ui/app/scripts/models/graph/graph-links/composition-graph-links/composition-ci-link-base.ts +++ b/catalog-ui/src/app/models/graph/nodes/common-ci-node-base.ts @@ -17,30 +17,28 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../../../../references"/> -module Sdc.Models { +import {CommonNodeBase} from "./base-common-node"; +import {ComponentInstance} from "../../componentsInstances/componentInstance"; +export abstract class CommonCINodeBase extends CommonNodeBase { - export interface ICompositionCiLinkBase extends ICommonCiLinkBase{ - updateLinkDirection():void; - } - - export class CompositionCiLinkBase extends CommonCiLinkBase implements ICompositionCiLinkBase { - - type:string; - visible:boolean; - - constructor(relation?:RelationshipModel, singleRelationship?:Models.Relationship) { - super(relation, singleRelationship); - this.visible = true; - } + public certified:boolean; + public template:string; + public componentInstance:ComponentInstance; + public group:string; - public setRelation = (relation: Models.RelationshipModel) => { - this.relation = relation; - }; + constructor(instance:ComponentInstance) { + super(); + this.componentInstance = instance; + this.id = this.componentInstance.uniqueId; + this.name = this.componentInstance.name; + this.img = ''; + this.certified = this.isCertified(this.componentInstance.componentVersion); + this.displayName = instance.name; + } - updateLinkDirection():void{ - this.source = this.relation.fromNode; - this.target = this.relation.toNode; - } + private isCertified(version:string):boolean { + return 0 === (parseFloat(version)) % 1; } + } + diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts new file mode 100644 index 0000000000..d17d97ac19 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {CommonCINodeBase} from "../common-ci-node-base"; +import {ImageCreatorService} from "app/directives/graphs-v2/image-creator/image-creator.service"; +import {ImagesUrl} from "app/utils"; +import {AngularJSBridge} from "app/services"; + +export interface ICompositionCiNodeBase { + +} + +export abstract class CompositionCiNodeBase extends CommonCINodeBase implements ICompositionCiNodeBase { + + public textPosition:string; //need to move to cp UCPE + public isUcpe:boolean; + public isInsideGroup:boolean; + public isUcpePart:boolean; + + constructor(instance:ComponentInstance, + public imageCreator:ImageCreatorService) { + super(instance); + this.init(); + } + + private init() { + + this.displayName = this.getDisplayName(); + this.isUcpe = false; + this.isGroup = false; + this.isUcpePart = false; + this.isInsideGroup = false; + + } + + public initImage(node:Cy.Collection):string { + + this.imageCreator.getImageBase64(this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png', + this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'uncertified.png') + .then(imageBase64 => { + this.img = imageBase64; + node.style({'background-image': this.img}); + }); + + return this.img; + } + + protected getDisplayName():string { + + let graphResourceName = AngularJSBridge.getFilter('graphResourceName'); + let resourceName = AngularJSBridge.getFilter('resourceName'); + return graphResourceName(resourceName(this.componentInstance.name)); + } + +} diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts new file mode 100644 index 0000000000..e6d0cc178f --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +import {CompositionCiNodeBase} from "./composition-ci-node-base"; +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import {AngularJSBridge} from "../../../../services/angular-js-bridge-service"; +import {ImagesUrl} from "../../../../utils/constants"; + +export class CompositionCiNodeCp extends CompositionCiNodeBase { + + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initCp(); + } + + private initCp():void { + let sdcConfig = AngularJSBridge.getAngularConfig(); + this.img = sdcConfig.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; + this.type = "basic-small-node"; + //if the cp from type cpEndPointInstances create with another template + if (sdcConfig.cpEndPointInstances.indexOf(this.componentInstance.icon) > -1) { + this.classes = 'cp-end-point-node'; + } else { + this.classes = 'cp-node'; + } + if (!this.certified) { + this.classes = this.classes + ' not-certified'; + } + + } +} diff --git a/catalog-ui/app/scripts/models/schema-attribute.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts index 725a7589e0..dd2fb6c6dd 100644 --- a/catalog-ui/app/scripts/models/schema-attribute.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts @@ -17,21 +17,25 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; - export class SchemaAttributeGroupModel{ - property: SchemaAttribute; +import {ImagesUrl} from "../../../../utils/constants"; +import {ComponentInstance, CompositionCiNodeBase} from "../../../../models"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +export class CompositionCiNodeService extends CompositionCiNodeBase { - constructor(schemaAttribute?:Models.SchemaAttribute) { - this.property = schemaAttribute; - } + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initService(); } - export class SchemaAttribute extends SchemaProperty{ + private initService():void { + + this.img = this.imagesPath + ImagesUrl.SERVICE_ICONS + this.componentInstance.icon + '.png'; + this.classes = 'service-node' + if (!this.certified) { + this.classes = this.classes + ' not-certified'; + } } } - - diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts index 9123ff7224..37882963d3 100644 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe-cp.ts @@ -17,23 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../../../../references"/> - -module Sdc.Models.Graph { - - export class CompositionCiNodeUcpeCp extends CompositionCiNodeCp { - - constructor(instance:Models.ComponentsInstances.ComponentInstance, - imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.isUcpePart = true; - this.classes = 'ucpe-cp'; // the css class for the node - this.parent = instance.uniqueId; - this.type = 'ucpe-cp-node'; //the type is for the handle (plus icon) extension - this.isDraggable = false; - } +import {CompositionCiNodeCp, ComponentInstance} from "./../../../../models"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +export class CompositionCiNodeUcpeCp extends CompositionCiNodeCp { + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.isUcpePart = true; + this.classes = 'ucpe-cp'; // the css class for the node + this.parent = instance.uniqueId; + this.type = 'ucpe-cp-node'; //the type is for the handle (plus icon) extension + this.isDraggable = false; } } diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts index 82afe11fe4..d209a10019 100644 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-ucpe.ts @@ -17,27 +17,34 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { - 'use strict'; - export interface IClientMessageModalModel extends IMessageModalModel { +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import {CompositionCiNodeBase} from "./composition-ci-node-base"; + +export class NodeUcpe extends CompositionCiNodeBase { + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initUcpe(); } - export interface IClientMessageModalViewModelScope extends IMessageModalViewModelScope { - clientMessageModalModel: IClientMessageModalModel; + private initUcpe():void { + this.isUcpe = true; + this.isGroup = true; + this.isUcpePart = true; + this.classes = 'ucpe-node'; + this.type = 'ucpe-node'; + this.allowConnection = false; + + if (!this.certified) { + this.classes = this.classes + ' not-certified-ucpe'; + } } - export class ClientMessageModalViewModel extends MessageModalViewModel { +} + - static '$inject' = ['$scope', '$modalInstance', 'clientMessageModalModel']; - constructor(private $scope:IClientMessageModalViewModelScope, - private $modalInstance:ng.ui.bootstrap.IModalServiceInstance, - private clientMessageModalModel:IClientMessageModalModel) { - super($scope, $modalInstance, clientMessageModalModel); - } - } -} diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts new file mode 100644 index 0000000000..cb0cd59b13 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +import {CompositionCiNodeBase} from "./composition-ci-node-base"; +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import {ImagesUrl} from "../../../../utils/constants"; + +export class CompositionCiNodeVf extends CompositionCiNodeBase { + + constructor(instance:ComponentInstance, + imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initVf(); + } + + private initVf():void { + this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; + this.classes = 'vf-node'; + if (!this.certified) { + this.classes = this.classes + ' not-certified'; + } + } + +} diff --git a/catalog-ui/app/scripts/models/additional-information.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts index bcac2e5d12..e08e6a4915 100644 --- a/catalog-ui/app/scripts/models/additional-information.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vfc.ts @@ -17,28 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../references"/> -module Sdc.Models { - 'use strict'; +import {CompositionCiNodeBase} from "./composition-ci-node-base"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {ImagesUrl} from "../../../../utils/constants"; - - export interface IAdditionalInformationModel { - uniqueId: string; - key: string; - value: string; +export class CompositionCiNodeVfc extends CompositionCiNodeBase { + constructor(instance:ComponentInstance, imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initVfc(); } - - export class AdditionalInformationModel implements IAdditionalInformationModel { - uniqueId:string; - key:string; - value:string; - - constructor() { - this.uniqueId = ''; - this.key = ''; - this.value = ''; - - } + private initVfc():void { + this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png'; } } diff --git a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts index ed9a0d9d87..596d12058f 100644 --- a/catalog-ui/app/scripts/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts +++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts @@ -17,22 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/// <reference path="../../../../references"/> +import {ComponentInstance} from "../../../componentsInstances/componentInstance"; +import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service"; +import {CompositionCiNodeBase} from "./composition-ci-node-base"; +import {ImagesUrl} from "../../../../utils/constants"; -module Sdc.Models.Graph { +export class CompositionCiNodeVl extends CompositionCiNodeBase { + private toolTipText:string; - export class CompositionCiNodeVl extends CompositionCiNodeBase { - private toolTipText:string; - - constructor(instance:Models.ComponentsInstances.ComponentInstance, imageCreator: Utils.ImageCreatorService) { - super(instance, imageCreator); - this.initVl(); + constructor(instance:ComponentInstance, imageCreator:ImageCreatorService) { + super(instance, imageCreator); + this.initVl(); - } + } - private initVl():void { - this.type = "basic-small-node"; - this.toolTipText = 'Point to point'; + private initVl():void { + this.type = "basic-small-node"; + this.toolTipText = 'Point to point'; + if(this.componentInstance.capabilities) { let key:string = _.find(Object.keys(this.componentInstance.capabilities), (key)=> { return _.includes(key.toLowerCase(), 'linkable'); }); @@ -41,14 +43,14 @@ module Sdc.Models.Graph { if ('UNBOUNDED' == linkable[0].maxOccurrences) { this.toolTipText = 'Multi point'; } - } - this.img = this.imagesPath + Utils.Constants.ImagesUrl.RESOURCE_ICONS + 'vl.png'; - this.classes = 'vl-node'; - if(!this.certified) { - this.classes = this.classes + ' not-certified'; } } + this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'vl.png'; + this.classes = 'vl-node'; + if (!this.certified) { + this.classes = this.classes + ' not-certified'; + } } } diff --git a/catalog-ui/app/scripts/modules/utils.ts b/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts index fd5eaf2a4b..51e3591304 100644 --- a/catalog-ui/app/scripts/modules/utils.ts +++ b/catalog-ui/src/app/models/graph/nodes/modules-graph-nodes/module-node-base.ts @@ -18,22 +18,34 @@ * ============LICENSE_END========================================================= */ /** - * Created by obarda on 2/11/2016. + * Created by obarda on 6/29/2016. */ -/// <reference path="../references"/> -module Sdc { - let moduleName:string = 'Sdc.Utils'; - let serviceModule:ng.IModule = angular.module(moduleName, []); +'use strict'; +import {ImagesUrl} from "../../../../utils/constants"; +import {Module} from "../../../modules/base-module"; +import {CommonNodeBase} from "../base-common-node"; +export interface IModuleNodeBase { +} + +export class ModuleNodeBase extends CommonNodeBase implements IModuleNodeBase { + + module:Module; + constructor(module:Module) { + super(); + this.module = module; + this.init(); + } - //Utils - serviceModule.service('ComponentFactory', Sdc.Utils.ComponentFactory); - serviceModule.service('ComponentInstanceFactory', Sdc.Utils.ComponentInstanceFactory); - serviceModule.service('ChangeLifecycleStateHandler', Sdc.Utils.ChangeLifecycleStateHandler); - serviceModule.service('ModalsHandler', Sdc.Utils.ModalsHandler); - serviceModule.service('MenuHandler', Sdc.Utils.MenuHandler); + private init() { - + this.id = this.module.uniqueId; + this.name = this.module.name; + this.displayName = this.module.name; + this.isGroup = true; + this.img = ImagesUrl.MODULE_ICON; + this.classes = "module-node"; + } } diff --git a/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts b/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts new file mode 100644 index 0000000000..6c4f71e722 --- /dev/null +++ b/catalog-ui/src/app/models/graph/nodes/nodes-factory.ts @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; + +import {CompositionCiNodeUcpeCp, Module, ModuleNodeBase, CompositionCiNodeVf, CompositionCiNodeVl, CompositionCiNodeCp, + NodeUcpe, CompositionCiNodeService, CompositionCiNodeBase, ComponentInstance} from "./../../../models"; +import {ComponentType, ResourceType} from "../../../utils/constants"; +import {ImageCreatorService} from "../../../directives/graphs-v2/image-creator/image-creator.service"; + +export class NodesFactory { + + constructor(private imageCreator:ImageCreatorService) { + } + + public createNode = (instance:ComponentInstance):CompositionCiNodeBase => { + + if (instance.isUcpe()) { + return new NodeUcpe(instance, this.imageCreator); + } + if (instance.originType === ComponentType.SERVICE) { + return new CompositionCiNodeService(instance, this.imageCreator); + } + if (instance.originType === ResourceType.CP) { + return new CompositionCiNodeCp(instance, this.imageCreator); + } + if (instance.originType === ResourceType.VL) { + return new CompositionCiNodeVl(instance, this.imageCreator); + } + + return new CompositionCiNodeVf(instance, this.imageCreator); + }; + + public createModuleNode = (module:Module):ModuleNodeBase => { + + return new ModuleNodeBase(module); + }; + + public createUcpeCpNode = (instance:ComponentInstance):CompositionCiNodeCp => { + + return new CompositionCiNodeUcpeCp(instance, this.imageCreator); + } +} + +NodesFactory.$inject = [ + 'ImageCreatorService' +]; diff --git a/catalog-ui/src/app/models/graph/point.ts b/catalog-ui/src/app/models/graph/point.ts new file mode 100644 index 0000000000..8fece5af99 --- /dev/null +++ b/catalog-ui/src/app/models/graph/point.ts @@ -0,0 +1,20 @@ +/** + * Created by obarda on 11/7/2016. + */ +export class Point { + /** + * The two-argument constructor produces the Point(x, y). + * @param {number} x + * @param {number} y + */ + constructor(x?:number, y?:number) { + this.x = x || 0; + this.y = y || 0; + } + + /**Gets or sets the x value of the Point.*/ + x:number; + + /**Gets or sets the y value of the Point.*/ + y:number; +} diff --git a/catalog-ui/src/app/models/graph/relationMenuObjects.ts b/catalog-ui/src/app/models/graph/relationMenuObjects.ts new file mode 100644 index 0000000000..aaef0b218c --- /dev/null +++ b/catalog-ui/src/app/models/graph/relationMenuObjects.ts @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {MatchReqToReq, MatchBase} from "./match-relation"; +import {CompositionCiNodeBase} from "./nodes/composition-graph-nodes/composition-ci-node-base"; +import {Component} from "../components/component"; +import {ComponentInstance} from "../componentsInstances/componentInstance"; + +export class RelationMenuDirectiveObj { + + fromNode:CompositionCiNodeBase; + toNode:CompositionCiNodeBase; + menuPosition:Cy.Position; + rightSideLink:GraphLinkMenuSide; + leftSideLink:GraphLinkMenuSide; + selectionText:string; + vlType:string; + + constructor(fromNode:CompositionCiNodeBase, toNode:CompositionCiNodeBase, menuPosition:Cy.Position, possibleRelations:Array<MatchBase>) { + this.fromNode = fromNode; + this.toNode = toNode; + // this.modelLinks = modelLinks; + this.menuPosition = menuPosition; + this.leftSideLink = new GraphLinkMenuSide(this.fromNode.componentInstance); + this.rightSideLink = new GraphLinkMenuSide(this.toNode.componentInstance); + this.selectionText = ''; + this.vlType = null; + + possibleRelations.forEach((match:any) => { + + let reqObjKey:string = match.requirement.ownerName + match.requirement.uniqueId; + let capObjKey:string = match.secondRequirement ? match.secondRequirement.ownerName + match.secondRequirement.uniqueId + : match.capability.ownerName + match.capability.uniqueId; + + if (match.fromNode === this.leftSideLink.componentInstance.uniqueId) { + //init the left side requirements Array + if (!this.leftSideLink.requirements[reqObjKey]) { + this.leftSideLink.requirements[reqObjKey] = []; + } + //push the match to fromNode object (from node is always the requirement) + this.leftSideLink.requirements[reqObjKey].push(match); + + if (match instanceof MatchReqToReq) { + //init the right side requirements Array + if (!this.rightSideLink.requirements[capObjKey]) { + this.rightSideLink.requirements[capObjKey] = []; + } + this.rightSideLink.requirements[capObjKey].push(match); + } else { + //init the right side capabilities Array + if (!this.rightSideLink.capabilities[capObjKey]) { + this.rightSideLink.capabilities[capObjKey] = []; + } + //add to array + this.rightSideLink.capabilities[capObjKey].push(match); + } + + } else { + if (!this.rightSideLink.requirements[reqObjKey]) { + this.rightSideLink.requirements[reqObjKey] = []; + } + this.rightSideLink.requirements[reqObjKey].push(match); + + if (!this.leftSideLink.capabilities[capObjKey]) { + this.leftSideLink.capabilities[capObjKey] = []; + } + this.leftSideLink.capabilities[capObjKey].push(match); + } + }); + + } +} + +export class GraphLinkMenuSide { + public componentInstance:ComponentInstance; + public selectedMatch:Array<any>; //match array returned by function in utils + public requirements:any; //array of matches returned by function in utils + public capabilities:any; //array of matches returned by function in utils + + constructor(componentInstance:ComponentInstance) { + this.componentInstance = componentInstance; + this.capabilities = {}; + this.requirements = {}; + } + + public selectMatchArr(matchArr:Array<MatchBase>):void { + if (this.selectedMatch === matchArr) { + this.selectedMatch = undefined; + } else { + this.selectedMatch = matchArr; + } + } + + + //TODO move to match object + public getPreviewText(showReq:boolean):string { + if (!this.selectedMatch) { + return ''; + } + + let match:any = this.selectedMatch[0]; + if (showReq) { + return match.requirement.ownerName + ': ' + match.requirement.name + + ': [' + match.requirement.minOccurrences + ', ' + match.requirement.maxOccurrences + ']'; + } else if (match.secondRequirement) { + return match.secondRequirement.ownerName + ': ' + match.secondRequirement.name + + ': [' + match.secondRequirement.minOccurrences + ', ' + match.secondRequirement.maxOccurrences + ']'; + } + else { + return match.capability.ownerName + ': ' + match.capability.name + + ': [' + match.capability.minOccurrences + ', ' + match.capability.maxOccurrences + ']'; + } + } +} diff --git a/catalog-ui/src/app/models/graph/relationship.ts b/catalog-ui/src/app/models/graph/relationship.ts new file mode 100644 index 0000000000..6345ab4c04 --- /dev/null +++ b/catalog-ui/src/app/models/graph/relationship.ts @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {Capability} from "../capability"; +import {Requirement} from "../requirement"; + +export class RelationshipModel { + fromNode:string; + toNode:string; + relationships:Array<Relationship>; + + constructor(relationshipModel?:RelationshipModel, singleRelationship?:Relationship) { + if (relationshipModel) { + this.fromNode = relationshipModel.fromNode; + this.toNode = relationshipModel.toNode; + this.relationships = []; + if (relationshipModel.relationships && !singleRelationship) { + _.forEach(relationshipModel.relationships, (relation:Relationship):void => { + this.relationships.push(new Relationship(relation)); + }); + } else if (singleRelationship) { + this.relationships.push(singleRelationship); + } + } + } + + public setRelationshipModelParams(fromNode:string, toNode:string, relationships:Array<Relationship>) { + this.fromNode = fromNode; + this.toNode = toNode; + this.relationships = relationships; + } +} + +export class RelationType { + type:string; + + constructor(type?:string) { + if (type) { + this.type = type; + } + } +} + +export class Relationship { + capability:string; + capabilityOwnerId:string; + capabilityUid:string; + relationship:RelationType; + requirement:string; + requirementOwnerId:string; + requirementUid:string; + + constructor(relationship?:Relationship) { + if (relationship) { + this.capability = relationship.capability; + this.capabilityOwnerId = relationship.capabilityOwnerId; + this.capabilityUid = relationship.capabilityUid; + this.relationship = new RelationType(relationship.relationship.type); + this.requirement = relationship.requirement; + this.requirementOwnerId = relationship.requirementOwnerId; + this.requirementUid = relationship.requirementUid; + } else { + this.relationship = new RelationType(); + } + + } + + public setRelationProperties = (capability:Capability, requirement:Requirement)=> { + this.capability = capability.name; + this.capabilityOwnerId = capability.ownerId; + this.capabilityUid = capability.uniqueId; + this.relationship = new RelationType(capability.type); + this.requirement = requirement.name; + this.requirementOwnerId = requirement.ownerId; + this.requirementUid = requirement.uniqueId; + }; + +} diff --git a/catalog-ui/src/app/models/heat-parameters.ts b/catalog-ui/src/app/models/heat-parameters.ts new file mode 100644 index 0000000000..be5ad92fb0 --- /dev/null +++ b/catalog-ui/src/app/models/heat-parameters.ts @@ -0,0 +1,18 @@ +/** + * Created by rcohen on 10/31/2016. + */ +'use strict'; + +export class HeatParameterModel { + uniqueId:string; + name:string; + type:string; + description:string; + currentValue:string; + defaultValue:string; + + constructor(parameter?:HeatParameterModel) { + } + +} + diff --git a/catalog-ui/src/app/models/input-property-base.ts b/catalog-ui/src/app/models/input-property-base.ts new file mode 100644 index 0000000000..dce76d597e --- /dev/null +++ b/catalog-ui/src/app/models/input-property-base.ts @@ -0,0 +1,26 @@ +/** + * Created by obarda on 1/22/2017. + */ +'use strict'; +import {SchemaPropertyGroupModel} from "./aschema-property"; + +export interface InputPropertyBase { + + uniqueId:string; + name:string; + defaultValue:string; + description:string; + password:boolean; + required:boolean; + type:string; + parentUniqueId:string; + schema:SchemaPropertyGroupModel; + componentInstanceId:string; + + //instance properties + value:string; + + //custom properties + isAlreadySelected:boolean; +} + diff --git a/catalog-ui/src/app/models/inputs-and-properties.ts b/catalog-ui/src/app/models/inputs-and-properties.ts new file mode 100644 index 0000000000..18ff928918 --- /dev/null +++ b/catalog-ui/src/app/models/inputs-and-properties.ts @@ -0,0 +1,22 @@ +/** + * Created by obarda on 1/11/2017. + */ +'use strict'; +import {PropertyModel} from "./properties"; +import {InputModel} from "./inputs"; + +export class InputsAndProperties { + + inputs:Array<InputModel>; + properties:Array<PropertyModel>; + + + constructor(inputs?:Array<InputModel>, properties?:Array<PropertyModel>) { + if (inputs && inputs.length > 0) { + this.inputs = inputs; + } + if (properties && properties.length > 0) { + this.properties = properties; + } + } +} diff --git a/catalog-ui/src/app/models/inputs.ts b/catalog-ui/src/app/models/inputs.ts new file mode 100644 index 0000000000..55e739b452 --- /dev/null +++ b/catalog-ui/src/app/models/inputs.ts @@ -0,0 +1,80 @@ +/** + * Created by obarda on 8/24/2016. + */ +'use strict'; +import {PropertyModel} from "./properties"; +import {InputPropertyBase} from "./input-property-base"; +import {SchemaPropertyGroupModel} from "./aschema-property"; + +export interface IInputModel extends InputPropertyBase { + //server data + definition:boolean; + value:string; + componentInstanceName:string; + //costom properties + isNew:boolean; + properties:Array<PropertyModel>; + inputs:Array<InputModel>; + filterTerm:string; + +} +export class InputModel implements IInputModel { + + //server data + uniqueId:string; + name:string; + type:string; + password:boolean; + required:boolean; + definition:boolean; + parentUniqueId:string; + description:string; + componentInstanceName:string; + componentInstanceId:string; + schema:SchemaPropertyGroupModel; + defaultValue:string; + value:string; + + //costom properties + isNew:boolean; + isDeleteDisabled:boolean; + properties:Array<PropertyModel>; + inputs:Array<InputModel>; + isAlreadySelected:boolean; + filterTerm:string; + + constructor(input:InputModel) { + + if (input) { + this.uniqueId = input.uniqueId; + this.name = input.name; + this.type = input.type; + this.description = input.description; + this.password = input.password; + this.required = input.required; + this.definition = input.definition; + this.parentUniqueId = input.parentUniqueId; + this.description = input.description; + this.componentInstanceName = input.componentInstanceName; + this.componentInstanceId = input.componentInstanceId; + this.schema = input.schema; + this.defaultValue = input.defaultValue; + this.value = input.value; + this.filterTerm = this.name + ' ' + this.description + ' ' + this.type + ' ' + this.componentInstanceName; + this.inputs = input.inputs; + this.properties = input.properties; + } + } + + public toJSON = ():any => { + let input = angular.copy(this); + input.isNew = undefined; + input.isDeleteDisabled = undefined; + input.properties = undefined; + input.inputs = undefined; + input.isAlreadySelected = undefined; + input.filterTerm = undefined; + return input; + }; +} + diff --git a/catalog-ui/src/app/models/instance-inputs-properties-map.ts b/catalog-ui/src/app/models/instance-inputs-properties-map.ts new file mode 100644 index 0000000000..47b99dfffd --- /dev/null +++ b/catalog-ui/src/app/models/instance-inputs-properties-map.ts @@ -0,0 +1,67 @@ +/** + * Created by obarda on 9/12/2016. + */ +'use strict'; +import {InputPropertyBase} from "./input-property-base"; +import {PropertyModel} from "./properties"; +import {InputModel} from "./inputs"; + +export class InstancesInputsOrPropertiesMapData { + [instanceId:string]:Array<InputPropertyBase>; +} + +export class InstancesInputsPropertiesMap { + componentInstanceProperties:InstancesInputsOrPropertiesMapData; + componentInstanceInputsMap:InstancesInputsOrPropertiesMapData; + + constructor(componentInstanceInputsMapData:InstancesInputsOrPropertiesMapData, componentInstanceInputsPropertiesMapData:InstancesInputsOrPropertiesMapData) { + this.componentInstanceInputsMap = componentInstanceInputsMapData; + this.componentInstanceProperties = componentInstanceInputsPropertiesMapData; + } + + private removeUnnecessaryData = (properties:Array<InputPropertyBase>, instanceId:string, mapData:any) => { + mapData[instanceId] = []; + if (properties && properties.length > 0) { + _.forEach(properties, (propertyOrInput:InputPropertyBase) => { + if (propertyOrInput instanceof PropertyModel) { // Handle Properties + if (propertyOrInput && !propertyOrInput.isAlreadySelected) { + mapData[instanceId].push(propertyOrInput); + } + } + if (propertyOrInput instanceof InputModel) { // Handle Inputs + if (propertyOrInput && !propertyOrInput.isAlreadySelected) { + mapData[instanceId].push(propertyOrInput); + } + } + }); + if (mapData[instanceId].length === 0) { + delete mapData[instanceId]; + } + } else { + delete mapData[instanceId]; + } + } + + /* + In the toJson we remove all inputs and property already selected (The check box selected but they are disable) + also we remove empty array in order to prevent Backend error + */ + + public cleanUnnecessaryDataBeforeSending = ():InstancesInputsPropertiesMap => { + + let map:InstancesInputsPropertiesMap = new InstancesInputsPropertiesMap(new InstancesInputsOrPropertiesMapData(), new InstancesInputsOrPropertiesMapData()); + angular.copy(this, map); + + //Removing unnecessary data from inputs map + _.forEach(map.componentInstanceInputsMap, (inputs:Array<InputModel>, instanceId:string) => { + this.removeUnnecessaryData(inputs, instanceId, map.componentInstanceInputsMap); + }); + + //Removing unnecessary data from properties map + _.forEach(map.componentInstanceProperties, (properties:Array<PropertyModel>, instanceId:string) => { + this.removeUnnecessaryData(properties, instanceId, map.componentInstanceProperties); + }); + + return map; + }; +} diff --git a/catalog-ui/src/app/models/left-panel.ts b/catalog-ui/src/app/models/left-panel.ts new file mode 100644 index 0000000000..759d5f317e --- /dev/null +++ b/catalog-ui/src/app/models/left-panel.ts @@ -0,0 +1,11 @@ +'use strict'; + +export class LeftPanelModel { + numberOfElements:number; + sortedCategories:any; + + constructor() { + this.numberOfElements = 0; + this.sortedCategories = {}; + } +} diff --git a/catalog-ui/src/app/models/member.ts b/catalog-ui/src/app/models/member.ts new file mode 100644 index 0000000000..a2d9d17aec --- /dev/null +++ b/catalog-ui/src/app/models/member.ts @@ -0,0 +1,16 @@ +/** + * Created by obarda on 8/2/2016. + */ +'use strict'; + +export class Members { + + [index:string]:string; + + constructor(members?:Members) { + _.forEach(members, (memberId:string, index) => { + this[index] = memberId; + }); + } +} + diff --git a/catalog-ui/src/app/models/modules/base-module.ts b/catalog-ui/src/app/models/modules/base-module.ts new file mode 100644 index 0000000000..4a5f282468 --- /dev/null +++ b/catalog-ui/src/app/models/modules/base-module.ts @@ -0,0 +1,95 @@ +/** + * Created by obarda on 6/30/2016. + */ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {PropertyModel} from "../properties"; +import {ArtifactModel} from "../artifacts"; +import {CommonUtils} from "../../utils/common-utils"; +export class Module { + + public name:string; + public groupUUID:string; + public invariantUUID:string; + public propertyValueCounter:number; + public type:string; + public typeUid:string; + public uniqueId:string; + public version:string; + public artifacts:Array<string> | Array<ArtifactModel>; + public artifactsUuid:Array<string>; + public properties:Array<PropertyModel>; + public members:Array<string>; + public customizationUUID:string; + public groupInstanceUniqueId:string; // This will only have a value if this is a group instance + + constructor(module?:Module) { + if (module) { + this.name = module.name; + this.groupUUID = module.groupUUID; + this.invariantUUID = module.invariantUUID; + this.propertyValueCounter = module.propertyValueCounter; + this.type = module.type; + this.typeUid = module.typeUid; + this.uniqueId = module.uniqueId; + this.version = module.version; + this.artifacts = module.artifacts; + this.artifactsUuid = module.artifactsUuid; + this.properties = CommonUtils.initProperties(module.properties); + this.members = module.members; + this.customizationUUID = module.customizationUUID; + this.groupInstanceUniqueId = module.groupInstanceUniqueId; + this.name = this.name.replace(/:/g, '..'); + + } + } +} + +export class DisplayModule extends Module { + + isBase:string; + artifacts:Array<ArtifactModel>; + + //custom properties + public vfInstanceName:string; + public heatName:string; + public moduleName:string; + public customizationUUID:string; + + + constructor(displayModule?:DisplayModule) { + super(displayModule); + + this.isBase = displayModule.isBase; + this.customizationUUID = displayModule.customizationUUID; + this.initArtifactsForDisplay(displayModule.artifacts); + + //splitting module name for display and edit + let splitName:Array<string> = this.name.split('..'); + this.vfInstanceName = splitName[0]; + this.heatName = splitName[1]; + this.moduleName = splitName[2]; + } + + private initArtifactsForDisplay = (artifacts:Array<ArtifactModel>):void => { + this.artifacts = new Array<ArtifactModel>(); + _.forEach(artifacts, (artifact:ArtifactModel) => { + this.artifacts.push(new ArtifactModel(artifact)); + }); + }; + + public updateName = ():void => { + this.name = this.vfInstanceName + '..' + this.heatName + '..' + this.moduleName; + }; + + public toJSON = ():any => { + this.vfInstanceName = undefined; + this.heatName = undefined; + this.moduleName = undefined; + this.isBase = undefined; + this.artifacts = undefined; + return this; + }; +} diff --git a/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts new file mode 100644 index 0000000000..1d79353453 --- /dev/null +++ b/catalog-ui/src/app/models/properties-inputs/derived-fe-property.ts @@ -0,0 +1,72 @@ +import { SchemaPropertyGroupModel, SchemaProperty } from '../aschema-property'; +import { PROPERTY_DATA, PROPERTY_TYPES} from 'app/utils'; +import { PropertyBEModel } from '../../models'; + +export enum DerivedPropertyType { + SIMPLE, + LIST, + MAP, + COMPLEX //other datatype, list of non-simple, or map of non-simple +} + +export class DerivedFEProperty extends PropertyBEModel { + parentName: string; + propertiesName: string; //"network_assignments#ipv4_subnet#use_ipv4 = parentPath + name + derivedDataType: DerivedPropertyType; + isDeclared: boolean; + isSelected: boolean; + isDisabled: boolean; + isChildOfListOrMap: boolean; + + constructor(property: PropertyBEModel, parentName?: string) + constructor(name: string, parentName: string, type: string, value: string, isChildOfListOrMap?:boolean, schema?: SchemaPropertyGroupModel); + constructor(nameOrPropertyObj?: string | PropertyBEModel, parentName?: string, type?: string, value?: string, isChildOfListOrMap?: boolean, schema?: SchemaPropertyGroupModel) { + + super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj); + + if (typeof nameOrPropertyObj !== 'string') { //constructor #1 + this.parentName = parentName ? parentName : null; + this.propertiesName = (parentName) ? parentName + '#' + nameOrPropertyObj.name : nameOrPropertyObj.name; + } else { //constructor #2 + this.name = nameOrPropertyObj; + this.type = type; + this.parentName = parentName; + this.propertiesName = parentName + '#' + nameOrPropertyObj; + this.value = value; + if (schema) { + this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property)); + } + } + this.derivedDataType = this.getDerivedPropertyType(); + this.isChildOfListOrMap = (isChildOfListOrMap) ? isChildOfListOrMap : false; + } + + public getDerivedPropertyType = () => { + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1) { + return DerivedPropertyType.SIMPLE; + } else if (this.type == PROPERTY_TYPES.LIST) { + return DerivedPropertyType.LIST; + } else if (this.type == PROPERTY_TYPES.MAP) { + return DerivedPropertyType.MAP; + } else { + return DerivedPropertyType.COMPLEX; + } + } + +} +export class DerivedFEPropertyMap { + [parentPath: string]: Array<DerivedFEProperty>; +} + + + +// isDataType: boolean; + + +// canAdd: boolean; +// canCollapse: boolean; +// canBeDeclared: boolean; + +// derivedValue: string; +// derivedValueType: string; +// propertiesName: string;
\ No newline at end of file diff --git a/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts new file mode 100644 index 0000000000..1261df3d6d --- /dev/null +++ b/catalog-ui/src/app/models/properties-inputs/input-fe-model.ts @@ -0,0 +1,32 @@ +import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property"; +import { PropertyBEModel } from "../../models"; +import {PROPERTY_DATA} from "../../utils/constants"; + +export class InputFEModel extends PropertyBEModel { + isSimpleType: boolean; + isDataType: boolean; + instanceName: string; + propertyName: string; + + + constructor(input?: PropertyBEModel) { + super(input); + if (input) { + this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1; + this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1; + let propNameIndex:number = this.name.indexOf('_'); + this.instanceName = this.name.substring(0, propNameIndex); + if (input.inputPath) { + this.propertyName = input.inputPath.substring(0, input.inputPath.indexOf('#')) + } else { + this.propertyName = this.name.substring(propNameIndex + 1); + } + } + } + + + + public toJSON = (): any => { + }; + +} diff --git a/catalog-ui/src/app/models/properties-inputs/property-be-model.ts b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts new file mode 100644 index 0000000000..a5279d0668 --- /dev/null +++ b/catalog-ui/src/app/models/properties-inputs/property-be-model.ts @@ -0,0 +1,84 @@ +import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property"; + +export class PropertyBEModel { + + defaultValue: string; + description: string; + fromDerived: boolean; + name: string; + parentUniqueId: string; + password: boolean; + required: boolean; + schema: SchemaPropertyGroupModel; + type: string; + uniqueId: string; + value: string; + definition: boolean; + inputPath: string; + propertiesName: string; + input: PropertyBEModel; + + constructor(property?: PropertyBEModel, childProperty?:PropertyBEModel) { + if (property) { + this.defaultValue = property.defaultValue; + this.description = property.description; + this.fromDerived = property.fromDerived; + this.name = property.name; + this.parentUniqueId = property.parentUniqueId; + this.password = property.password; + this.required = property.required; + this.schema = property.schema; + this.type = property.type; + this.uniqueId = property.uniqueId; + this.value = property.value ? property.value : property.defaultValue; + this.definition = property.definition; + if (property.inputPath) { + this.inputPath = property.inputPath; + } + } + if (childProperty) { + this.input = childProperty; + this.propertiesName = childProperty.propertiesName; + } + + if (!this.schema || !this.schema.property) { + this.schema = new SchemaPropertyGroupModel(new SchemaProperty()); + } else { //forcing creating new object, so editing different one than the object in the table + this.schema = new SchemaPropertyGroupModel(new SchemaProperty(this.schema.property)); + } + } + + + + public toJSON = (): any => { + let temp = angular.copy(this); + temp.value = temp.value === "{}" || temp.value === "[]" ? undefined : temp.value; + temp.defaultValue = temp.defaultValue === "{}" || temp.defaultValue === "[]" ? undefined : temp.defaultValue; + return temp; + }; + +} + + +// EXTRAS FROM CONSTRUCTOR: +// this.source = property.source; +// this.valueUniqueUid = property.valueUniqueUid; +// this.path = property.path; +// this.rules = property.rules; +// this.resourceInstanceUniqueId = property.resourceInstanceUniqueId; +// this.readonly = property.readonly; +// this.simpleType = property.simpleType; +// this.componentInstanceId = property.componentInstanceId; +// this.parentValue = property.parentValue; +//NEW PROPERTIES MAY NEED: +// export class PropertyFEModel extends PropertyBEModel { +// componentInstanceId: string; +// isAlreadySelected: boolean; +// filterTerm: string; +// } +//FOR INPUTS, BE ALSO INCLUDES: +//export class InputFEModel extends PropertyBEModel { +// hidden: boolean; +// label: string; +// immutable: boolean; +// } diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts new file mode 100644 index 0000000000..3b267460b1 --- /dev/null +++ b/catalog-ui/src/app/models/properties-inputs/property-fe-map.ts @@ -0,0 +1,21 @@ +'use strict'; +import { PropertyBEModel, PropertyFEModel } from "../../models"; + +export class InstanceBePropertiesMap { + [instanceId: string]: Array<PropertyBEModel>; +} + +export class InstanceFePropertiesMap { + [instanceId: string]: Array<PropertyFEModel>; +} + +export class InstancePropertiesAPIMap { + componentInstanceProperties: InstanceBePropertiesMap; + componentInstanceInputsMap: InstanceBePropertiesMap; + + constructor(inputsMapData: InstanceBePropertiesMap, propertiesMapData: InstanceBePropertiesMap) { + this.componentInstanceInputsMap = inputsMapData ? inputsMapData: new InstanceBePropertiesMap(); + this.componentInstanceProperties = propertiesMapData ? propertiesMapData: new InstanceBePropertiesMap(); + } + +} diff --git a/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts new file mode 100644 index 0000000000..29f2c79225 --- /dev/null +++ b/catalog-ui/src/app/models/properties-inputs/property-fe-model.ts @@ -0,0 +1,132 @@ +import {SchemaPropertyGroupModel, SchemaProperty} from '../aschema-property'; +import { PROPERTY_DATA } from 'app/utils'; +import { PropertyBEModel, DerivedFEPropertyMap, DerivedFEProperty } from '../../models'; + + +export class PropertyFEModel extends PropertyBEModel { + + //START - TO REMOVE: + treeNodeId: string; + parent: PropertyFEModel; + + childrenProperties: Array<PropertyFEModel>; + isAllChildrenLevelsCalculated: boolean; + uniqueId: string; + valueObjectRef: any; + //END - TO REMOVE: + + expandedChildPropertyId: string; + flattenedChildren: Array<DerivedFEProperty>; //[parentPath] : Array<DerivedFEProp> + isDataType: boolean; //aka- isComplexType. (Type is NOT: simple, list, or map) + isDeclared: boolean; + isDisabled: boolean; + isSelected: boolean; + isSimpleType: boolean; + + private _derivedFromSimpleTypeName:string; + get derivedFromSimpleTypeName():string { + return this._derivedFromSimpleTypeName; + } + set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) { + this._derivedFromSimpleTypeName = derivedFromSimpleTypeName; + } + + constructor(property?: PropertyBEModel); + constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel); + constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) { + + super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj); + + if (typeof nameOrPropertyObj === 'string') { + this.name = nameOrPropertyObj; + this.type = type; + this.treeNodeId = treeNodeId; + this.parent = parent; + this.valueObjectRef = valueObjectRef; + this.value = this.value || this.defaultValue; + if(schema){ + this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property)); + } + } + + this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1; + this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1; + this.setNonDeclared(); + } + + public convertChildToInput = (childName: string): void => { + //childName: "mac_count_required" + let childJson = this.flattenedChildren[childName].map((child) => { + + }); + }; + + public getChildJsonRecursive = (child: string, value?: string): void => { + //TODO: use array.map for the below + /* value += "{" + this.flattenedChildren[child].name + ":"; + if (this.flattenedChildren[child].valueType == 'simple') { + value += this.flattenedChildren[child].value + '}'; + return value; + } else { + this.flattenedChildren[child].forEach(grandChild => { + if (this.flattenedChildren[grandChild].valueType == 'simple') { + return "{" + this.flattenedChildren[grandChild].name + ':' + this.flattenedChildren[child].value.toString() + "}"; + } else { + return this.getChildJsonRecursive(grandChild + '#' + this.flattenedChildren[child].name); + } + }); + } + + return "{" + this.flattenedChildren[child].name + this.flattenedChildren[child].value.toString() + "}"; +*/ + + }; + + public setNonDeclared = (childPath?: string): void => { + if (!childPath) { //declaring a child prop + this.isDeclared = false; + } else { + let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childPath); + childProp.isDeclared = false; + } + } + + public setAsDeclared = (childNameToDeclare?:string): void => { + if (!childNameToDeclare) { //declaring a child prop + this.isSelected = false; + this.isDeclared = true; + } else { + let childProp: DerivedFEProperty = this.flattenedChildren.find(child => child.propertiesName == childNameToDeclare); + childProp.isSelected = false; + childProp.isDeclared = true; + } + } + + + + //For expand-collapse functionality + public updateExpandedChildPropertyId = (childPropertyId: string): void => { + if (childPropertyId.lastIndexOf('#') > -1) { + this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? (childPropertyId.substring(0, childPropertyId.lastIndexOf('#'))) : childPropertyId; + } else { + this.expandedChildPropertyId = this.name; + } + //console.log("expandedChild is now " + this.expandedChildPropertyId); + } + + public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here + // let serverObject = {}; + // let mapData = { + // 'type': this.type, + // 'required': this.required || false, + // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null, + // 'description': this.description, + // 'isPassword': this.password || false, + // 'schema': this.schema, + // 'name': this.name + // }; + // serverObject[this.name] = mapData; + + //return JSON.stringify(serverObject); + }; +} diff --git a/catalog-ui/src/app/models/properties.ts b/catalog-ui/src/app/models/properties.ts new file mode 100644 index 0000000000..357dac2e7d --- /dev/null +++ b/catalog-ui/src/app/models/properties.ts @@ -0,0 +1,141 @@ +'use strict'; +import {SchemaPropertyGroupModel, SchemaProperty} from "./aschema-property"; +import {InputPropertyBase} from "./input-property-base"; + +export class PropertiesGroup { + constructor(propertiesObj?:PropertiesGroup) { + _.forEach(propertiesObj, (properties:Array<PropertyModel>, instance) => { + this[instance] = []; + _.forEach(properties, (property:PropertyModel):void => { + property.resourceInstanceUniqueId = instance; + property.readonly = true; + this[instance].push(new PropertyModel(property)); + }); + }); + } +} + +export interface IPropertyModel extends InputPropertyBase { + + //server data + constraints:Array<Object>; + source:string; + + //instance properties + valueUniqueUid:string; + path:Array<string>; + rules:Array<Object>; + propertiesName:string; + input:any; + + //custom properties + resourceInstanceUniqueId:string; + readonly:boolean; + simpleType:string; +} + +export class PropertyModel implements IPropertyModel { + + //server data + uniqueId:string; + name:string; + constraints:Array<Object>; + defaultValue:string; + description:string; + password:boolean; + required:boolean; + type:string; + source:string; + parentUniqueId:string; + schema:SchemaPropertyGroupModel; + componentInstanceId:string; + parentValue:string; + + //instance properties + value:string; + valueUniqueUid:string; + path:Array<string>; + rules:Array<Object>; + propertiesName:string; + input:any; + + //custom properties + resourceInstanceUniqueId:string; + readonly:boolean; + simpleType:string; + filterTerm:string; + isAlreadySelected:boolean; + addOn:string; + + + constructor(property?:PropertyModel) { + if (property) { + this.uniqueId = property.uniqueId; + this.name = property.name; + this.constraints = property.constraints; + this.defaultValue = property.defaultValue; + this.description = property.description; + this.password = property.password; + this.required = property.required; + this.type = property.type; + this.source = property.source; + this.parentUniqueId = property.parentUniqueId; + this.schema = property.schema; + this.value = property.value ? property.value : property.defaultValue; + this.valueUniqueUid = property.valueUniqueUid; + this.path = property.path; + this.rules = property.rules; + this.resourceInstanceUniqueId = property.resourceInstanceUniqueId; + this.readonly = property.readonly; + this.simpleType = property.simpleType; + this.componentInstanceId = property.componentInstanceId; + this.parentValue = property.parentValue; + } + + if (!this.schema || !this.schema.property) { + this.schema = new SchemaPropertyGroupModel(new SchemaProperty()); + } else { + //forcing creating new object, so editing different one than the object in the table + this.schema = new SchemaPropertyGroupModel(new SchemaProperty(this.schema.property)); + } + if (property && property.uniqueId) { + this.filterTerm = this.name + " " + (this.description || "") + " " + this.type.replace("org.openecomp.datatypes.heat.", ""); + if (this.schema.property && this.schema.property.type) { + this.filterTerm += " " + this.schema.property.type.replace("org.openecomp.datatypes.heat.", ""); + } + } + } + + public convertToServerObject:Function = ():string => { + let serverObject = {}; + let mapData = { + "type": this.type, + "required": this.required || false, + "defaultValue": this.defaultValue != "" && this.defaultValue != "[]" && this.defaultValue != "{}" ? this.defaultValue : null, + "description": this.description, + "constraints": this.constraints, + "isPassword": this.password || false, + "schema": this.schema, + "name": this.name + }; + serverObject[this.name] = mapData; + + return JSON.stringify(serverObject); + }; + + public toJSON = ():any => { + // if(!this.resourceInstanceUniqueId){ + // this.value = undefined; + // } + let temp = angular.copy(this); + temp.readonly = undefined; + temp.resourceInstanceUniqueId = undefined; + temp.simpleType = undefined; + temp.value = temp.value === "{}" || temp.value === "[]" ? undefined : temp.value; + temp.defaultValue = temp.defaultValue === "{}" || temp.defaultValue === "[]" ? undefined : temp.defaultValue; + temp.rules = null; //don't send rules to server until feature is fully supported + temp.isAlreadySelected = undefined; + temp.addOn = undefined; + return temp; + }; +} diff --git a/catalog-ui/src/app/models/property-fe-model.ts b/catalog-ui/src/app/models/property-fe-model.ts new file mode 100644 index 0000000000..f83d6d6b51 --- /dev/null +++ b/catalog-ui/src/app/models/property-fe-model.ts @@ -0,0 +1,78 @@ +import {SchemaPropertyGroupModel, SchemaProperty} from './aschema-property'; +import { PROPERTY_DATA } from 'app/utils'; +import { FilterPropertiesAssignmentData, PropertyBEModel } from 'app/models'; + +export class PropertyFEModel extends PropertyBEModel { + public static filterData:FilterPropertiesAssignmentData; + childrenProperties: Array<PropertyFEModel>; + expandedChildPropertyId: string; + isAllChildrenLevelsCalculated: boolean; + isDataType: boolean; + isDisabled: boolean; + isSelected: boolean; + isSimpleType: boolean; + parent: PropertyFEModel; + treeNodeId: string; + valueObjectRef: any; + private _derivedFromSimpleTypeName:string; + get derivedFromSimpleTypeName():string { + return this._derivedFromSimpleTypeName; + } + set derivedFromSimpleTypeName(derivedFromSimpleTypeName:string) { + this._derivedFromSimpleTypeName = derivedFromSimpleTypeName; + } + + constructor(property?: PropertyBEModel); + constructor(name: string, type: string, treeNodeId: string, parent: PropertyFEModel, valueObjectRef: any, schema?: SchemaPropertyGroupModel); + constructor(nameOrPropertyObj?: string | PropertyBEModel, type?: string, treeNodeId?: string, parent?: PropertyFEModel, valueObjectRef?: any, schema?: SchemaPropertyGroupModel) { + + super(typeof nameOrPropertyObj === 'string' ? null : nameOrPropertyObj); + + if (typeof nameOrPropertyObj === 'string') { + this.name = nameOrPropertyObj; + this.type = type; + this.treeNodeId = treeNodeId; + this.parent = parent; + this.valueObjectRef = valueObjectRef; + this.value = this.value || this.defaultValue; + if(schema){ + this.schema = new SchemaPropertyGroupModel(new SchemaProperty(schema.property)); + } + } + this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1; + this.isDataType = PROPERTY_DATA.TYPES.indexOf(this.type) == -1; + this.setNonDeclared(); + } + + + public setNonDeclared = (): void => { + this.isSelected = false; + this.isDisabled = false; + } + + public setAsDeclared = (): void => { + this.isSelected = true; + this.isDisabled = true; + } + + //For expand-collapse functionality + public updateExpandedChildPropertyId = (childPropertyId: string): void => { + this.expandedChildPropertyId = (this.expandedChildPropertyId == childPropertyId) ? '' : childPropertyId; + } + + public convertToServerObject: Function = (): any => { //TODO: Idan, Rachel, Nechama: Decide what we need to do here + // let serverObject = {}; + // let mapData = { + // 'type': this.type, + // 'required': this.required || false, + // 'defaultValue': this.defaultValue != '' && this.defaultValue != '[]' && this.defaultValue != '{}' ? this.defaultValue : null, + // 'description': this.description, + // 'isPassword': this.password || false, + // 'schema': this.schema, + // 'name': this.name + // }; + // serverObject[this.name] = mapData; + + //return JSON.stringify(serverObject); + }; +} diff --git a/catalog-ui/src/app/models/requirement.ts b/catalog-ui/src/app/models/requirement.ts new file mode 100644 index 0000000000..e62c809ec9 --- /dev/null +++ b/catalog-ui/src/app/models/requirement.ts @@ -0,0 +1,71 @@ +/** + * Created by obarda on 4/20/2016. + */ +'use strict'; +//this is an object contains keys, when each key has matching array. +// for example: key = tosca.capabilities.network. and the match array is array of requirements objects +export class RequirementsGroup { + [key: string]: Array<Requirement>; + constructor(requirementGroupObj?:RequirementsGroup) { + _.forEach(requirementGroupObj, (requirementsArrayObj:Array<Requirement>, instance) => { + this[instance] = []; + _.forEach(requirementsArrayObj, (requirement:Requirement):void => { + this[instance].push(new Requirement(requirement)); + }); + }); + } +} + +export class Requirement { + + //server data + capability:string; + name:string; + ownerId:string; + ownerName:string; + node:string; + uniqueId:string; + relationship:string; + minOccurrences:string; + maxOccurrences:string; + //custom + filterTerm:string; + + constructor(requirement?:Requirement) { + + if (requirement) { + this.capability = requirement.capability; + this.name = requirement.name; + this.ownerId = requirement.ownerId; + this.ownerName = requirement.ownerName; + this.node = requirement.node; + this.uniqueId = requirement.uniqueId; + this.relationship = requirement.relationship; + this.minOccurrences = requirement.minOccurrences; + this.maxOccurrences = requirement.maxOccurrences; + this.initFilterTerm(); + + } + } + + public getFullTitle():string { + return this.ownerName + ': ' + this.name + + ': [' + this.minOccurrences + ', ' + this.maxOccurrences + ']'; + } + + public toJSON = ():any => { + this.filterTerm = undefined; + return this; + }; + + private initFilterTerm = ():void => { + this.filterTerm = (this.name + " ") + + (this.ownerName + " " ) + + (this.capability ? (this.capability.substring("tosca.capabilities.".length) + " " ) : "") + + (this.node ? (this.node.substring("tosca.nodes.".length) + " ") : "") + + (this.relationship ? (this.relationship.substring("tosca.relationships.".length) + " ") : "") + + this.minOccurrences + "," + this.maxOccurrences; + } +} + + diff --git a/catalog-ui/src/app/models/schema-attribute.ts b/catalog-ui/src/app/models/schema-attribute.ts new file mode 100644 index 0000000000..3c48aa3fa2 --- /dev/null +++ b/catalog-ui/src/app/models/schema-attribute.ts @@ -0,0 +1,16 @@ +'use strict'; +import {SchemaProperty} from "./aschema-property"; + +export class SchemaAttributeGroupModel { + property:SchemaAttribute; + + constructor(schemaAttribute?:SchemaAttribute) { + this.property = schemaAttribute; + } +} + +export class SchemaAttribute extends SchemaProperty { + +} + + diff --git a/catalog-ui/src/app/models/tab.ts b/catalog-ui/src/app/models/tab.ts new file mode 100644 index 0000000000..a7ce509ce0 --- /dev/null +++ b/catalog-ui/src/app/models/tab.ts @@ -0,0 +1,27 @@ +/** + * Created by obarda on 7/31/2016. + */ +'use strict'; + +export class Tab { + + public templateUrl:string; + public controller:string; + public data:any; + public icon:string; + public name:string; + public isViewMode:boolean; + + constructor(templateUrl:string, controller:string, name:string, isViewMode:boolean, data?:any, icon?:string) { + + this.templateUrl = templateUrl; + this.controller = controller; + this.icon = icon; + this.data = data; + this.name = name; + this.isViewMode = isViewMode; + } +} + + + diff --git a/catalog-ui/src/app/models/tooltip-data.ts b/catalog-ui/src/app/models/tooltip-data.ts new file mode 100644 index 0000000000..902a20e926 --- /dev/null +++ b/catalog-ui/src/app/models/tooltip-data.ts @@ -0,0 +1,6 @@ +'use strict'; + +export class TooltipData { +} + + diff --git a/catalog-ui/src/app/models/user.ts b/catalog-ui/src/app/models/user.ts new file mode 100644 index 0000000000..8ef800acb7 --- /dev/null +++ b/catalog-ui/src/app/models/user.ts @@ -0,0 +1,96 @@ +'use strict'; +import {IUserResource} from "../services/user-resource-service"; + +export enum UserRole { + ADMIN, + DESIGNER, + TESTER, + GOVERNOR, + OPS, + PRODUCT_MANAGER, + PRODUCT_STRATEGIST +} + +export interface IUserManager { + isInEditMode:boolean; + filterTerm:string; +} + +export interface IUserProperties extends IUserManager { + firstName:string; + lastName:string; + userId:string; + email:string; + role:string; + tempRole:string; + lastLoginTime:string; + status:string; +} + +export interface IUser { + resource:IUserResource; + getRole():UserRole; + getRoleToView():string; + getName():string; + getFirstName():string; + getLastName():string; +} + +export class User implements IUser { + + constructor(public resource:IUserResource) { + } + + public getLastName = () => { + return this.resource.lastName; + } + + public getFirstName = () => { + return this.resource.firstName; + } + + public getName = () => { + return this.resource.firstName + ' ' + this.resource.lastName; + } + + public getLastLogin = () => { + if (!this.resource.lastLoginTime || this.resource.lastLoginTime === "0") { + return ""; + } else { + return this.resource.lastLoginTime; + } + } + + public getRole = ():UserRole => { + let role:UserRole; + switch (UserRole[this.resource.role.toUpperCase()]) { + case UserRole.ADMIN: + role = UserRole.ADMIN; + break; + case UserRole.DESIGNER: + role = UserRole.DESIGNER; + break; + case UserRole.TESTER: + role = UserRole.TESTER; + break; + case UserRole.GOVERNOR: + role = UserRole.GOVERNOR; + break; + case UserRole.OPS: + role = UserRole.OPS; + break; + case UserRole.PRODUCT_MANAGER: + role = UserRole.PRODUCT_MANAGER; + break; + case UserRole.PRODUCT_STRATEGIST: + role = UserRole.PRODUCT_STRATEGIST; + break; + } + return role; + } + + public getRoleToView = ():string => { + let role:string = this.resource.role.toLowerCase().replace('governor', 'governance_Rep'); + return role.charAt(0).toUpperCase() + role.slice(1).replace('_', ' '); + } +} diff --git a/catalog-ui/src/app/models/validate.ts b/catalog-ui/src/app/models/validate.ts new file mode 100644 index 0000000000..59638ab4dd --- /dev/null +++ b/catalog-ui/src/app/models/validate.ts @@ -0,0 +1,7 @@ +'use strict'; + +export interface IValidate { + isValid:boolean; +} + + diff --git a/catalog-ui/src/app/models/validation-config.ts b/catalog-ui/src/app/models/validation-config.ts new file mode 100644 index 0000000000..3524addf86 --- /dev/null +++ b/catalog-ui/src/app/models/validation-config.ts @@ -0,0 +1,20 @@ +class PropertyValue { + min: number; + max: number; +} + +class validationPatterns { + string: string; + comment:string; + integer: string; +} + +export class Validations { + propertyValue: PropertyValue; + validationPatterns: validationPatterns; +} + +export class ValidationConfiguration { + static validation: Validations; + +} diff --git a/catalog-ui/src/app/modules/directive-module.ts b/catalog-ui/src/app/modules/directive-module.ts new file mode 100644 index 0000000000..6ad89b8db7 --- /dev/null +++ b/catalog-ui/src/app/modules/directive-module.ts @@ -0,0 +1,152 @@ +import {ClickedOutsideDirective} from "../directives/clicked-outside/clicked-outside-directive"; +import {LoaderDirective} from "../directives/loader/loader-directive"; +import {UserHeaderDetailsDirective} from "../directives/user-header-details/user-header-details-directive"; +import {FileTypeDirective} from "../directives/file-type/file-type"; +import {DownloadArtifactDirective} from "../directives/download-artifact/download-artifact"; +import {EllipsisDirective} from "../directives/ellipsis/ellipsis-directive"; +import {InvalidCharactersDirective} from "../directives/invalid-characters/invalid-characters"; +import {ExpandCollapseDirective} from "../directives/utils/expand-collapse/expand-collapse"; +import {PerfectScrollerDirective} from "../directives/perfect-scrollbar/angular-perfect-scrollbar"; +import {SdcModalDirective} from "../directives/modal/sdc-modal"; +import {FileOpenerDirective} from "../directives/file-opener/file-opener"; +import {FileUploadDirective} from "../directives/file-upload/file-upload"; +import {StructureTreeDirective} from "../directives/structure-tree/structure-tree-directive"; +import {SmartTooltipDirective} from "../directives/utils/smart-tooltip/smart-tooltip"; +import {PrintGraphScreenDirective} from "../directives/print-graph-screen/print-graph-screen"; +import {TagDirective} from "../directives/tag/tag-directive"; +import {SdcTagsDirective} from "../directives/utils/sdc-tags/sdc-tags"; +import {SdcKeyboardEventsDirective} from "../directives/utils/sdc-keyboard-events/sdc-keyboard-events"; +import {ExpandCollapseMenuBoxDirective} from "../directives/utils/expand-collapse-menu-box/expand-collaps-menu-box"; +import {PunchOutDirective} from "../directives/punch-out/punch-out"; +import {CustomValidationDirective} from "../directives/custom-validation/custom-validation"; +import {EcompHeaderDirective} from "../directives/ecomp-header/ecomp-header"; +import {EcompFooterDirective} from "../directives/ecomp-footer/ecomp-footer"; +import {EditNamePopoverDirective} from "../directives/edit-name-popover/edit-name-popover-directive"; +import {DataTypeFieldsStructureDirective} from "../directives/property-types/data-type-fields-structure/data-type-fields-structure"; +import {TypeMapDirective} from "../directives/property-types/type-map/type-map-directive"; +import {TypeListDirective} from "../directives/property-types/type-list/type-list-directive"; +import {SelectDataTypeFieldsStructureDirective} from "../directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure"; +import {SelectTypeMapDirective} from "../directives/select-property-types/select-type-map/select-type-map-directive"; +import {SelectTypeListDirective} from "../directives/select-property-types/select-type-list/select-type-list-directive"; +import {ValidationOnLoadDirective} from "../directives/utils/validation-on-load/validation-on-load"; +import {InfoTooltipDirective} from "../directives/info-tooltip/info-tooltip"; +import {SdcTabsDirective} from "../directives/sdc-tabs/sdc-tabs-directive"; +import {SdcSingleTabDirective, InnerSdcSingleTabDirective} from "../directives/sdc-tabs/sdc-single-tab/sdc-single-tab-directive"; +import {ExpandCollapseListHeaderDirective} from "../directives/utils/expand-collapse-list-header/expand-collapse-list-header"; +import {JsonExportExcelDirective} from "../directives/export-json-to-excel/export-json-to-excel"; +import {TopNavDirective} from "../directives/layout/top-nav/top-nav"; +import {TopProgressDirective} from "../directives/layout/top-progress/top-progress"; +import {CheckboxElementDirective} from "../directives/elements/checkbox/checkbox"; +import {RadiobuttonElementDirective} from "../directives/elements/radiobutton/radiobutton"; +import {OnLastRepeatDirective} from "../directives/events/on-last-repeat/on-last-repeat"; +import {InputRowDirective} from "../directives/inputs-and-properties/inputs/input-row-directive"; +import {PropertyRowDirective} from "../directives/inputs-and-properties/properties/property-row-directive"; +import {NodesFactory} from "../models/graph/nodes/nodes-factory"; +import {LinksFactory} from "../models/graph/graph-links/links-factory"; +import {ImageCreatorService} from "../directives/graphs-v2/image-creator/image-creator.service"; +import {Palette} from "../directives/graphs-v2/palette/palette.directive"; +import {CompositionGraph} from "../directives/graphs-v2/composition-graph/composition-graph.directive"; +import {RelationMenuDirective} from "../directives/graphs-v2/relation-menu/relation-menu"; +import {DeploymentGraph} from "../directives/graphs-v2/deployment-graph/deployment-graph.directive"; +import {CommonGraphUtils} from "../directives/graphs-v2/common/common-graph-utils"; +import {CompositionGraphNodesUtils} from "../directives/graphs-v2/composition-graph/utils/composition-graph-nodes-utils"; +import {CompositionGraphGeneralUtils} from "../directives/graphs-v2/composition-graph/utils/composition-graph-general-utils"; +import {CompositionGraphLinkUtils} from "../directives/graphs-v2/composition-graph/utils/composition-graph-links-utils"; +import {DeploymentGraphGeneralUtils} from "../directives/graphs-v2/deployment-graph/deployment-utils/deployment-graph-general-utils"; +import {CompositionGraphPaletteUtils} from "../directives/graphs-v2/composition-graph/utils/composition-graph-palette-utils"; +import {MatchCapabilitiesRequirementsUtils} from "../directives/graphs-v2/composition-graph/utils/match-capability-requierment-utils"; +import {AssetPopoverDirective} from "../directives/graphs-v2/asset-popover/asset-popover"; +import {downgradeComponent} from "@angular/upgrade/static"; +import {CapabilitiesListDirective} from "../directives/capabilities-and-requirements/capability/capabilities-list-directive"; +import {RequirementsListDirective} from "../directives/capabilities-and-requirements/requirement/requirements-list-directive"; + +let moduleName:string = 'Sdc.Directives'; +let directiveModule:ng.IModule = angular.module(moduleName, []); + +directiveModule.directive('clickedOutside', ClickedOutsideDirective.factory); +directiveModule.directive('loader', LoaderDirective.factory); +directiveModule.directive('userHeaderDetails', UserHeaderDetailsDirective.factory); +directiveModule.directive('ellipsis', EllipsisDirective.factory); +directiveModule.directive('downloadArtifact', DownloadArtifactDirective.factory); +directiveModule.directive('fileType', FileTypeDirective.factory); +directiveModule.directive('invalidCharacters', InvalidCharactersDirective.factory); +directiveModule.directive('perfectScrollbar', PerfectScrollerDirective.factory); +directiveModule.directive('expandCollapse', ExpandCollapseDirective.factory); +directiveModule.directive('sdcModal', SdcModalDirective.factory); +directiveModule.directive('fileOpener', FileOpenerDirective.factory); +directiveModule.directive('fileUpload', FileUploadDirective.factory); +directiveModule.directive('structureTree', StructureTreeDirective.factory); +directiveModule.directive('sdcSmartTooltip', SmartTooltipDirective.factory); +directiveModule.directive('printGraphScreen', PrintGraphScreenDirective.factory); +directiveModule.directive('sdcTag', TagDirective.factory); +directiveModule.directive('sdcTags', SdcTagsDirective.factory); +directiveModule.directive('sdcKeyboardEvents', SdcKeyboardEventsDirective.factory); +directiveModule.directive('expandCollapseMenuBox', ExpandCollapseMenuBoxDirective.factory); +directiveModule.directive('punchOut', PunchOutDirective.factory); +directiveModule.directive('customValidation', CustomValidationDirective.factory); +directiveModule.directive('ecompHeader', EcompHeaderDirective.factory); +directiveModule.directive('ecompFooter', EcompFooterDirective.factory); +directiveModule.directive('editNamePopover', EditNamePopoverDirective.factory); +directiveModule.directive('fieldsStructure', DataTypeFieldsStructureDirective.factory); +directiveModule.directive('typeMap', TypeMapDirective.factory); +directiveModule.directive('typeList', TypeListDirective.factory); +directiveModule.directive('selectFieldsStructure', SelectDataTypeFieldsStructureDirective.factory); +directiveModule.directive('selectTypeMap', SelectTypeMapDirective.factory); +directiveModule.directive('selectTypeList', SelectTypeListDirective.factory); +directiveModule.directive('infoTooltip', InfoTooltipDirective.factory); +directiveModule.directive('validationOnLoad', ValidationOnLoadDirective.factory); +directiveModule.directive('sdcTabs', SdcTabsDirective.factory); +directiveModule.directive('sdcSingleTab', SdcSingleTabDirective.factory); +directiveModule.directive('innerSdcSingleTab', InnerSdcSingleTabDirective.factory); +directiveModule.directive('jsonExportExcel', JsonExportExcelDirective.factory); +directiveModule.directive('expandCollapseListHeader', ExpandCollapseListHeaderDirective.factory); +// +// // Layouts +directiveModule.directive('topNav', TopNavDirective.factory); +directiveModule.directive('topProgress', TopProgressDirective.factory); +// +// // Elements +directiveModule.directive('sdcCheckbox', CheckboxElementDirective.factory); +directiveModule.directive('sdcRadioButton', RadiobuttonElementDirective.factory); +// +// // Events +directiveModule.directive('onLastRepeat', OnLastRepeatDirective.factory); +// +// //Inputs & Properties +directiveModule.directive('inputRow', InputRowDirective.factory); +directiveModule.directive('propertyRow', PropertyRowDirective.factory); +// +// +// // ------------------------------------------- Composition & Deployment Graphs------------------------------------------// +// +// //Util service for Graph +directiveModule.service('NodesFactory', NodesFactory); +directiveModule.service('LinksFactory', LinksFactory); +directiveModule.service('ImageCreatorService', ImageCreatorService); +// +// //composition +directiveModule.directive('palette', Palette.factory); +directiveModule.directive('compositionGraph', CompositionGraph.factory); +directiveModule.directive('relationMenu', RelationMenuDirective.factory); + //directiveModule.directive('assetPopover', AssetPopoverDirective.factory); +// +// //deployment +directiveModule.directive('deploymentGraph', DeploymentGraph.factory); +// +// //Graph Utils - Common +directiveModule.service('CommonGraphUtils', CommonGraphUtils); +// +// //Composition Graph Utils +directiveModule.service('CompositionGraphNodesUtils', CompositionGraphNodesUtils); +directiveModule.service('CompositionGraphGeneralUtils', CompositionGraphGeneralUtils); +directiveModule.service('CompositionGraphLinkUtils', CompositionGraphLinkUtils); +directiveModule.service('CompositionGraphPaletteUtils', CompositionGraphPaletteUtils); +directiveModule.service('MatchCapabilitiesRequirementsUtils', MatchCapabilitiesRequirementsUtils); +// +// //Deployment Graph Utils +directiveModule.service('DeploymentGraphGeneralUtils', DeploymentGraphGeneralUtils); + + +//Compoisiton right tab directives +directiveModule.directive('capabilitiesList', CapabilitiesListDirective.factory); +directiveModule.directive('requirementsList', RequirementsListDirective.factory); diff --git a/catalog-ui/src/app/modules/filters.ts b/catalog-ui/src/app/modules/filters.ts new file mode 100644 index 0000000000..a62283f927 --- /dev/null +++ b/catalog-ui/src/app/modules/filters.ts @@ -0,0 +1,26 @@ +import {TestsIdFilter} from "../filters/tests-id-filter"; +import {TrimFilter} from "../filters/trim-filter"; +import {ResourceTypeFilter} from "../filters/resource-type-filter"; +import {StringToDateFilter} from "../filters/string-to-date-filter"; +import {CategoryTypeFilter} from "../filters/category-type-filter"; +import {CatalogStatusFilter} from "../filters/catalog-status-filter"; +import {TruncateFilter} from "../filters/truncate-filter"; +import {EntityFilter} from "../filters/entity-filter"; +import {GraphResourceNameFilter} from "../filters/graph-resource-name-filter"; +import {ResourceNameFilter} from "../filters/resource-name-filter"; +import {ClearWhiteSpacesFilter} from "../filters/clear-whitespaces-filter"; + +let moduleName:string = 'Sdc.Filters'; +let filterModule:ng.IModule = angular.module(moduleName, []); + +filterModule.filter("resourceName", ResourceNameFilter); +filterModule.filter("graphResourceName", GraphResourceNameFilter); +filterModule.filter("entityFilter", EntityFilter); +filterModule.filter("truncate", TruncateFilter); +filterModule.filter("catalogStatusFilter", CatalogStatusFilter); +filterModule.filter("categoryTypeFilter", CategoryTypeFilter); +filterModule.filter("stringToDateFilter", StringToDateFilter); +filterModule.filter("resourceTypeName", ResourceTypeFilter); +filterModule.filter("trim", TrimFilter); +filterModule.filter("clearWhiteSpaces", ClearWhiteSpacesFilter); +filterModule.filter('testsId', TestsIdFilter); diff --git a/catalog-ui/src/app/modules/service-module.ts b/catalog-ui/src/app/modules/service-module.ts new file mode 100644 index 0000000000..55ba87b9fb --- /dev/null +++ b/catalog-ui/src/app/modules/service-module.ts @@ -0,0 +1,66 @@ +import {ConfigurationUiService} from "../services/configuration-ui-service"; +import {CookieService} from "../services/cookie-service"; +import {EntityService} from "../services/entity-service"; +import {AvailableIconsService} from "../services/available-icons-service"; +import {UrlToBase64Service} from "../services/url-tobase64-service"; +import {CacheService} from "../services/cache-service"; +import {HeaderInterceptor} from "../services/header-interceptor"; +import {HttpErrorInterceptor} from "../services/http-error-interceptor"; +import {SharingService} from "../services/sharing-service"; +import {SdcVersionService} from "../services/sdc-version-service"; +import {ActivityLogService} from "../services/activity-log-service"; +import {OnboardingService} from "../services/onboarding-service"; +import {EcompHeaderService} from "../services/ecomp-service"; +import {DataTypesService} from "../services/data-types-service"; +import {ComponentService} from "../services/components/component-service"; +import {ServiceService} from "../services/components/service-service"; +import {ResourceService} from "../services/components/resource-service"; +import {ProductService} from "../services/components/product-service"; +import {LeftPaletteLoaderService} from "../services/components/utils/composition-left-palette-service"; +import {EventListenerService} from "../services/event-listener-service"; +import {ProgressService} from "../services/progress-service"; +import {ArtifactsUtils} from "../utils/artifacts-utils"; +import {FileUtils} from "../utils/file-utils"; +import {ValidationUtils} from "../utils/validation-utils"; +import {AngularJSBridge} from "../services/angular-js-bridge-service"; +import {LoaderService} from "../services/loader-service"; +import {UserResourceService} from "../services/user-resource-service"; +import {CategoryResourceService} from "../services/category-resource-service"; + +let moduleName:string = 'Sdc.Services'; +let serviceModule:ng.IModule = angular.module(moduleName, []); + +serviceModule.service('Sdc.Services.ConfigurationUiService', ConfigurationUiService); +serviceModule.service('Sdc.Services.CookieService', CookieService); +serviceModule.service('Sdc.Services.EntityService', EntityService); +serviceModule.service('Sdc.Services.AvailableIconsService', AvailableIconsService); +serviceModule.service('Sdc.Services.UrlToBase64Service', UrlToBase64Service); +serviceModule.service('Sdc.Services.CacheService', CacheService); +serviceModule.service('Sdc.Services.HeaderInterceptor', HeaderInterceptor); +serviceModule.service('Sdc.Services.HttpErrorInterceptor', HttpErrorInterceptor); +serviceModule.service('Sdc.Services.SharingService', SharingService); +serviceModule.service('Sdc.Services.SdcVersionService', SdcVersionService); +serviceModule.service('Sdc.Services.ActivityLogService', ActivityLogService); +serviceModule.service('Sdc.Services.OnboardingService', OnboardingService); +serviceModule.service('Sdc.Services.EcompHeaderService', EcompHeaderService); +serviceModule.service('Sdc.Services.DataTypesService', DataTypesService); + +//Components Services +serviceModule.service('Sdc.Services.Components.ComponentService', ComponentService); +serviceModule.service('Sdc.Services.Components.ServiceService',ServiceService); +serviceModule.service('Sdc.Services.Components.ResourceService', ResourceService); +serviceModule.service('Sdc.Services.Components.ProductService', ProductService); +serviceModule.service('LeftPaletteLoaderService', LeftPaletteLoaderService); +serviceModule.service('EventListenerService', EventListenerService); +serviceModule.service('Sdc.Services.ProgressService', ProgressService); + +//Utils +serviceModule.service('ArtifactsUtils', ArtifactsUtils); +serviceModule.service('FileUtils', FileUtils); +serviceModule.service('ValidationUtils', ValidationUtils); + +serviceModule.service('AngularJSBridge',AngularJSBridge); +serviceModule.service('LoaderService', LoaderService); + +serviceModule.factory('Sdc.Services.UserResourceService', UserResourceService.getResource); +serviceModule.factory('Sdc.Services.CategoryResourceService', CategoryResourceService.getResource); diff --git a/catalog-ui/src/app/modules/utils.ts b/catalog-ui/src/app/modules/utils.ts new file mode 100644 index 0000000000..529857ac39 --- /dev/null +++ b/catalog-ui/src/app/modules/utils.ts @@ -0,0 +1,16 @@ +import {ComponentFactory} from "../utils/component-factory"; +import {ComponentInstanceFactory} from "../utils/component-instance-factory"; +import {ChangeLifecycleStateHandler} from "../utils/change-lifecycle-state-handler"; +import {ModalsHandler} from "../utils/modals-handler"; +import {MenuHandler} from "../utils/menu-handler"; + +let moduleName:string = 'Sdc.Utils'; +let serviceModule:ng.IModule = angular.module(moduleName, []); + +//Utils +serviceModule.service('ComponentFactory', ComponentFactory); +serviceModule.service('ComponentInstanceFactory', ComponentInstanceFactory); +serviceModule.service('ChangeLifecycleStateHandler', ChangeLifecycleStateHandler); +serviceModule.service('ModalsHandler', ModalsHandler); +serviceModule.service('MenuHandler', MenuHandler); + diff --git a/catalog-ui/src/app/modules/view-model-module.ts b/catalog-ui/src/app/modules/view-model-module.ts new file mode 100644 index 0000000000..4060fe794e --- /dev/null +++ b/catalog-ui/src/app/modules/view-model-module.ts @@ -0,0 +1,125 @@ +import {AddCategoryModalViewModel} from "../view-models/admin-dashboard/add-category-modal/add-category-modal-view-model"; +import {DashboardViewModel} from "../view-models/dashboard/dashboard-view-model"; +import {WorkspaceViewModel} from "../view-models/workspace/workspace-view-model"; +import {CompositionViewModel} from "../view-models/workspace/tabs/composition/composition-view-model"; +import {DetailsViewModel} from "../view-models/workspace/tabs/composition/tabs/details/details-view-model"; +import {ResourceArtifactsViewModel} from "../view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model"; +import {PropertyFormBaseView} from "../view-models/forms/property-forms/base-property-form/property-form-base-model"; +import {PropertyFormViewModel} from "../view-models/forms/property-forms/component-property-form/property-form-view-model"; +import {ModulePropertyView} from "../view-models/forms/property-forms/module-property-modal/module-property-model"; +import {ArtifactResourceFormViewModel} from "../view-models/forms/artifact-form/artifact-form-view-model"; +import {SelectDataTypeViewModel} from "../view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model"; +import {AttributeFormViewModel} from "../view-models/forms/attribute-form/attribute-from-view-model"; +import {ResourcePropertiesViewModel} from "../view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model"; +import {CatalogViewModel} from "../view-models/catalog/catalog-view-model"; +import {OnboardVendorViewModel} from "../view-models/onboard-vendor/onboard-vendor-view-model"; +import {DistributionViewModel} from "../view-models/workspace/tabs/distribution/distribution-view-model"; +import {SupportViewModel} from "../view-models/support/support-view-model"; +import {ConfirmationModalViewModel} from "../view-models/modals/confirmation-modal/confirmation-modal-view-model"; +import {EmailModalViewModel} from "../view-models/modals/email-modal/email-modal-view-model"; +import {MessageModalViewModel} from "../view-models/modals/message-modal/message-base-modal-model"; +import {ServerMessageModalViewModel} from "../view-models/modals/message-modal/message-server-modal/server-message-modal-view-model"; +import {ClientMessageModalViewModel} from "../view-models/modals/message-modal/message-client-modal/client-message-modal-view-model"; +import {ErrorViewModel} from "../view-models/modals/error-modal/error-view-model"; +import {RelationsViewModel} from "../view-models/workspace/tabs/composition/tabs/relations/relations-view-model"; +import {ResourceInstanceNameViewModel} from "../view-models/forms/resource-instance-name-form/resource-instance-name-model"; +import {WelcomeViewModel} from "../view-models/welcome/welcome-view"; +import {PreLoadingViewModel} from "../view-models/preloading/preloading-view"; +import {TutorialEndViewModel} from "../view-models/tutorial-end/tutorial-end"; +import {AdminDashboardViewModel} from "../view-models/admin-dashboard/admin-dashboard-view-model"; +import {EnvParametersFormViewModel} from "../view-models/forms/env-parameters-form/env-parameters-form"; +import {StructureViewModel} from "../view-models/workspace/tabs/composition/tabs/structure/structure-view"; +import {UserManagementViewModel} from "../view-models/admin-dashboard/user-management/user-management-view-model"; +import {CategoryManagementViewModel} from "../view-models/admin-dashboard/category-management/category-management-view-model"; + +import {OnboardingModalViewModel} from "../view-models/modals/onboarding-modal/onboarding-modal-view-model"; +import {DistributionStatusModalViewModel} from "../view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model"; +import {DcaeAppViewModel} from "../view-models/dcae-app/dcae-app-view-model"; +import {GeneralViewModel} from "../view-models/workspace/tabs/general/general-view-model"; +import {IconsViewModel} from "../view-models/workspace/tabs/icons/icons-view-model"; +import {DeploymentArtifactsViewModel} from "../view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model"; +import {InformationArtifactsViewModel} from "../view-models/workspace/tabs/information-artifacts/information-artifacts-view-model"; +import {ToscaArtifactsViewModel} from "../view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model"; +import {PropertiesViewModel} from "../view-models/workspace/tabs/properties/properties-view-model"; +import {AttributesViewModel} from "../view-models/workspace/tabs/attributes/attributes-view-model"; +import {ProductHierarchyViewModel} from "../view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model"; +import {ActivityLogViewModel} from "../view-models/workspace/tabs/activity-log/activity-log"; +import {ManagementWorkflowViewModel} from "../view-models/workspace/tabs/management-workflow/management-workflow-view-model"; +import {NetworkCallFlowViewModel} from "../view-models/workspace/tabs/network-call-flow/network-call-flow-view-model"; +import {DeploymentViewModel} from "../view-models/workspace/tabs/deployment/deployment-view-model"; +import {ResourceInputsViewModel} from "../view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model"; +import {ServiceInputsViewModel} from "../view-models/workspace/tabs/inputs/service-input/service-inputs-view-model"; +import {ReqAndCapabilitiesViewModel} from "../view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model"; +import {InputFormViewModel} from "../view-models/forms/input-form/input-form-view-modal"; +import {HierarchyViewModel} from "../view-models/tabs/hierarchy/hierarchy-view-model"; +import {downgradeComponent} from "@angular/upgrade/static"; +import {ConformanceLevelModalViewModel} from "../view-models/workspace/conformance-level-modal/conformance-level-modal-view-model"; +// import {NG2ExampleComponent} from "../ng2/view-ng2/ng2.example.component/ng2.example.component"; +// import {upgradeAdapter} from "../ng2/app.module"; +// import { UpgradeAdapter } from '@angular/upgrade'; +let moduleName:string = 'Sdc.ViewModels'; +let viewModelModule:ng.IModule = angular.module(moduleName, []); + +viewModelModule + .controller(moduleName + '.DashboardViewModel', DashboardViewModel) + + .controller(moduleName + '.DetailsViewModel', DetailsViewModel) + .controller(moduleName + '.ResourceArtifactsViewModel', ResourceArtifactsViewModel) + .controller(moduleName + '.PropertyFormBaseView', PropertyFormBaseView) + .controller(moduleName + '.PropertyFormViewModel', PropertyFormViewModel) + .controller(moduleName + '.ModulePropertyView', ModulePropertyView) + .controller(moduleName + '.SelectDataTypeViewModel', SelectDataTypeViewModel) + .controller(moduleName + '.ArtifactResourceFormViewModel', ArtifactResourceFormViewModel) + .controller(moduleName + '.AttributeFormViewModel', AttributeFormViewModel) + .controller(moduleName + '.ResourcePropertiesViewModel', ResourcePropertiesViewModel) + .controller(moduleName + '.CatalogViewModel', CatalogViewModel) + .controller(moduleName + '.OnboardVendorViewModel', OnboardVendorViewModel) + .controller(moduleName + '.DistributionViewModel', DistributionViewModel) + .controller(moduleName + '.SupportViewModel', SupportViewModel) + .controller(moduleName + '.ConfirmationModalViewModel', ConfirmationModalViewModel) + .controller(moduleName + '.EmailModalViewModel', EmailModalViewModel) + .controller(moduleName + '.MessageModalViewModel', MessageModalViewModel) + .controller(moduleName + '.ServerMessageModalViewModel', ServerMessageModalViewModel) + .controller(moduleName + '.ClientMessageModalViewModel', ClientMessageModalViewModel) + .controller(moduleName + '.ErrorViewModel', ErrorViewModel) + .controller(moduleName + '.RelationsViewModel', RelationsViewModel) + .controller(moduleName + '.ResourceInstanceNameViewModel', ResourceInstanceNameViewModel) + .controller(moduleName + '.WelcomeViewModel', WelcomeViewModel) + .controller(moduleName + '.PreLoadingViewModel', PreLoadingViewModel) + .controller(moduleName + '.TutorialEndViewModel', TutorialEndViewModel) + .controller(moduleName + '.AdminDashboardViewModel', AdminDashboardViewModel) + .controller(moduleName + '.EnvParametersFormViewModel', EnvParametersFormViewModel) + .controller(moduleName + '.StructureViewModel', StructureViewModel) + .controller(moduleName + '.AddCategoryModalViewModel', AddCategoryModalViewModel) + .controller(moduleName + '.UserManagementViewModel', UserManagementViewModel) + .controller(moduleName + '.CategoryManagementViewModel', CategoryManagementViewModel) + .controller(moduleName + '.OnboardingModalViewModel', OnboardingModalViewModel) + .controller(moduleName + '.DistributionStatusModalViewModel', DistributionStatusModalViewModel) + .controller(moduleName + '.DcaeAppViewModel', DcaeAppViewModel) + // + // //NEW + .controller(moduleName + '.WorkspaceViewModel', WorkspaceViewModel) + .controller(moduleName + '.ConformanceLevelModalViewModel', ConformanceLevelModalViewModel) + .controller(moduleName + '.CompositionViewModel', CompositionViewModel) + .controller(moduleName + '.GeneralViewModel', GeneralViewModel) + .controller(moduleName + '.IconsViewModel', IconsViewModel) + .controller(moduleName + '.DeploymentArtifactsViewModel', DeploymentArtifactsViewModel) + .controller(moduleName + '.InformationArtifactsViewModel', InformationArtifactsViewModel) + .controller(moduleName + '.ToscaArtifactsViewModel', ToscaArtifactsViewModel) + .controller(moduleName + '.PropertiesViewModel', PropertiesViewModel) + .controller(moduleName + '.AttributesViewModel', AttributesViewModel) + .controller(moduleName + '.ProductHierarchyViewModel', ProductHierarchyViewModel) + .controller(moduleName + '.ActivityLogViewModel', ActivityLogViewModel) + .controller(moduleName + '.ManagementWorkflowViewModel', ManagementWorkflowViewModel) + .controller(moduleName + '.NetworkCallFlowViewModel', NetworkCallFlowViewModel) + .controller(moduleName + '.DeploymentViewModel', DeploymentViewModel) + .controller(moduleName + '.ResourceInputsViewModel', ResourceInputsViewModel) + .controller(moduleName + '.ServiceInputsViewModel', ServiceInputsViewModel) + .controller(moduleName + '.ReqAndCapabilitiesViewModel', ReqAndCapabilitiesViewModel) + .controller(moduleName + '.InputFormViewModel', InputFormViewModel) + // + // //TABS + .controller(moduleName + '.HierarchyViewModel', HierarchyViewModel) + + // NG2 + //.controller(moduleName + '.NG2Example', downgradeComponent({component: NG2Example2Component}) ); diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal.less b/catalog-ui/src/app/ng2/app.component.css index e69de29bb2..e69de29bb2 100644 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal.less +++ b/catalog-ui/src/app/ng2/app.component.css diff --git a/catalog-ui/src/app/ng2/app.component.html b/catalog-ui/src/app/ng2/app.component.html new file mode 100644 index 0000000000..ed90b3deda --- /dev/null +++ b/catalog-ui/src/app/ng2/app.component.html @@ -0,0 +1,6 @@ +<!--<nav> + <app-navbar></app-navbar> +</nav> +<main> + <router-outlet></router-outlet> +</main>-->
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/app.component.ts b/catalog-ui/src/app/ng2/app.component.ts new file mode 100644 index 0000000000..0499045a79 --- /dev/null +++ b/catalog-ui/src/app/ng2/app.component.ts @@ -0,0 +1,15 @@ +import { Component, Inject } from '@angular/core'; +import { AuthenticationService } from './services/authentication.service'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + + constructor(auth:AuthenticationService){ + + } + +} diff --git a/catalog-ui/src/app/ng2/app.module.ts b/catalog-ui/src/app/ng2/app.module.ts new file mode 100644 index 0000000000..9e122cd288 --- /dev/null +++ b/catalog-ui/src/app/ng2/app.module.ts @@ -0,0 +1,74 @@ +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule, APP_INITIALIZER} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {forwardRef} from '@angular/core'; +import {AppComponent} from './app.component'; +import {UpgradeAdapter} from '@angular/upgrade'; +import {UpgradeModule} from '@angular/upgrade/static'; +import {PropertiesAssignmentModule} from './pages/properties-assignment/properties-assignment.module'; +import { + DataTypesServiceProvider, SharingServiceProvider, CookieServiceProvider, + StateParamsServiceFactory +} from "./utils/ng1-upgraded-provider"; +import {ConfigService} from "./services/config.service"; +import {HttpService} from "./services/http.service"; +import {HttpModule} from '@angular/http'; +import {AuthenticationService} from './services/authentication.service'; +import {Cookie2Service} from "./services/cookie.service"; +import {ComponentServiceNg2} from "./services/component-services/component.service"; +import {ServiceServiceNg2} from "./services/component-services/service.service"; +import {ComponentInstanceServiceNg2} from "./services/component-instance-services/component-instance.service"; + +export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule)); + +export function configServiceFactory(config:ConfigService) { + return () => config.loadValidationConfiguration(); +} + +// export function httpServiceFactory(backend: XHRBackend, options: RequestOptions) { +// return new HttpService(backend, options); +// } + +@NgModule({ + declarations: [ + AppComponent + ], + imports: [ + BrowserModule, + UpgradeModule, + FormsModule, + HttpModule, + PropertiesAssignmentModule + ], + exports: [], + entryComponents: [], + providers: [ + HttpService, + DataTypesServiceProvider, + SharingServiceProvider, + CookieServiceProvider, + StateParamsServiceFactory, + AuthenticationService, + Cookie2Service, + ConfigService, + ComponentServiceNg2, + ServiceServiceNg2, + ComponentInstanceServiceNg2, + { + provide: APP_INITIALIZER, + useFactory: configServiceFactory, + deps: [ConfigService], + multi: true + } + ], + bootstrap: [AppComponent] +}) + + +export class AppModule { + // ngDoBootstrap() {} + constructor(public upgrade:UpgradeModule) { + + + } +} diff --git a/catalog-ui/src/app/ng2/app.routing.ts b/catalog-ui/src/app/ng2/app.routing.ts new file mode 100644 index 0000000000..38bc92619f --- /dev/null +++ b/catalog-ui/src/app/ng2/app.routing.ts @@ -0,0 +1,20 @@ +import { RouterModule, Route } from '@angular/router'; +import { ModuleWithProviders } from '@angular/core'; +// import { Page1Component } from "./pages/page1/page1.component"; +// import { Page2Component } from "./pages/page2/page2.component"; +import { PageNotFoundComponent } from "./pages/page404/page404.component"; + +const routes: Route[] = [ + // { path: 'page1', component: Page1Component }, + // { path: 'page2', component: Page2Component }, + // { path: '', pathMatch: 'full', redirectTo: 'page1'}, + { path: '**', component: PageNotFoundComponent } + /*{ loadChildren: './pages/dashboard/dashboard.module#DashboardModule', path: 'dashboard' }*/ +]; + +export const routing: ModuleWithProviders = RouterModule.forRoot( + routes, + { + useHash: true + } +); diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.less b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.less new file mode 100644 index 0000000000..e219d49aa4 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.less @@ -0,0 +1,3 @@ +dynamic-element { + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.ts new file mode 100644 index 0000000000..de5965e488 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.component.ts @@ -0,0 +1,117 @@ +import { Component, Compiler, EventEmitter, ViewContainerRef, ViewChild, Input, Output, ElementRef, ComponentRef, ComponentFactory, ComponentFactoryResolver } from '@angular/core' +import { UiElementCheckBoxComponent } from './elements-ui/checkbox/ui-element-checkbox.component'; +import { UiElementDropDownComponent, DropdownValue } from './elements-ui/dropdown/ui-element-dropdown.component'; +import { UiElementInputComponent } from './elements-ui/input/ui-element-input.component'; +import {UiElementPopoverInputComponent} from "./elements-ui/popover-input/ui-element-popover-input.component"; +import {ValidationConfiguration} from "app/models"; + +@Component({ + selector: 'dynamic-element', + template: `<div #target></div>`, + styleUrls: ['./dynamic-element.component.less'], + entryComponents: [ + UiElementInputComponent, + UiElementDropDownComponent, + UiElementCheckBoxComponent, + UiElementPopoverInputComponent + ] +}) +export class DynamicElementComponent { + + @ViewChild('target', { read: ViewContainerRef }) target: any; + @Input() type: any; + @Input() name: string; + value:any; + + // Two way binding for value (need to write the "Change" word like this) + @Output('valueChange') emitter: EventEmitter<string> = new EventEmitter<any>(); + @Input('value') set setValueValue(value) { + this.value = value; + } + + cmpRef: ComponentRef<any>; + private isViewInitialized: boolean = false; + validation = ValidationConfiguration.validation; + + constructor( + private componentFactoryResolver: ComponentFactoryResolver, + private compiler: Compiler, + private el: ElementRef) { + } + + updateComponent() { + if (!this.isViewInitialized) { + return; + } + if (this.cmpRef) { + this.cmpRef.destroy(); + } + + // Factory to create component based on type or peroperty name. + switch(this.type) { + case 'list': + case 'integer': + this.createComponent(UiElementInputComponent); + this.cmpRef.instance.pattern = this.validation.validationPatterns.integer; + break; + case 'string': + switch(this.name.toUpperCase()) { + case 'SUBNETPOOLID': + this.createComponent(UiElementPopoverInputComponent); + break; + default: + this.createComponent(UiElementInputComponent); + } + break; + case 'boolean': + //this.createComponent(UiElementCheckBoxComponent); + + this.createComponent(UiElementDropDownComponent); + + // Build drop down values + let tmp = []; + tmp.push(new DropdownValue('true','TRUE')); + tmp.push(new DropdownValue('false','FALSE')); + this.cmpRef.instance.values = tmp; + break; + default: + this.createComponent(UiElementInputComponent); + console.log("ERROR: No ui component to handle type: " + this.type); + } + + // Additional attributes in base element class + if (this.cmpRef) { + this.cmpRef.instance.name = this.name; + this.cmpRef.instance.type = this.type; + this.cmpRef.instance.value = this.value; + } + + // Subscribe to change event of of ui-element-basic and fire event to change the value + this.cmpRef.instance.baseEmitter.subscribe((value):void => { + this.emitter.emit(value) + }); + + } + + createComponent(ComponentToCreate:any):void { + let factory = this.componentFactoryResolver.resolveComponentFactory(ComponentToCreate); + this.cmpRef = this.target.createComponent(factory); + } + + ngOnChanges() { + this.updateComponent(); + } + + ngAfterContentInit() { + //console.log("DynamicElementComponent: ngAfterContentInit: type: " + this.type + " value: " + this.value); + this.isViewInitialized = true; + this.updateComponent(); + } + + ngOnDestroy() { + if (this.cmpRef) { + this.cmpRef.destroy(); + } + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.module.ts b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.module.ts new file mode 100644 index 0000000000..18b044bc9d --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/dynamic-element.module.ts @@ -0,0 +1,34 @@ +import { NgModule } from "@angular/core"; +import { UiElementCheckBoxComponent } from './elements-ui/checkbox/ui-element-checkbox.component'; +import { UiElementDropDownComponent } from './elements-ui/dropdown/ui-element-dropdown.component'; +import { UiElementInputComponent } from './elements-ui/input/ui-element-input.component'; +import { DynamicElementComponent } from "app/ng2/components/dynamic-element/dynamic-element.component"; +import { BrowserModule } from '@angular/platform-browser' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { UiElementPopoverInputComponent } from "./elements-ui/popover-input/ui-element-popover-input.component"; +import {PopoverModule} from "../popover/popover.module"; +import {TooltipModule} from "../tooltip/tooltip.module"; + +@NgModule({ + declarations: [ + DynamicElementComponent, + UiElementInputComponent, + UiElementCheckBoxComponent, + UiElementDropDownComponent, + UiElementPopoverInputComponent + ], + imports: [ + BrowserModule, + FormsModule, + PopoverModule, + ReactiveFormsModule, + TooltipModule + ], + exports: [ + DynamicElementComponent + ], + providers: [] +}) +export class DynamicElementModule { + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.html b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.html new file mode 100644 index 0000000000..2ad3d8e94a --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.html @@ -0,0 +1 @@ +<input #{{name}} [(ngModel)]="value" type="checkbox" (change)="onSave(value)" /> diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.less b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.less new file mode 100644 index 0000000000..bed097fe5e --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.less @@ -0,0 +1,2 @@ +/deep/ ui-element-checkbox { +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.ts new file mode 100644 index 0000000000..152303aee7 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/checkbox/ui-element-checkbox.component.ts @@ -0,0 +1,27 @@ +import { Component, ViewChild, ElementRef, ContentChildren, Input } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser' +import { UiElementBase, UiElementBaseInterface } from './../ui-element-base.component'; + +@Component({ + selector: 'ui-element-checkbox', + templateUrl: './ui-element-checkbox.component.html', + styleUrls: ['./ui-element-checkbox.component.less'], +}) +export class UiElementCheckBoxComponent extends UiElementBase implements UiElementBaseInterface { + + constructor() { + super(); + } + + ngAfterContentInit() { + // Convert the value to boolean (instanceOf does not work, the type is undefined). + if (this.value==='true' || this.value==='false') { + this.value = this.value==='true'?true:false; + } + } + + onSave() { + this.baseEmitter.emit(this.value); + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.html b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.html new file mode 100644 index 0000000000..589d00e42d --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.html @@ -0,0 +1,3 @@ +<select name='{{name}}' [(ngModel)]="value" #t (change)="onSave()"> + <option *ngFor="let ddvalue of values" [value]="ddvalue.value">{{ddvalue.label}}</option> +</select> diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.less b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.less new file mode 100644 index 0000000000..ea3e35140e --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.less @@ -0,0 +1,11 @@ +@import '../../../../../../assets/styles/variables'; + +/deep/ ui-element-dropdown { + + select { + text-indent: 6px; + border: solid 1px @main_color_o; + width: 100%; + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.ts new file mode 100644 index 0000000000..208bf54983 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/dropdown/ui-element-dropdown.component.ts @@ -0,0 +1,33 @@ +import { Component, EventEmitter, Output, Input } from '@angular/core' +import { BrowserModule } from '@angular/platform-browser' +import { UiElementBase, UiElementBaseInterface } from './../ui-element-base.component'; + +export class DropdownValue { + value:string; + label:string; + + constructor(value:string,label:string) { + this.value = value; + this.label = label; + } +} + +@Component({ + selector: 'ui-element-dropdown', + templateUrl: './ui-element-dropdown.component.html', + styleUrls: ['./ui-element-dropdown.component.less'], +}) +export class UiElementDropDownComponent extends UiElementBase implements UiElementBaseInterface { + + @Input() + values: DropdownValue[]; + + constructor() { + super(); + } + + onSave() { + this.baseEmitter.emit(this.value); + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.html b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.html new file mode 100644 index 0000000000..00fea65b72 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.html @@ -0,0 +1,13 @@ +<input + class="value-input" + [ngClass]="{'error': control.invalid}" + type="text" + [name]="name" + [(ngModel)]="value" + (change)="onSave()" + [attr.maxlength]="validation.propertyValue.max" + [attr.minlength]="validation.propertyValue.min" + [pattern]="pattern" + [formControl]="control" + tooltip="{{value}}" + /> diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.less b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.less new file mode 100644 index 0000000000..d320c7ff8b --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.less @@ -0,0 +1,17 @@ +@import '../../../../../../assets/styles/variables'; + +/deep/ ui-element-input { + + input { + text-indent: 6px; + border: solid 1px @main_color_o; + } + + .error { + border: solid 1px @func_color_q; + color: @func_color_q; + outline: none; + box-sizing: border-box; + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.ts new file mode 100644 index 0000000000..5a14d8f206 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/input/ui-element-input.component.ts @@ -0,0 +1,22 @@ +import { Component, ViewChild, ElementRef, ContentChildren } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser' +import { UiElementBase, UiElementBaseInterface } from './../ui-element-base.component'; + +@Component({ + selector: 'ui-element-input', + templateUrl: './ui-element-input.component.html', + styleUrls: ['./ui-element-input.component.less'], +}) +export class UiElementInputComponent extends UiElementBase implements UiElementBaseInterface { + + constructor() { + super(); + this.pattern = this.validation.validationPatterns.comment; + } + + onSave() { + if (!this.control.invalid){ + this.baseEmitter.emit(this.value); + } + } +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.html b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.html new file mode 100644 index 0000000000..5adceb49a0 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.html @@ -0,0 +1,26 @@ +<div class="popover-input-wrapper" tooltip="{{value}}"> + <input + class="value-input" + type="text" + [ngClass]="{'error': control.invalid}" + [name]="name" + [value]="value" + disabled + /> + <button [popover]="popoverForm">Edit</button> +</div> + +<popover-content #popoverForm [title]="name" [buttons]="buttonsArray" [placement]="'top'" [closeOnClickOutside]="true"> + <div class="edit-subnet-wrapper"> + <textarea rows="5" + #textArea + class="subnet-value" + [ngClass]="{'error': control.invalid}" + [(ngModel)]="value" + [attr.maxlength]="validation.propertyValue.max" + [attr.minlength]="validation.propertyValue.min" + [pattern]="pattern" + [formControl]="control" + ></textarea> + </div> +</popover-content> diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.less b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.less new file mode 100644 index 0000000000..5be443f7b6 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.less @@ -0,0 +1,36 @@ +@import '../../../../../../assets/styles/variables'; + +.popover-input-wrapper { + display: flex; +} + +/deep/ ui-element-popover-input { + + .popover { + max-width: 350px; + width: 350px; + } + + .edit-subnet-wrapper { + padding: 12px; + + .subnet-value { + width: 100%; + resize: none; + } + } + + input { + padding-right: 6px; + padding-left: 6px; + border: solid 1px @main_color_o; + } + + .error { + border: solid 1px @func_color_q; + color: @func_color_q; + outline: none; + box-sizing: border-box; + } + +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.ts new file mode 100644 index 0000000000..7300417686 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/popover-input/ui-element-popover-input.component.ts @@ -0,0 +1,39 @@ +import {Component, ViewChild, ElementRef} from '@angular/core'; +import {UiElementBase, UiElementBaseInterface} from "../ui-element-base.component"; +import {ButtonsModelMap, ButtonModel} from "app/models"; +import { PopoverContentComponent } from "app/ng2/components/popover/popover-content.component" +import { PopoverComponent } from "app/ng2/components/popover/popover.component" + +@Component({ + selector: 'ui-element-popover-input', + templateUrl: './ui-element-popover-input.component.html', + styleUrls: ['./ui-element-popover-input.component.less'] +}) +export class UiElementPopoverInputComponent extends UiElementBase implements UiElementBaseInterface { + + @ViewChild('textArea') textArea: ElementRef; + @ViewChild('popoverForm') popoverContentComponent: PopoverContentComponent; + + saveButton: ButtonModel; + buttonsArray: ButtonsModelMap; + + onSave = ():void => { + if (!this.control.invalid){ + this.baseEmitter.emit(this.value); + this.popoverContentComponent.hide(); + } + } + + constructor() { + super(); + // Create Save button and insert to buttons map + this.saveButton = new ButtonModel('save', 'blue', this.onSave); + this.buttonsArray = { 'test': this.saveButton }; + + // Define the regex pattern for this controller + this.pattern = this.validation.validationPatterns.comment; + + // Disable / Enable button according to validation + //this.control.valueChanges.subscribe(data => this.saveButton.disabled = this.control.invalid); + } +} diff --git a/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/ui-element-base.component.ts b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/ui-element-base.component.ts new file mode 100644 index 0000000000..b60271f6f0 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/dynamic-element/elements-ui/ui-element-base.component.ts @@ -0,0 +1,34 @@ +import { Component, EventEmitter, Input, Output } from '@angular/core' +import { ValidationConfiguration } from "app/models"; +import { FormControl, Validators } from '@angular/forms'; + +export interface UiElementBaseInterface { + onSave(); +} + +@Component({ + template: ``, + styles: [] +}) +export class UiElementBase { + + protected validation = ValidationConfiguration.validation; + protected control: FormControl; + + // Two way binding for value (need to write the "Change" word like this) + @Output('valueChange') baseEmitter: EventEmitter<string> = new EventEmitter<any>(); + @Input('value') set setValueValue(value) { + this.value = value; + } + + protected name: string; + protected type: string; + protected value: any; + protected pattern: any; + + constructor() { + //this.control = new FormControl('', [Validators.required]); + this.control = new FormControl('', []); + } + +} diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html new file mode 100644 index 0000000000..4d2b91f3b4 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.html @@ -0,0 +1,26 @@ +<popover-content #filterPopover [title]="'Filters'" [buttons]="footerButtons" placement="bottom-right" [hideArrow]="true"> + <!--<form [formGroup]="filterForm">--> + <form> + <div class="field"> + <label>Resource Type</label> + <div> + <checkbox [label]="'All'" [(checked)]="allSelected" (checkedChange)="selectAll()"></checkbox> + </div> + <div *ngFor="let type of typesOptions"> + <checkbox [label]="type" [(checked)]="selectedTypes[type]" (checkedChange)="onTypeSelected(type)"></checkbox> + </div> + </div> + <div class="field"> + <label>Property Name</label> + <input class="i-sdc-form-input" + name="propertyName" + [(ngModel)]="filterData.propertyName" + placeholder="Type here" + required + /> + </div> + </form> +</popover-content> +<div class="open-filter-button" [popover]="filterPopover" [ngClass]="{'open':showPopover}" (onShown)="showPopover = true" (onHidden)="showPopover = false"> + <div class="sprite-new filter-icon"></div> +</div> diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less new file mode 100644 index 0000000000..c1341b8dcf --- /dev/null +++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.less @@ -0,0 +1,38 @@ +@import '../../../../assets/styles/variables'; +form{ + margin: 0 20px; + .field{ + padding:20px 0; + &:not(:last-child){ + border-bottom: solid 1px @main_color_o; + } + } + /deep/ [ng-reflect-checked="true"]{ + /deep/ .checkbox-label-content{ + color: @main_color_a; + } + } +} + +.open-filter-button{ + cursor: pointer; + width: 25px; + height: 34px; + display: inline-block; + &.open{ + z-index: 1061; + position: relative; + top: 2px; + background-color: @main_color_p; + border: solid 1px @main_color_c; + border-bottom: none; + } + .filter-icon{ + top: 8px; + position: relative; + } +} + +/deep/ .popover{ + border: solid 1px @main_color_c !important; +} diff --git a/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts new file mode 100644 index 0000000000..c23e08bc0d --- /dev/null +++ b/catalog-ui/src/app/ng2/components/filter-properties-assignment/filter-properties-assignment.component.ts @@ -0,0 +1,77 @@ +/** + * Created by rc2122 on 5/16/2017. + */ +import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {ButtonModel, ButtonsModelMap, FilterPropertiesAssignmentData} from "app/models"; +import {PopoverComponent} from "../popover/popover.component"; +import * as sdcConfig from "../../../../../configurations/dev" + +@Component({ + selector: 'filter-properties-assignment', + templateUrl: './filter-properties-assignment.component.html', + styleUrls: ['./filter-properties-assignment.component.less'] +}) + +export class FilterPropertiesAssignmentComponent { + @Input() componentType: string; + @Output() searchProperties: EventEmitter<FilterPropertiesAssignmentData> = new EventEmitter<FilterPropertiesAssignmentData>(); + footerButtons:ButtonsModelMap = {}; + typesOptions:Array<string>;//All optional types + selectedTypes:Object = {}; + allSelected:boolean = false;//if all option selected + filterData:FilterPropertiesAssignmentData = new FilterPropertiesAssignmentData(); + @ViewChild('filterPopover') filterPopover: PopoverComponent; + + ngOnInit() { + this.footerButtons['Apply'] = new ButtonModel('Apply', 'blue', this.search, this.someTypesSelectedAndThereIsPropertyName); + this.footerButtons['Close'] = new ButtonModel('Close', 'grey', this.close); + this.componentType = this.componentType.toLocaleLowerCase(); + this.typesOptions = sdcConfig.resourceTypesFilter[this.componentType]; + } + + selectAll = () => { + _.forEach(this.typesOptions, (type) => { + this.selectedTypes[type] = this.allSelected; + }); + } + + onTypeSelected = (type:string) => { + if(!this.selectedTypes[type]){ + this.allSelected = false;//unselected 'All' + } + }; + + search = () => { + console.log('search props'); + this.filterData.selectedTypes = []; + _.forEach(sdcConfig.resourceTypesFilter[this.componentType], (type) => { + if(this.selectedTypes[type]){ + this.filterData.selectedTypes.push(type); + } + }); + this.searchProperties.emit(this.filterData); + this.filterPopover.hide(); + } + + close = () => { + this.filterPopover.hide(); + } + + someTypesSelectedAndThereIsPropertyName = ():boolean => { + if( _.find(Object.keys(this.selectedTypes),(key) => { + return this.selectedTypes[key]; + }) && this.filterData.propertyName ){ + return null + } + return true; + } + + clearAll = ():void => { + this.filterData.propertyName = ""; + _.forEach(this.selectedTypes,(value, key) => { + this.selectedTypes[key] = false; + }); + this.allSelected = false; + } + +} diff --git a/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-display-options.ts b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-display-options.ts new file mode 100644 index 0000000000..7045286ccd --- /dev/null +++ b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-display-options.ts @@ -0,0 +1,12 @@ +export class HierarchyDisplayOptions { + idProperty: string; + valueProperty: string; + childrenProperty: string; + searchText:string; + constructor(idProperty:string, valueProperty:string, childrenProperty?:string, searchText?:string) { + this.idProperty = idProperty; + this.valueProperty = valueProperty; + this.childrenProperty = childrenProperty; + this.searchText = searchText; + } +} diff --git a/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.html b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.html new file mode 100644 index 0000000000..40a1c37cee --- /dev/null +++ b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.html @@ -0,0 +1,13 @@ +<div class="navigation-wrapper"> + <div class="node-item" *ngFor="let item of displayData" (click)="onClick($event, item)"> + <div class="node-data-wrapper" [ngClass]="{'selected': selectedItem && selectedItem === item[displayOptions.idProperty]}"> + <span class="node-data" [ngClass]="{'mark':item[displayOptions.valueProperty] === displayOptions.searchText}">{{item[displayOptions.valueProperty]}}</span> + </div> + <div class="children-node" *ngIf="item[displayOptions.childrenProperty]"> + <hierarchy-navigation class="children-hierarchy" [displayData]="item[displayOptions.childrenProperty]" + [selectedItem]="selectedItem" + [displayOptions]="displayOptions" + (updateSelected)="onSelectedUpdate($event)"></hierarchy-navigation> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.less b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.less new file mode 100644 index 0000000000..57d51616a8 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.less @@ -0,0 +1,51 @@ +.navigation-wrapper { + text-align: left; +} + +.node-item { + border: 1px dotted; + border-right: none; + border-bottom: none; +} + +.node-item:last-child { + border-left: none; +} + +.node-data-wrapper { + cursor: default; + height: 30px; + line-height: 2.6em;; + position: relative; + top: -1.1em; + background-color: white; + margin-left: 0.7em; +} + +.children-node { + padding-left: 40px; +} + +.node-data { + margin-left: 10px; + margin-right: 10px; +} + +.node-data-wrapper.selected { + background-color: #e6f6fb; + + .node-data { + color: #009fdb; + } +} + +.node-data-wrapper:hover { + background-color: #eaeaea; +} + +.mark{ + background-color: yellow; +} + + + diff --git a/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.ts b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.ts new file mode 100644 index 0000000000..428bbb4b04 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/hierarchy-navigtion/hierarchy-navigation.component.ts @@ -0,0 +1,28 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {HierarchyDisplayOptions} from './hierarchy-display-options'; + + +@Component({ + selector: 'hierarchy-navigation', + templateUrl: './hierarchy-navigation.component.html', + styleUrls: ['./hierarchy-navigation.component.less'] +}) + +export class HierarchyNavigationComponent { + @Input() displayData: Array<any>; + @Input() selectedItem: any; + @Input() displayOptions: HierarchyDisplayOptions; + + @Output() updateSelected:EventEmitter<any> = new EventEmitter(); + + onClick = ($event, item) => { + $event.stopPropagation(); + this.selectedItem = item; + this.updateSelected.emit(item); + }; + + onSelectedUpdate = ($event) => { + this.selectedItem = $event; + this.updateSelected.emit($event); + } +} diff --git a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html new file mode 100644 index 0000000000..e7801b82cf --- /dev/null +++ b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.html @@ -0,0 +1,37 @@ +<div class="properties-table"> + <div class="table-header"> + <div class="table-cell col1">Property Name</div> + <div class="table-cell col2">Type</div> + <div class="table-cell col3">ES</div> + <div class="table-cell valueCol">Value</div> + </div> + <div class="table-body"> + <div class="no-data" *ngIf="!inputs || !inputs.length">No data to display</div> + <div class="table-row" *ngFor="let input of inputs"> + <div class="table-cell col1"> + <span tooltip="{{input.name}}" >{{input.name}}</span> + <span *ngIf="input.description" + class="property-description-icon sprite-new show-desc" + tooltip="{{input.description}}"></span> + </div> + <div class="table-cell col2">{{input.type | contentAfterLastDot}}</div> + <div class="table-cell col3">{{input.schema && input.schema.property && input.schema.property.type ? (input.schema.property.type | contentAfterLastDot) : ''}}</div> + <div class="table-cell valueCol input-value-col" [class.inner-table-container]="input.childrenProperties || !input.isSimpleType"> + <dynamic-element class="value-input" + *ngIf="input.isSimpleType" + pattern="validationUtils.getValidationPattern(input.type)" + [(value)]="input.defaultValue" + [type]="input.type" + [name]="input.name" + (change)="onInputValueChanged(input);"> + </dynamic-element> + <div class="delete-button-container"> + <span class="sprite-new delete-btn" (click)="onDeleteInput(input)"></span> + </div> + </div> + + </div> + </div> +</div> + + diff --git a/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts new file mode 100644 index 0000000000..ea01edf043 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/inputs-table/inputs-table.component.ts @@ -0,0 +1,33 @@ +/** + * Created by rc2122 on 5/4/2017. + */ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import {InputFEModel} from "app/models"; + +@Component({ + selector: 'inputs-table', + templateUrl: './inputs-table.component.html', + styleUrls: ['../properties-table/properties-table.component.less'] +}) +export class InputsTableComponent { + + @Input() inputs: Array<InputFEModel>; + + @Output() inputValueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() deleteInput: EventEmitter<any> = new EventEmitter<any>(); + + constructor (){ + } + + onInputValueChanged = (input) => { + this.inputValueChanged.emit(input); + }; + + onDeleteInput = (input) => { + this.deleteInput.emit(input); + } + + +} + + diff --git a/catalog-ui/src/app/ng2/components/popover/popover-content.component.html b/catalog-ui/src/app/ng2/components/popover/popover-content.component.html new file mode 100644 index 0000000000..6d76f0ad06 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/popover/popover-content.component.html @@ -0,0 +1,24 @@ +<div #popoverDiv class="popover {{ effectivePlacement }}" + [style.top]="top + 'px'" + [style.left]="left + 'px'" + [class.in]="isIn" + [class.fade]="animation" + style="display: block" + role="popover" + [ngClass]="{'hide-arrow':hideArrow}"> + <div [hidden]="!closeOnMouseOutside" class="virtual-area"></div> + <div class="arrow" *ngIf="!hideArrow"></div> + <div class="popover-header"> + <span class="title">{{ title }}</span> + <span class="close-button" (click)="popover.hide()"></span> + </div> + <ng-content></ng-content> + <div class="popover-footer"> + <button *ngFor="let buttonName of buttonsNames" + class="tlv-btn {{buttons[buttonName].cssClass}}" + [disabled] = "buttons[buttonName].getDisabled && buttons[buttonName].getDisabled()" + (click) = "buttons[buttonName].callback()">{{buttons[buttonName].text}}</button> + </div> +</div> + + diff --git a/catalog-ui/src/app/ng2/components/popover/popover-content.component.less b/catalog-ui/src/app/ng2/components/popover/popover-content.component.less new file mode 100644 index 0000000000..f7b62e91f7 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/popover/popover-content.component.less @@ -0,0 +1,73 @@ +@import '../../../../assets/styles/variables'; +@import '../../../../assets/styles/mixins'; +@import '../../../../assets/styles/sprite-old'; +.popover .virtual-area { + height: 11px; + width: 100%; + position: absolute; +} +.popover.top .virtual-area { + bottom: -11px; +} +.popover.bottom .virtual-area { + top: -11px; +} +.popover.left .virtual-area { + right: -11px; +} +.popover.right .virtual-area { + left: -11px; +} +.popover.hide-arrow{ + margin: 0; +} + +.popover-header{ + .m_14_m; + font-weight: bold; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; + height: 40px; + line-height: 48px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + text-align: left; + border-bottom: solid 1px @main_color_o; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + margin: 0px 20px; + .title{ + -webkit-box-flex: 999; + -ms-flex-positive: 999; + flex-grow: 999; + } + .close-button{ + .sprite; + .sprite.x-btn-black; + cursor: pointer; + } +} + +.popover-footer{ + background-color: @tlv_color_t; + height: 40px; + clear: both; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: end; + -ms-flex-pack: end; + justify-content: flex-end; + button{ + margin: 8px 12px 8px 6px; + } +} diff --git a/catalog-ui/src/app/ng2/components/popover/popover-content.component.ts b/catalog-ui/src/app/ng2/components/popover/popover-content.component.ts new file mode 100644 index 0000000000..c4489f59b9 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/popover/popover-content.component.ts @@ -0,0 +1,258 @@ +import {Component, Input, Output, AfterViewInit, ElementRef, ChangeDetectorRef, OnDestroy, ViewChild, EventEmitter, Renderer } from "@angular/core"; +import {ButtonsModelMap} from "app/models"; +import {PopoverComponent} from "./popover.component"; + +@Component({ + selector: "popover-content", + templateUrl:'./popover-content.component.html', + styleUrls:['popover-content.component.less'] +}) +export class PopoverContentComponent implements AfterViewInit, OnDestroy { + + @Input() public title: string; + @Input() public buttons:ButtonsModelMap; + + @Input() + content: string; + + @Input() + placement: "top"|"bottom"|"left"|"right"|"auto"|"auto top"|"auto bottom"|"auto left"|"auto right" = "bottom"; + + @Input() + animation: boolean = true; + + @Input() + closeOnClickOutside: boolean = false; + + @Input() + closeOnMouseOutside: boolean = false; + + @Input() + hideArrow: boolean = false; + + @ViewChild("popoverDiv") + popoverDiv: ElementRef; + + buttonsNames:Array<string>; + + popover: PopoverComponent; + onCloseFromOutside = new EventEmitter(); + top: number = -10000; + left: number = -10000; + isIn: boolean = false; + displayType: string = "none"; + effectivePlacement: string; + + onDocumentMouseDown = (event: any) => { + const element = this.element.nativeElement; + if (!element || !this.popover) return; + if (element.contains(event.target) || this.popover.getElement().contains(event.target)) return; + this.hide(); + this.onCloseFromOutside.emit(undefined); + }; + + + constructor(protected element: ElementRef, + protected cdr: ChangeDetectorRef, + protected renderer: Renderer) { + } + + listenClickFunc: any; + listenMouseFunc: any; + + ngAfterViewInit(): void { + this.buttonsNames = Object.keys(this.buttons); + if (this.closeOnClickOutside) + this.listenClickFunc = this.renderer.listenGlobal("document", "mousedown", (event: any) => this.onDocumentMouseDown(event)); + if (this.closeOnMouseOutside) + this.listenMouseFunc = this.renderer.listenGlobal("document", "mouseover", (event: any) => this.onDocumentMouseDown(event)); + + this.show(); + this.cdr.detectChanges(); + } + + ngOnDestroy() { + if (this.closeOnClickOutside) + this.listenClickFunc(); + if (this.closeOnMouseOutside) + this.listenMouseFunc(); + } + + // ------------------------------------------------------------------------- + // Public Methods + // ------------------------------------------------------------------------- + + show(): void { + if (!this.popover || !this.popover.getElement()) + return; + + const p = this.positionElements(this.popover.getElement(), this.popoverDiv.nativeElement, this.placement); + this.displayType = "block"; + this.top = p.top; + this.left = p.left; + this.isIn = true; + } + + hide(): void { + this.top = -10000; + this.left = -10000; + this.isIn = true; + this.popover.hide(); + } + + hideFromPopover() { + this.top = -10000; + this.left = -10000; + this.isIn = true; + } + + // ------------------------------------------------------------------------- + // Protected Methods + // ------------------------------------------------------------------------- + + protected positionElements(hostEl: HTMLElement, targetEl: HTMLElement, positionStr: string, appendToBody: boolean = false): { top: number, left: number } { + let positionStrParts = positionStr.split("-"); + let pos0 = positionStrParts[0]; + let pos1 = positionStrParts[1] || "center"; + let hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl); + let targetElWidth = targetEl.offsetWidth; + let targetElHeight = targetEl.offsetHeight; + + this.effectivePlacement = pos0 = this.getEffectivePlacement(pos0, hostEl, targetEl); + + let shiftWidth: any = { + center: function (): number { + return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2; + }, + left: function (): number { + return hostElPos.left; + }, + right: function (): number { + return hostElPos.left + hostElPos.width - targetElWidth; + } + }; + + let shiftHeight: any = { + center: function (): number { + return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2; + }, + top: function (): number { + return hostElPos.top; + }, + bottom: function (): number { + return hostElPos.top + hostElPos.height - targetElHeight; + } + }; + + let targetElPos: { top: number, left: number }; + switch (pos0) { + case "right": + targetElPos = { + top: shiftHeight[pos1](), + left: hostElPos.left + hostElPos.width + }; + break; + + case "left": + targetElPos = { + top: shiftHeight[pos1](), + left: hostElPos.left - targetElWidth + }; + break; + + case "bottom": + targetElPos = { + top: hostElPos.top + hostElPos.height, + left: shiftWidth[pos1]() + }; + break; + + default: + targetElPos = { + top: hostElPos.top - targetElHeight, + left: shiftWidth[pos1]() + }; + break; + } + + return targetElPos; + } + + protected position(nativeEl: HTMLElement): { width: number, height: number, top: number, left: number } { + let offsetParentBCR = { top: 0, left: 0 }; + const elBCR = this.offset(nativeEl); + const offsetParentEl = this.parentOffsetEl(nativeEl); + if (offsetParentEl !== window.document) { + offsetParentBCR = this.offset(offsetParentEl); + offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop; + offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft; + } + + const boundingClientRect = nativeEl.getBoundingClientRect(); + return { + width: boundingClientRect.width || nativeEl.offsetWidth, + height: boundingClientRect.height || nativeEl.offsetHeight, + top: elBCR.top - offsetParentBCR.top, + left: elBCR.left - offsetParentBCR.left + }; + } + + protected offset(nativeEl: any): { width: number, height: number, top: number, left: number } { + const boundingClientRect = nativeEl.getBoundingClientRect(); + return { + width: boundingClientRect.width || nativeEl.offsetWidth, + height: boundingClientRect.height || nativeEl.offsetHeight, + top: boundingClientRect.top + (window.pageYOffset || window.document.documentElement.scrollTop), + left: boundingClientRect.left + (window.pageXOffset || window.document.documentElement.scrollLeft) + }; + } + + protected getStyle(nativeEl: HTMLElement, cssProp: string): string { + if ((nativeEl as any).currentStyle) // IE + return (nativeEl as any).currentStyle[cssProp]; + + if (window.getComputedStyle) + return (window.getComputedStyle as any)(nativeEl)[cssProp]; + + // finally try and get inline style + return (nativeEl.style as any)[cssProp]; + } + + protected isStaticPositioned(nativeEl: HTMLElement): boolean { + return (this.getStyle(nativeEl, "position") || "static" ) === "static"; + } + + protected parentOffsetEl(nativeEl: HTMLElement): any { + let offsetParent: any = nativeEl.offsetParent || window.document; + while (offsetParent && offsetParent !== window.document && this.isStaticPositioned(offsetParent)) { + offsetParent = offsetParent.offsetParent; + } + return offsetParent || window.document; + } + + protected getEffectivePlacement(placement: string, hostElement: HTMLElement, targetElement: HTMLElement): string { + const placementParts = placement.split(" "); + if (placementParts[0] !== "auto") { + return placement; + } + + const hostElBoundingRect = hostElement.getBoundingClientRect(); + + const desiredPlacement = placementParts[1] || "bottom"; + + if (desiredPlacement === "top" && hostElBoundingRect.top - targetElement.offsetHeight < 0) { + return "bottom"; + } + if (desiredPlacement === "bottom" && hostElBoundingRect.bottom + targetElement.offsetHeight > window.innerHeight) { + return "top"; + } + if (desiredPlacement === "left" && hostElBoundingRect.left - targetElement.offsetWidth < 0) { + return "right"; + } + if (desiredPlacement === "right" && hostElBoundingRect.right + targetElement.offsetWidth > window.innerWidth) { + return "left"; + } + + return desiredPlacement; + } +} diff --git a/catalog-ui/src/app/ng2/components/popover/popover.component.ts b/catalog-ui/src/app/ng2/components/popover/popover.component.ts new file mode 100644 index 0000000000..a7e2881b29 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/popover/popover.component.ts @@ -0,0 +1,159 @@ +import { Directive, HostListener, ComponentRef, ViewContainerRef, ComponentFactoryResolver, ComponentFactory, Input, OnChanges, SimpleChange, Output, EventEmitter } from "@angular/core"; +import {PopoverContentComponent} from "./popover-content.component"; + +@Directive({ + selector: "[popover]", + exportAs: "popover" +}) +export class PopoverComponent implements OnChanges { + + protected PopoverComponent = PopoverContentComponent; + protected popover: ComponentRef<PopoverContentComponent>; + protected visible: boolean; + + + constructor(protected viewContainerRef: ViewContainerRef, + protected resolver: ComponentFactoryResolver) { + } + + @Input("popover") + content: string|PopoverContentComponent; + + @Input() + popoverDisabled: boolean; + + @Input() + popoverAnimation: boolean; + + @Input() + popoverPlacement: "top"|"bottom"|"left"|"right"|"auto"|"auto top"|"auto bottom"|"auto left"|"auto right"; + + @Input() + popoverTitle: string; + + @Input() + popoverOnHover: boolean = false; + + @Input() + popoverCloseOnClickOutside: boolean; + + @Input() + popoverCloseOnMouseOutside: boolean; + + @Input() + popoverDismissTimeout: number = 0; + + @Output() + onShown = new EventEmitter<PopoverComponent>(); + + @Output() + onHidden = new EventEmitter<PopoverComponent>(); + + @HostListener("click") + showOrHideOnClick(): void { + if (this.popoverOnHover) return; + if (this.popoverDisabled) return; + this.toggle(); + } + + @HostListener("focusin") + @HostListener("mouseenter") + showOnHover(): void { + if (!this.popoverOnHover) return; + if (this.popoverDisabled) return; + this.show(); + } + + @HostListener("focusout") + @HostListener("mouseleave") + hideOnHover(): void { + if (this.popoverCloseOnMouseOutside) return; + if (!this.popoverOnHover) return; + if (this.popoverDisabled) return; + this.hide(); + } + + ngOnChanges(changes: {[propertyName: string]: SimpleChange}) { + if (changes["popoverDisabled"]) { + if (changes["popoverDisabled"].currentValue) { + this.hide(); + } + } + } + + toggle() { + if (!this.visible) { + this.show(); + } else { + this.hide(); + } + } + + show() { + if (this.visible) return; + + this.visible = true; + if (typeof this.content === "string") { + const factory = this.resolver.resolveComponentFactory(this.PopoverComponent); + if (!this.visible) + return; + + this.popover = this.viewContainerRef.createComponent(factory); + const popover = this.popover.instance as PopoverContentComponent; + popover.popover = this; + popover.content = this.content as string; + if (this.popoverPlacement !== undefined) + popover.placement = this.popoverPlacement; + if (this.popoverAnimation !== undefined) + popover.animation = this.popoverAnimation; + if (this.popoverTitle !== undefined) + popover.title = this.popoverTitle; + if (this.popoverCloseOnClickOutside !== undefined) + popover.closeOnClickOutside = this.popoverCloseOnClickOutside; + if (this.popoverCloseOnMouseOutside !== undefined) + popover.closeOnMouseOutside = this.popoverCloseOnMouseOutside; + + popover.onCloseFromOutside.subscribe(() => this.hide()); + if (this.popoverDismissTimeout > 0) + setTimeout(() => this.hide(), this.popoverDismissTimeout); + } else { + const popover = this.content as PopoverContentComponent; + popover.popover = this; + if (this.popoverPlacement !== undefined) + popover.placement = this.popoverPlacement; + if (this.popoverAnimation !== undefined) + popover.animation = this.popoverAnimation; + if (this.popoverTitle !== undefined) + popover.title = this.popoverTitle; + if (this.popoverCloseOnClickOutside !== undefined) + popover.closeOnClickOutside = this.popoverCloseOnClickOutside; + if (this.popoverCloseOnMouseOutside !== undefined) + popover.closeOnMouseOutside = this.popoverCloseOnMouseOutside; + + popover.onCloseFromOutside.subscribe(() => this.hide()); + if (this.popoverDismissTimeout > 0) + setTimeout(() => this.hide(), this.popoverDismissTimeout); + popover.show(); + } + + this.onShown.emit(this); + } + + hide() { + if (!this.visible) return; + + this.visible = false; + if (this.popover) + this.popover.destroy(); + + if (this.content instanceof PopoverContentComponent) + (this.content as PopoverContentComponent).hideFromPopover(); + + this.onHidden.emit(this); + } + + getElement() { + return this.viewContainerRef.element.nativeElement; + } + +} diff --git a/catalog-ui/src/app/ng2/components/popover/popover.module.ts b/catalog-ui/src/app/ng2/components/popover/popover.module.ts new file mode 100644 index 0000000000..4bd8426ce1 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/popover/popover.module.ts @@ -0,0 +1,27 @@ +/** + * Created by rc2122 on 5/17/2017. + */ +import {NgModule} from "@angular/core"; +import { CommonModule } from '@angular/common'; +import {PopoverComponent} from "./popover.component"; +import {PopoverContentComponent} from "./popover-content.component"; + +@NgModule({ + declarations: [ + PopoverComponent, + PopoverContentComponent + ], + imports: [ + // PopoverComponent, + // PopoverContentComponent + CommonModule + ], + exports: [ + PopoverComponent, + PopoverContentComponent + ], + providers: [] +}) +export class PopoverModule { + +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.html new file mode 100644 index 0000000000..6e7d4e882b --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.html @@ -0,0 +1,24 @@ +<!-- TODO: refactor this to be dynamic --> +<div class="derived-property-row" *ngIf="propertyObj.isDeclared || propertyObj.derivedDataType == derivedPropertyTypes.SIMPLE"> + <div class="table-cell" [ngClass]="{'iltered':propertyObj.name === propertyNameSearchText}"><checkbox [label]="propertyObj.name" [(checked)]="propertyObj.isSelected" [disabled]="propertyObj.isDisabled ||propertyObj.isDeclared" (checkedChange)="checkedChange($event)"></checkbox></div> + + <div class="table-cell simple"> + <input type="text" [(ngModel)]="propertyObj.value" [disabled]="propertyObj.isDisabled || propertyObj.isDeclared" (change)="valueChanged.emit()" /> + </div> +</div> +<div class="derived-property-row" *ngIf="!propertyObj.isDeclared && propertyObj.derivedDataType == derivedPropertyTypes.COMPLEX"> + <div class="table-cell" [ngClass]="{'filtered':propertyObj.name === propertyNameSearchText}"><checkbox [label]="propertyObj.name" [(checked)]="propertyObj.isSelected" [disabled]="propertyObj.isDisabled ||propertyObj.isDeclared" (checkedChange)="checkedChange($event)"></checkbox></div> + <div class="table-cell complex"> + <span class="datatype-text">{{propertyObj.type | contentAfterLastDot }}</span> + <span (click)="expandChildById(propertyObj.propertiesName)" class="expand-icon" [class.expanded]="expanded">V</span> + </div> +</div> +<div class="derived-property-row" *ngIf="!propertyObj.isDeclared && propertyObj.derivedDataType == derivedPropertyTypes.SIMPLELIST ||propertyObj.derivedDataType == derivedPropertyTypes.SIMPLEMAP"> + <div class="table-cell"> + <span [ngClass]="{'filtered':propertyObj.name === propertyNameSearchText}">{{propertyObj.name}}</span> + </div> + <div class="table-cell simple2"> + <div class="sprite-new add-item-icon" (click)="addRows(propertyObj)"></div> + </div> +</div> + diff --git a/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.less b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.less new file mode 100644 index 0000000000..3102c5ceb8 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.less @@ -0,0 +1,35 @@ +.derived-property-row { + display:flex; + flex-direction:row; + position:relative; + border-top: #d2d2d2 solid 1px; + + &:first-child { + border-top:none; + } + .table-cell { + flex: 0 0 50%; + padding:5px; + position:relative; + text-overflow: ellipsis; + white-space: nowrap; + + &:first-child { + border-right:#d2d2d2 solid 1px; + overflow:hidden; + } + span.expand-icon { + position: absolute; + right: 10px; + transition: 200ms transform ease-in-out; + } + span.expand-icon.expanded { + transform: rotate(-180deg); + } + } +} +.filtered { + /deep/ .checkbox-label-content{ + background-color: yellow; + } +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.ts new file mode 100644 index 0000000000..16f069a685 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/derived-property/derived-property.component.ts @@ -0,0 +1,46 @@ +/** + * Created by rc2122 on 4/20/2017. + */ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import { DerivedFEProperty, DerivedPropertyType} from "app/models"; +import {PropertiesService} from "../../../services/properties.service"; + +@Component({ + selector: 'derived-property', + templateUrl: './derived-property.component.html', + styleUrls: ['./derived-property.component.less'] +}) +export class DerivedPropertyComponent { + + derivedPropertyTypes = DerivedPropertyType; //http://stackoverflow.com/questions/35835984/how-to-use-a-typescript-enum-value-in-an-angular2-ngswitch-statement + + @Input() propertyObj: DerivedFEProperty; + @Input() propertyNameSearchText: string; + @Input() expanded: boolean; + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() expandChild: EventEmitter<string> = new EventEmitter<string>(); + @Output() selectProperty: EventEmitter<boolean> = new EventEmitter<boolean>(); + + + constructor ( private propertiesService:PropertiesService){ + } + + + propValueChanged = () => { + this.valueChanged.emit(this.propertyObj); + }; + + expandChildById = (id: string) => { + this.expandChild.emit(id); + } + + checkedChange = (isChecked:boolean) => { + this.selectProperty.emit(isChecked); + } + + addRows = (flatProperty: DerivedFEProperty): void => { + console.log("ADDING A ROW OF TYPE " + flatProperty.type); + console.log(flatProperty); + } + +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html new file mode 100644 index 0000000000..17e4002ae5 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html @@ -0,0 +1,66 @@ +<div class="dynamic-property-row" + [ngClass]="{'selected': selectedPropertyId === property.uniqueId }" + [class.with-top-border]="property.isChildOfListOrMap" + (click)="onClickPropertyRow(property, $event)"> + <!-- LEFT CELL - for all NON-PropFEModel properties except for MAP)--> + <ng-container *ngIf="!isPropertyFEModel"> + <div class="table-cell" *ngIf="canBeDeclared"> <!-- simple children of complex type --> + <checkbox [label]="property.name" [(checked)]="property.isSelected" [disabled]="property.isDisabled ||property.isDeclared" (checkedChange)="checkProperty.emit(property.propertiesName)" + ></checkbox> + </div> + <div class="table-cell" *ngIf="!canBeDeclared && !property.isChildOfListOrMap">{{property.name}}</div> <!-- simple children of complex type within map or list --> + </ng-container> + <!-- RIGHT CELL --> + <ng-container *ngIf="propType == derivedPropertyTypes.SIMPLE || property.isDeclared"> + <div class="table-cell" [class.full-width]="isPropertyFEModel || property.isChildOfListOrMap"> + <dynamic-element class="value-input" + pattern="validationUtils.getValidationPattern(property.type)" + [(value)]="property.value" + [type]="property.type" + [name]="property.name" + (valueChange)="propValueChanged(property);" + > <!--[disabled]="property.isDisabled || property.isDeclared" --> + </dynamic-element> + </div> + </ng-container> + <ng-container *ngIf="!property.isDeclared"> <!-- other cases need to fail if isDeclared, in which case we need to use full width value above instead) --> + + <ng-container *ngIf="propType == derivedPropertyTypes.COMPLEX && !isPropertyFEModel"> + <div class="table-cell complex" [class.full-width]="property.isChildOfListOrMap"> + <span>{{property.type | contentAfterLastDot }}</span> + </div> + </ng-container> + <ng-container *ngIf="property.isChildOfListOrMap && propType == derivedPropertyTypes.MAP"> + <div class="table-cell map-entry"><input type="text" /></div> + <div class="table-cell" *ngIf="property.schema.property.isSimpleType"> + <input type="text" [(ngModel)]="property.value" /></div> + <div class="table-cell" *ngIf="!property.schema.property.isSimpleType"> + <span>{{property.schema.property.type | contentAfterLastDot }}</span> + </div> + </ng-container> + + <!-- ICONS: add, delete, and expand --> + <div *ngIf="(propType == derivedPropertyTypes.LIST || propType == derivedPropertyTypes.MAP) && !property.isChildOfListOrMap" class="table-cell"><span class="sprite-new add-item-icon" (click)="addRows()"></span></div> + <span *ngIf="property.isChildOfListOrMap" class="delete-span sprite-new delete-item-icon" (click)="deleteItem.emit(property.propertiesName)"></span> + <span *ngIf="propType == derivedPropertyTypes.COMPLEX || (property.isChildOfListOrMap && propChildren)" (click)="expandChildById(propPath)" class="expand-icon" [class.expanded]="propPath == expandedChildId">V</span> + </ng-container> + +</div> +<!-- Now, recurse into children --> +<ng-container *ngIf="propChildren && !property.isDeclared"> + <ng-container *ngFor="let prop of propChildren | filterChildProperties: expandedChildId; trackBy:prop?.propertiesName"> + <dynamic-property + [selectedPropertyId]="selectedPropertyId" + [canBeDeclared]="childrenCanBeDeclared" + [property]="prop" + [expandedChildId]="expandedChildId" + [propChildren]="" + (valueChanged)="propValueChanged(prop);" + (expandChild)="expandChildById($event)" + (deleteItem)="deleteListOrMapItem($event)" + (clickOnPropertyRow)="onClickPropertyRow($event)" + (checkProperty)="checkedChange($event)" + > + </dynamic-property> + </ng-container> +</ng-container> diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less new file mode 100644 index 0000000000..53cde3035a --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less @@ -0,0 +1,48 @@ +.dynamic-property-row { + display:flex; + flex-direction:row; + position:relative; + + .table-cell { + flex: 1 0 50%; + padding:5px; + position:relative; + text-overflow: ellipsis; + white-space: nowrap; + + + &.full-width { + border-right:none; + flex: 0 0 100%; + } + + &:first-child:not(:only-child) { + border-right:#d2d2d2 solid 1px; + overflow:hidden; + } + + + } + span.delete-item-icon{ + position: absolute; + right: 25px; + top: 10px; + } + span.add-item-icon { + float:right; + } + span.expand-icon { + position: absolute; + top:6px; + right: 10px; + transition: 200ms transform ease-in-out; + } + span.expand-icon.expanded { + transform: rotate(-180deg); + } +} +.filtered { + /deep/ .checkbox-label-content{ + background-color: yellow; + } +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts new file mode 100644 index 0000000000..0ca93a773f --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts @@ -0,0 +1,149 @@ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import { PropertyBEModel, PropertyFEModel, DerivedFEProperty, DerivedPropertyType, SchemaPropertyGroupModel, DataTypeModel } from "app/models"; +import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils'; +import { PropertiesUtils } from "app/ng2/pages/properties-assignment/properties.utils"; +import { DataTypeService } from "../../../services/data-type.service"; +import { UUID } from "angular2-uuid"; + + +@Component({ + selector: 'dynamic-property', + templateUrl: './dynamic-property.component.html', + styleUrls: ['./dynamic-property.component.less'] +}) +export class DynamicPropertyComponent { + + derivedPropertyTypes = DerivedPropertyType; //http://stackoverflow.com/questions/35835984/how-to-use-a-typescript-enum-value-in-an-angular2-ngswitch-statement + propType: DerivedPropertyType; + propPath: string; + isPropertyFEModel: boolean; + mapOfIDsAndKeys: Map<string, string> = new Map(); //used for map and list + + childrenCanBeDeclared: boolean; + @Input() canBeDeclared: boolean; + @Input() property: PropertyFEModel | DerivedFEProperty; + @Input() propChildren: Array<DerivedFEProperty>; + @Input() expandedChildId: string; + @Input() selectedPropertyId: string; + + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() expandChild: EventEmitter<string> = new EventEmitter<string>(); + @Output() checkProperty: EventEmitter<string> = new EventEmitter<string>(); + @Output() deleteItem: EventEmitter<string> = new EventEmitter<string>(); + @Output() clickOnPropertyRow: EventEmitter<PropertyFEModel | DerivedFEProperty> = new EventEmitter<PropertyFEModel | DerivedFEProperty>(); + + constructor(private propertiesUtils: PropertiesUtils, private dataTypeService: DataTypeService) { + } + + ngOnInit() { + this.isPropertyFEModel = this.property instanceof PropertyFEModel; + if (this.property instanceof PropertyFEModel) { + this.propType = this.getDerivedPropertyType(this.property.type); + this.propPath = this.property.name; + } else { + this.propType = this.property.derivedDataType; + this.propPath = this.property.propertiesName; + } + + this.childrenCanBeDeclared = this.canBeDeclared && this.propType != this.derivedPropertyTypes.MAP && this.propType != this.derivedPropertyTypes.LIST; + + if (this.propType == this.derivedPropertyTypes.LIST || this.propType == this.derivedPropertyTypes.MAP) { + this.initializeValues(); + } + + } + + initializeValues = () => { + let tempValue: any; + if (this.property.value) { + tempValue = JSON.parse(this.property.value); + if (!_.isEmpty(tempValue)) { + tempValue.forEach((element, key) => { + let newChildID: string = this.createNewChildProperty(JSON.stringify(element)); + this.mapOfIDsAndKeys[newChildID] = key; + console.log(this.mapOfIDsAndKeys); + }); + } + } + //this.pseudoChildren = []; + //this.valueObjRef = []; + //TODO: generate necessary elements for existing values here + // if (this.propType == this.derivedPropertyTypes.LIST) { + // this.valueObjRef = (this.property.value) ? JSON.parse(this.property.value) : []; + // } else if (this.propType == this.derivedPropertyTypes.MAP) { + // this.valueObjRef = (this.property.value)? JSON.parse(this.property.value) : {}; + // } + console.log(this.property.value); + } + + onClickPropertyRow = (property, event) => { + // Because DynamicPropertyComponent is recrusive second time the event is fire event.stopPropagation = undefined + event && event.stopPropagation && event.stopPropagation(); + this.clickOnPropertyRow.emit(property); + } + + deleteListOrMapItem = (itemName: string) => { + this.propChildren = this.propChildren.filter(prop => prop.propertiesName.indexOf(itemName) != 0); //remove item and children; + } + + propValueChanged = (property) => { + console.log("property value change!! Prop type: " + property.type + " New value: " + property.value); + this.valueChanged.emit(property); + }; + + expandChildById = (id: string) => { + this.expandedChildId = id; + this.expandChild.emit(id); + } + + checkedChange = (propName: string) => { + this.checkProperty.emit(propName); + } + + + + addRows = (): void => { //from within the template, when creating empty item + let childPropId = this.createNewChildProperty(); + this.expandChildById(this.propPath + "#" + childPropId); + } + + createNewChildProperty = (value?:string):string => { + let propUUID:string = UUID.UUID(); + let newProp: DerivedFEProperty; + if (this.propType == this.derivedPropertyTypes.LIST) { //for list - create new prop of schema type + newProp = new DerivedFEProperty(propUUID, this.propPath, this.property.schema.property.type, value, true); + } else { //for map - create new prop of type map, with schema, but with flag that its a child + newProp = new DerivedFEProperty(propUUID, this.propPath, this.property.type, value, true, this.property.schema); + } + + + this.propChildren = this.propChildren || []; + this.propChildren.push(newProp); + + //if it's a complex type, add children properties + if (!this.property.schema.property.isSimpleType) { + let schemaDataType: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(this.property.schema.property.type); + this.dataTypeService.getDerivedDataTypeProperties(schemaDataType, this.propChildren, newProp.propertiesName); + this.propertiesUtils.assignValuesRecursively(JSON.parse(value), this.propChildren, newProp.propertiesName); + console.log(JSON.stringify(this.propChildren)); + } + + return propUUID; + } + + + + //TODO: remove this and move to somewhere central!! (or make all properties be the same type...) + getDerivedPropertyType = (type) => { + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(type) > -1) { + return DerivedPropertyType.SIMPLE; + } else if (type == PROPERTY_TYPES.LIST) { + return DerivedPropertyType.LIST; + } else if (type == PROPERTY_TYPES.MAP) { + return DerivedPropertyType.MAP; + } else { + return DerivedPropertyType.COMPLEX; + } + } + +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.html new file mode 100644 index 0000000000..a251d33649 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.html @@ -0,0 +1,33 @@ +<div class="add-data-row"> + <div class="sprite-new add-item-icon" (click)="addListItem()"></div> +</div> +<div *ngIf="property.schema.property.isSimpleType && property.valueObjectRef && property.valueObjectRef.length"> + <!--the ngFor runs on dummy array in the list array length and not on list array in order to prevent from page do the ngFor again when user changes an item--> + <div class="simple-list-item" *ngFor="let item of getNumber(property.valueObjectRef); let i = index"> + <input class="value-input" [(ngModel)]="property.valueObjectRef[i]" + type="property.schema.property.derivedFromSimpleTypeName || property.schema.property.type" + (change)="propValueChanged()"/> + <span class="delete-span sprite-new delete-item-icon" (click)="deleteListItem(i)"></span> + </div> +</div> +<div class="test" *ngIf="property.schema.property.isDataType && property.childrenProperties && property.childrenProperties.length"> + <template ngFor let-item [ngForOf]="property.childrenProperties" let-i="index"> + <div class="table-inner-row" (click)="onChildPropertySelected(item)" [ngClass]="{'selected': selectedPropertyId === item.treeNodeId}"> + <div class="table-cell">{{item.name}}</div> + <div class="table-cell"> + <span class="delete-span sprite-new delete-item-icon" (click)="deleteListItem(i)"></span> + <span (click)="property.updateExpandedChildPropertyId(item.treeNodeId)">V</span> + </div> + </div> + <div class="table-inner-row" *ngIf="property.expandedChildPropertyId == item.treeNodeId"> + <div class="inner-table-container"> + <properties-value-inner-table [property]="item" + (selectChildProperty)="onChildPropertySelected($event)" + [selectedPropertyId]="selectedPropertyId" + [propertyNameSearchText]="propertyNameSearchText" + (valueChanged)="propValueChanged()"></properties-value-inner-table> + </div> + </div> + </template> + +</div> diff --git a/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.less b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.less new file mode 100644 index 0000000000..7c4d90a38d --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.less @@ -0,0 +1,3 @@ +.simple-list-item{ + position: relative; +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.ts new file mode 100644 index 0000000000..96f8c680a2 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/list-property/list-property.component.ts @@ -0,0 +1,85 @@ +/** + * Created by rc2122 on 4/23/2017. + */ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import { PropertyFEModel} from "app/models"; +import {PropertiesService} from "app/ng2/services/properties.service"; +import { ContentAfterLastDotPipe } from "app/ng2/pipes/contentAfterLastDot.pipe"; +import {UUID} from "angular2-uuid"; +import {ComponentType} from "app/utils"; + +@Component({ + selector: 'list-property', + templateUrl: './list-property.component.html', + styleUrls: ['../properties-value-inner-table/properties-value-inner-table.component.less', './list-property.component.less'] +}) +export class ListPropertyComponent { + + @Input() property: PropertyFEModel; + @Input() selectedPropertyId: string; + @Input() propertyNameSearchText:string; + + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() selectChildProperty: EventEmitter<any> = new EventEmitter<PropertyFEModel>(); + + constructor ( private propertiesService:PropertiesService, private contentAfterLastDotPipe:ContentAfterLastDotPipe ){ + } + + propValueChanged = () => { + this.valueChanged.emit(this.property); + }; + + onChildPropertySelected = (property) => { + this.selectChildProperty.emit(property); + }; + + getNumber = (valueObjectRef: any): Array<any> => { + let num: number = (valueObjectRef) ? valueObjectRef.length : 0; + return new Array(num); + } + + createNewChildProperty = ():void => { + let newProperty: PropertyFEModel = new PropertyFEModel(this.contentAfterLastDotPipe.transform(this.property.schema.property.type), + this.property.schema.property.type, + UUID.UUID(), + this.property, + this.property.valueObjectRef[this.property.childrenProperties.length] + ); + this.propertiesService.createPropertiesTreeForProp(newProperty); + this.property.childrenProperties.push(newProperty); + } + + addListItem = ():void => { + this.property.valueObjectRef = this.property.valueObjectRef || []; + this.property.childrenProperties = this.property.childrenProperties || []; + if (this.property.schema.property.isSimpleType){ + if( this.property.valueObjectRef.indexOf("") == -1 ) {//prevent insert multiple empty simple type items to list + this.property.valueObjectRef.push(""); + } + }else{ + this.property.valueObjectRef[this.property.childrenProperties.length] = {}; + this.property.childrenProperties = this.property.childrenProperties || []; + this.createNewChildProperty(); + this.valueChanged.emit(this.property); + } + } + + deleteListItem = (indexInList:number):void => { + this.property.valueObjectRef.splice(indexInList, 1); + if(this.property.childrenProperties){ + this.property.childrenProperties.splice(indexInList, 1); + } + if (!this.property.valueObjectRef.length) {//only when user removes all items from list - put the default + if ( this.property.defaultValue ) { + angular.copy(JSON.parse(this.property.defaultValue), this.property.valueObjectRef); + if (this.property.schema.property.isDataType){ + _.forEach(this.property.valueObjectRef, () => { + this.createNewChildProperty(); + }); + } + } + } + this.valueChanged.emit(this.property); + } + +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.html new file mode 100644 index 0000000000..e1975175a8 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.html @@ -0,0 +1,38 @@ +<div class="add-data-row"> + <div class="sprite-new add-item-icon" (click)="addMapItemFields()"></div> +</div> + +<!--the ngFor runs on dummy array in mapKey array length and not on maKeys array in order to prevent from page do the ngFor again when user changes a key--> +<template ngFor let-num [ngForOf]="getNumber(mapKeys.length)" let-i="index"> + <div class="table-inner-row" + [ngClass]="{'selected': property.schema.property.isDataType && selectedPropertyId === property.childrenProperties[i].treeNodeId}" + (click)="property.schema.property.isDataType && onChildPropertySelected(property.childrenProperties[i])"> + <div class="table-cell"> + <input class="value-input" (keyup)="changeKeyOfMap(mapKeys[i], i);$event.stopPropagation();" + [(ngModel)]="mapKeys[i]" + name="mapKey{{property.treeNodeId}}{{i}}" + (change)="propValueChanged()"/> + </div> + <div class="table-cell"> + <input class="value-input" *ngIf="property.schema.property.isSimpleType" + [(ngModel)]="property.valueObjectRef[mapKeys[i]]" + type="property.schema.property.derivedFromSimpleTypeName || property.schema.property.type" + (change)="propValueChanged()"/> + <div *ngIf="property.schema.property.isDataType"> + <div>{{ property.schema.property.type | contentAfterLastDot }}</div> + <span (click)="property.updateExpandedChildPropertyId(property.childrenProperties[i].treeNodeId)">V</span> + </div> + <span class="delete-span sprite-new delete-item-icon" (click)="deleteMapItem(i)"></span> + </div> + </div> + <div class="table-inner-row" *ngIf="property.schema.property.isDataType && property.expandedChildPropertyId == property.childrenProperties[i].treeNodeId"> + <div class="inner-table-container"> + <properties-value-inner-table [property]="property.childrenProperties[i]" + [selectedPropertyId]="selectedPropertyId" + [propertyNameSearchText]="propertyNameSearchText" + (selectChildProperty)="onChildPropertySelected($event)" + (valueChanged)="propValueChanged()"></properties-value-inner-table> + </div> + </div> +</template> + diff --git a/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.ts new file mode 100644 index 0000000000..d62d0b94e3 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/map-property/map-property.component.ts @@ -0,0 +1,121 @@ +/** + * Created by rc2122 on 4/24/2017. + */ +/** + * Created by rc2122 on 4/23/2017. + */ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import { PropertyFEModel} from "app/models"; +import { PropertiesService } from "../../../services/properties.service"; +import {ComponentType} from "app/utils"; +import {UUID} from "angular2-uuid"; + +@Component({ + selector: 'map-property', + templateUrl: './map-property.component.html', + styleUrls: ['../properties-value-inner-table/properties-value-inner-table.component.less'] +}) +export class MapPropertyComponent { + + @Input() property: PropertyFEModel; + @Input() selectedPropertyId: string; + @Input() propertyNameSearchText:string; + + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() selectChildProperty: EventEmitter<any> = new EventEmitter<PropertyFEModel>(); + + constructor ( private propertiesService:PropertiesService){ + } + + mapKeys:Array<string>; + + ngOnInit() { + this.mapKeys = Object.keys(this.property.valueObjectRef); + } + + propValueChanged = () => { + this.valueChanged.emit(this.property); + }; + + onChildPropertySelected = (property) => { + this.selectChildProperty.emit(property); + }; + + getNumber = (num:number):Array<any> => { + return new Array(num); + } + + createNewChildProperty = (mapKey:string):void => { + + let newProperty: PropertyFEModel = new PropertyFEModel(mapKey, + this.property.schema.property.type, + UUID.UUID(), this.property, + this.property.valueObjectRef[mapKey]); + this.propertiesService.createPropertiesTreeForProp(newProperty); + this.property.childrenProperties = this.property.childrenProperties || []; + this.property.childrenProperties.push(newProperty); + } + + //get: new key and the index of this item in the map + //This method checks if the new key isn't exist already in the map and update the object and the children array with the new key + changeKeyOfMap = (newKey:string, index:number):void => { + //let fieldName:string = "mapKey" + this.property.treeNodeId + index; + let oldKey:string = Object.keys(this.property.valueObjectRef)[index]; + let existsKeyIndex:number = Object.keys(this.property.valueObjectRef).indexOf(newKey); + if (existsKeyIndex > -1 && existsKeyIndex != index) { + //error for exists key validation + } else { + //remove error for exists key validation and if the form is valid - update the map object + let newObj = {}; + angular.forEach(this.property.valueObjectRef,function(value:any,key:string){ + if(key == oldKey){ + newObj[newKey] = value; + }else{ + newObj[key] = value; + } + }); + this.property.valueObjectRef = newObj; + this.property.parent.valueObjectRef[this.property.name] = this.property.valueObjectRef;//in order to prevent break ref + if(this.property.childrenProperties){ + this.property.childrenProperties[index].name = newKey;//update this property childrenProperties with the new key + } + } + } + + //get: index of the item in the map + //This method removes item from map. + deleteMapItem = (index:number):void=> { + delete this.property.valueObjectRef[this.mapKeys[index]]; + this.mapKeys.splice(index, 1); + if(this.property.childrenProperties){ + this.property.childrenProperties.splice(index, 1); + } + if (!this.mapKeys.length) {//only when user removes all pairs of key-value fields - put the default + if (this.property.defaultValue) { + angular.copy(JSON.parse(this.property.defaultValue), this.property.valueObjectRef); + this.mapKeys = Object.keys(this.property.valueObjectRef); + if (this.property.schema.property.isDataType){ + angular.forEach(this.property.valueObjectRef, (value, key) => { + this.createNewChildProperty(key); + }, this); + } + } + } + this.valueChanged.emit(this.property); + } + + //This method inserts new empty item to map + addMapItemFields = ():void => { + this.property.valueObjectRef = this.property.valueObjectRef || {}; + if (this.property.schema.property.isSimpleType){ + this.property.valueObjectRef[''] = null; + }else{ + if(!this.property.valueObjectRef['']){ + this.property.valueObjectRef[''] = {}; + this.createNewChildProperty(''); + } + } + this.mapKeys = Object.keys(this.property.valueObjectRef); + } +} + diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html new file mode 100644 index 0000000000..3ab47074e7 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.html @@ -0,0 +1,135 @@ + + +<div class="properties-table"> + <div class="table-header"> + <div class="table-cell col1">Property Name</div> + <div class="table-cell col2">Type</div> + <div class="table-cell col3">ES</div> + <div class="table-cell valueCol">Value</div> + </div> + <div class="table-body"> + <div class="no-data" *ngIf="!feInstancesNames">No data to display</div> + + <div *ngFor="let instanceName of feInstancesNames; trackBy:instanceName"> + <div class="table-rows-header">{{instanceName | contentAfterLastDot}}</div> + + <div class="table-row" *ngFor="let property of fePropertiesMap[instanceName]; trackBy:property?.name" (click)="onClickPropertyRow(property, instanceName, $event)" [ngClass]="{'selected': selectedPropertyId === property.uniqueId}"> + <div class="table-cell col1"> + <checkbox [label]="property.name" + [(checked)]="property.isSelected" + [disabled]="property.isDisabled || property.isDeclared" + (checkedChange)="propertyChecked(property)" + tooltip="{{property.name}}"></checkbox> + <span *ngIf="property.description" class="property-description-icon sprite-new show-desc" tooltip="{{property.description}}"></span> + </div> + <div class="table-cell col2">{{property.type | contentAfterLastDot}}</div> + <div class="table-cell col3">{{property.schema && property.schema.property && property.schema.property.type ? (property.schema.property.type + | contentAfterLastDot) : ''}}</div> + <div class="table-cell valueCol"> + <!-- [ngClass]="{'filtered':property.name === propertyNameSearchText}" (selectProperty)="propertySelected(property, $event, flatProperty.propertiesName)" [propType]="property.type" [propSchema]="property.schema" [propKey]="" [propValue]="property.value"--> + <dynamic-property + [selectedPropertyId]="selectedPropertyId" + [canBeDeclared]="true" + [property]="property" + [expandedChildId]="property.expandedChildPropertyId" + [propChildren]="property.flattenedChildren | filterChildProperties : property.expandedChildPropertyId" + (valueChanged)="propValueChanged(property);" + (expandChild)="property.updateExpandedChildPropertyId($event)" + (clickOnPropertyRow)="onClickPropertyInnerRow($event, instanceName)" + (checkProperty)="propertyChecked(property, $event)" + > + </dynamic-property> + + </div> + </div> +<!-- + <div *ngIf="!property.isSimpleType && !property.isDeclared" class="table-cell valueCol child-property-container"> + + <div class="child-property-row" *ngFor="let flatProperty of property.flattenedChildren | filterChildProperties : property.expandedChildPropertyId" + [ngClass]="{'selected': selectedPropertyId === flatProperty.uniqueId}" (click)="clickOnPropertyRow(flatProperty, instanceName, $event)" [@fadeIn]="''"> + <derived-property [propertyObj]="flatProperty" [propertyNameSearchText]="propertyNameSearchText" [expanded]="flatProperty.propertiesName == property.expandedChildPropertyId" + (selectProperty)="propertySelected(property, $event, flatProperty.propertiesName)" (valueChanged)="propValueChanged(property)" (expandChild)="property.updateExpandedChildPropertyId($event)"></derived-property> + </div> + + </div> + <!-- + + + <property [propertyObj]="flatProperty" + [expanded]="flatProperty.parentName == property.expandedChildPropertyId" + (valueChanged)="propValueChanged($event)" + (selectChildProperty)="onChildPropertySelected($event)"></property> + <list-property *ngIf="property.type == 'list'" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (valueChanged)="propValueChanged($event)" + (selectChildProperty)="onChildPropertySelected($event)"></list-property> + <map-property *ngIf="property.type == 'map'" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (valueChanged)="propValueChanged($event)" + (selectChildProperty)="onChildPropertySelected($event)"></map-property> + <properties-value-inner-table *ngIf="property.isDataType" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (selectChildProperty)="onChildPropertySelected($event)" + (valueChanged)="propValueChanged($event)"></properties-value-inner-table> + --> + + + + </div> + + </div> +</div> +<!-- +<div class="properties-table" style="display:block"> + <div class="table-header"> + <div class="table-cell col1">Property Name</div> + <div class="table-cell col2">Type</div> + <div class="table-cell col3">ES</div> + <div class="table-cell valueCol">Value</div> + </div> + <div class="table-body"> + <div class="no-data" *ngIf="!properties || !properties.length">No data to display</div> + <div class="table-row" *ngFor="let property of properties" (click)="clickOnPropertyRow(property)"> + <div class="table-cell col1"><checkbox [label]="property.name" [(checked)]="property.isSelected" (checkedChange)="propSelected(property)" [disabled]="property.isDisabled"></checkbox></div> + <div class="table-cell col2">{{property.type | contentAfterLastDot}}</div> + <div class="table-cell col3">{{property.schema && property.schema.property && property.schema.property.type ? (property.schema.property.type | contentAfterLastDot) : ''}}</div> + <div class="table-cell valueCol" [class.inner-table-container]="property.childrenProperties || !property.isSimpleType"> + <!--<input class="value-input" *ngIf="property.isSimpleType" + type="property.derivedFromSimpleTypeName || property.type" + [(ngModel)]="property.value" + (change)="putDefaultValueInEmptyProperty(property);propValueChanged(property);" + pattern="validationUtils.getValidationPattern(property.type)"/> + <dynamic-element + class="value-input" + *ngIf="property.isSimpleType" + [(value)]="property.value" + (valueChange)="putDefaultValueInEmptyProperty(property);propValueChanged(property);" + [type]="property.derivedFromSimpleTypeName || property.type" + [name]="property.name"> + </dynamic-element> + <list-property *ngIf="property.type == 'list'" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (valueChanged)="propValueChanged($event)" + (selectChildProperty)="onChildPropertySelected($event)"></list-property> + <map-property *ngIf="property.type == 'map'" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (valueChanged)="propValueChanged($event)" + (selectChildProperty)="onChildPropertySelected($event)"></map-property> + <properties-value-inner-table *ngIf="property.isDataType" + [property]="property" + [selectedPropertyId]="selectedPropertyId" + (selectChildProperty)="onChildPropertySelected($event)" + (valueChanged)="propValueChanged($event)"></properties-value-inner-table> + </div> + + </div> + </div> +</div> --> + + + diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.less b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.less new file mode 100644 index 0000000000..de080dfdc9 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.less @@ -0,0 +1,188 @@ + +@import './../../../../assets/styles/variables.less'; + +:host /deep/ input { width:100%;} + +.properties-table { + display:flex; + flex-direction:column; + flex: 1; + height:100%; + text-align:left; + + + .child-property-container { + display:flex; + flex-direction:column; + + &.table-cell { + padding:0; + } + + .child-property-row { + border-bottom: #d2d2d2 solid 1px; + &:last-child { + border-bottom:none; + } + } + } + + + derived-property, dynamic-property { + width:100%; + } + + /deep/ dynamic-property dynamic-property .dynamic-property-row { + border-top:solid #d2d2d2 1px; + } + + /deep/ dynamic-property dynamic-property:first-of-type .dynamic-property-row:not(.with-top-border) { + border-top: none; + } + + properties-value-inner-table { + width: 100%; + } + + .table-header { + font-weight:bold; + border-top: #d2d2d2 solid 1px; + background-color: #eaeaea; + + .valueCol { + justify-content: flex-start; + padding: 5px; + } + } + .table-header, .table-row { + display: flex; + flex-direction:row; + flex: 0 0 auto; + } + + .table-body { + display:flex; + flex-direction: column; + overflow-y:auto; + flex: 1; + + .no-data { + border: #d2d2d2 solid 1px; + border-top:none; + text-align: center; + height: 100%; + padding: 20px; + } + /deep/.selected{ + background-color: #e6f6fb; + color: #009fdb; + } + } + + .table-rows-header { + font-size:16px; + flex:1; + border: #d2d2d2 solid 1px; + border-top:none; + padding: 5px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + background-color: @tlv_color_v; + } + + .table-row { + &:hover { + background-color:#f8f8f8; cursor:pointer; + } + + &:last-child { + flex: 1 0 auto; + } + .selected-row { + background-color:#e6f6fb; + } + } + .table-cell { + font-size:13px; + flex:1; + border: #d2d2d2 solid 1px; + border-right:none; + border-top:none; + padding: 5px; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + + &:last-child { + border-right:#d2d2d2 solid 1px; + } + &.col1 { + flex: 0 0 300px; + max-width:300px; + + .property-description-icon { + float: right; + margin-top: 4px; + } + } + &.col2 { + flex: 0 0 150px; + max-width:150px; + } + + &.col3 { + flex:0 0 120px; + max-width:120px; + } + + &.valueCol { + flex: 1 0 auto; + min-width: 350px; + display: flex; + justify-content: flex-end; + padding: 0px; + + .value-input { + flex: 1; + max-height: 24px; + border: none; + background-color: inherit; + + &:focus, &:active { + border:none; + outline:none; + } + } + + .delete-btn { + flex: 0 0 auto; + } + + .delete-button-container { + max-height: 24px; + } + + &.inner-table-container { + padding: 0px; + + .delete-button-container { + padding: 3px 5px 0 0 ; + } + } + } + + &.input-value-col { + padding: 5px; + } + + + } + + .filtered { + /deep/ .checkbox-label-content{ + background-color: yellow; + } + } + +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.ts b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.ts new file mode 100644 index 0000000000..d5a9b40425 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-table.component.ts @@ -0,0 +1,93 @@ +import { Component, Input, Output, EventEmitter, SimpleChanges, ViewChild, ElementRef } from "@angular/core"; +import { trigger, state, style, transition, animate} from '@angular/core'; +import {PropertyFEModel, DerivedFEProperty, DerivedPropertyType, InstanceFePropertiesMap} from "app/models"; +import {PropertiesService} from "../../services/properties.service"; +// import { GroupByPipe } from 'app/ng2/pipes/groupBy.pipe'; +//import {PropertiesValueInnerTableComponent} from "./properties-table/properties-value-inner-table/properties-value-inner-table"; +import { DynamicElementComponent } from 'app/ng2/components/dynamic-element/dynamic-element.component'; +import { KeysPipe } from 'app/ng2/pipes/keys.pipe'; + +@Component({ + selector: 'properties-table', + templateUrl: './properties-table.component.html', + styleUrls: ['./properties-table.component.less'], + animations: [trigger('fadeIn', [transition(':enter', [style({ opacity: '0' }), animate('.3s ease-out', style({ opacity: '1' }))]) ])] +}) +export class PropertiesTableComponent { + + @Input() fePropertiesMap: InstanceFePropertiesMap; + @Input() selectedPropertyId: string; + @Input() displayDeleteButton: boolean; + @Input() propertyNameSearchText:string; + + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + @Output() selectPropertyRow: EventEmitter<PropertyRowSelectedEvent> = new EventEmitter<PropertyRowSelectedEvent>(); + @Output() updateCheckedPropertyCount: EventEmitter<boolean> = new EventEmitter<boolean>(); + //@Output() selectInstanceRow: EventEmitter<string> = new EventEmitter<string>(); + + feInstancesNames: Array<string>; + + constructor ( private propertiesService:PropertiesService ){ + } + + /** + * Update feInstancesNames when fePropertiesMap: InstanceFePropertiesMap change (after getting response from server) + */ + ngOnChanges(changes: SimpleChanges) { + if (changes['fePropertiesMap']) { + if (changes['fePropertiesMap'].currentValue) { + let keysPipe = new KeysPipe(); + let fiteredArr = keysPipe.transform(changes['fePropertiesMap'].currentValue,[]); + this.feInstancesNames = fiteredArr; + } + } + } + + propValueChanged = (property) => { + !property.isDeclared && this.valueChanged.emit(property); + }; + + // Click on main row (row of propertyFEModel) + onClickPropertyRow = (property:PropertyFEModel, instanceName:string, event?) => { + //event && event.stopPropagation(); + let propertyRowSelectedEvent:PropertyRowSelectedEvent = new PropertyRowSelectedEvent(property, instanceName); + this.selectPropertyRow.emit(propertyRowSelectedEvent); + }; + + // Click on inner row (row of DerivedFEProperty) + onClickPropertyInnerRow = (property:DerivedFEProperty, instanceName:string) => { + let propertyRowSelectedEvent:PropertyRowSelectedEvent = new PropertyRowSelectedEvent(property, instanceName); + this.selectPropertyRow.emit(propertyRowSelectedEvent); + } + + propertyChecked = (prop: PropertyFEModel, childPropName?: string) => { + let isChecked: boolean = (!childPropName)? prop.isSelected : prop.flattenedChildren.find(prop => prop.propertiesName == childPropName).isSelected; + + console.log(isChecked, childPropName, prop); + if (!isChecked) { + this.propertiesService.undoDisableRelatedProperties(prop, childPropName); + } else { + this.propertiesService.disableRelatedProperties(prop, childPropName); + } + this.updateCheckedPropertyCount.emit(isChecked); + } + + putDefaultValueInEmptyProperty = (property:PropertyFEModel):void => { + property.value = property.value || property.defaultValue; + } + + // clickOnInstanceRow = (instanceName:string) =>{ + // this.selectInstanceRow.emit(instanceName); + // }; + +} + +export class PropertyRowSelectedEvent { + propertyModel:PropertyFEModel | DerivedFEProperty; + instanceName:string; + constructor ( propertyModel:PropertyFEModel | DerivedFEProperty, instanceName:string ){ + this.propertyModel = propertyModel; + this.instanceName = instanceName; + } +} + diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.html b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.html new file mode 100644 index 0000000000..61555cac50 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.html @@ -0,0 +1,41 @@ + +<template ngFor let-childProp [ngForOf]="property.childrenProperties" let-i="index"> + <div class="table-inner-row" (click)="onChildPropertySelected(childProp)" [ngClass]="{'selected': selectedPropertyId === childProp.treeNodeId}"> + <div class="table-cell" [ngClass]="{'filtered':childProp.name === propertyNameSearchText}"> + <checkbox [label]="childProp.name" [(checked)]="childProp.isSelected" [disabled]="property.isDisabled"></checkbox> + </div> + <div class="table-cell prop-value"> + <input class="value-input" *ngIf="childProp.isSimpleType" + [(ngModel)]="property.valueObjectRef[childProp.name]" + (change)="putDefaultValueInEmptyChildProperty(childProp);propValueChanged();" + type="childProp.derivedFromSimpleTypeName || childProp.type"/> + <span class="datatype-text" *ngIf="childProp.isDataType">{{ childProp.type | contentAfterLastDot }}</span> + <span *ngIf="!childProp.isSimpleType" (click)="property.updateExpandedChildPropertyId(childProp.treeNodeId)">V</span> + </div> + </div> + <div class="table-inner-row" *ngIf="childProp.type === 'list' && property.expandedChildPropertyId === childProp.treeNodeId"> + <list-property [property]="childProp" + [selectedPropertyId]="selectedPropertyId" + [propertyNameSearchText]="propertyNameSearchText" + (valueChanged)="propValueChanged()" + (selectChildProperty)="onChildPropertySelected($event)"></list-property> + + </div> + <div class="table-inner-row" *ngIf="childProp.type === 'map' && property.expandedChildPropertyId == childProp.treeNodeId"> + <map-property [property]="childProp" + [selectedPropertyId]="selectedPropertyId" + [propertyNameSearchText]="propertyNameSearchText" + (valueChanged)="propValueChanged()" + (selectChildProperty)="onChildPropertySelected($event)"></map-property> + + </div> + <div class="table-inner-row" *ngIf="childProp.isDataType && property.expandedChildPropertyId == childProp.treeNodeId"> + <properties-value-inner-table [property]="childProp" + [selectedPropertyId]="selectedPropertyId" + [propertyNameSearchText]="propertyNameSearchText" + (selectChildProperty)="onChildPropertySelected($event)" + (valueChanged)="propValueChanged()"></properties-value-inner-table> + </div> +</template> + + diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.less b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.less new file mode 100644 index 0000000000..1b7f6d4cd1 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.less @@ -0,0 +1,71 @@ +table { width:100%;} +tr {border-bottom: #d2d2d2 solid 1px;} +tr:last-child { border-bottom:none;} +td { border:none; padding:5px;} +td:first-child { border-right:#d2d2d2 solid 1px;} + +.prop-value{ + span { + position: absolute; + top: 5px; + right: 2px; + + &.delete-span { + right:20px; + } + + &.datatype-text { + position:static; + } + + } +} + +.add-data-row { + padding:5px; + text-align:right; + border-bottom: #d2d2d2 solid 1px; + + &:last-child { + border-bottom:none; + } +} +.table-inner-row { + display:flex; + flex-direction:row; + border-bottom: #d2d2d2 solid 1px; + flex: 0 0 100%; + position:relative; + + &:last-child { + border-bottom:none; + } + + .table-cell { + flex: 0 0 50%; + padding:5px; + position:relative; + text-overflow: ellipsis; + white-space: nowrap; + + &:first-child { + border-right:#d2d2d2 solid 1px; + overflow:hidden; + } + + + } + + .table-inner-container, .inner-table-container { + flex: 0 0 100%; + } +} +/deep/ map-property, /deep/ properties-value-inner-table, /deep/ list-property{ + width:100%; +} + +.filtered { + /deep/ .checkbox-label-content{ + background-color: yellow; + } +} diff --git a/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.ts b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.ts new file mode 100644 index 0000000000..7d0b219ffe --- /dev/null +++ b/catalog-ui/src/app/ng2/components/properties-table/properties-value-inner-table/properties-value-inner-table.component.ts @@ -0,0 +1,37 @@ +/** + * Created by rc2122 on 4/20/2017. + */ +import {Component, Input, Output, EventEmitter} from "@angular/core"; +import {PropertyFEModel} from "app/models"; +import {PropertiesService} from "../../../services/properties.service"; + +@Component({ + selector: 'properties-value-inner-table', + templateUrl: './properties-value-inner-table.component.html', + styleUrls: ['./properties-value-inner-table.component.less'] +}) +export class PropertiesValueInnerTableComponent { + + @Input() property: PropertyFEModel; + @Input() selectedPropertyId: string; + @Input() propertyNameSearchText:string; + + @Output() selectChildProperty: EventEmitter<any> = new EventEmitter<PropertyFEModel>(); + @Output() valueChanged: EventEmitter<any> = new EventEmitter<any>(); + + constructor ( private propertiesService:PropertiesService){ + } + + + onChildPropertySelected = (property) => { + this.selectChildProperty.emit(property); + }; + + propValueChanged = () => { + this.valueChanged.emit(this.property); + }; + + putDefaultValueInEmptyChildProperty = (childProp:PropertyFEModel):void => { + this.property.valueObjectRef[childProp.name] = this.property.valueObjectRef[childProp.name] || childProp.defaultValue; + } +} diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.html b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.html new file mode 100644 index 0000000000..1fbf45e39f --- /dev/null +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.html @@ -0,0 +1,12 @@ +<div class="tooltip {{ placement }}" + [style.top]="top + 'px'" + [style.left]="left + 'px'" + [class.in]="isIn" + [class.fade]="isFade" + role="tooltip"> + <div class="tooltip-arrow"></div> + <div class="tooltip-inner"> + <ng-content></ng-content> + {{ content }} + </div> +</div> diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.less b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.less new file mode 100644 index 0000000000..1ff496f840 --- /dev/null +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.less @@ -0,0 +1,11 @@ +.tooltip-inner { + word-wrap: break-word; + max-width: 300px; +} + +.tooltip.bottom .tooltip-arrow { + border-bottom-color: #000 !important; +} + + + diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.ts b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.ts new file mode 100644 index 0000000000..6e3e8065bb --- /dev/null +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip-content.component.ts @@ -0,0 +1,195 @@ +import {Component, AfterViewInit, Input, ElementRef, ChangeDetectorRef} from "@angular/core"; + +@Component +({ + selector: "tooltip-content", + templateUrl: "./tooltip-content.component.html", + styleUrls: ["./tooltip-content.component.less"] +}) + +export class TooltipContentComponent implements AfterViewInit { + + // ------------------------------------------------------------------------- + // Inputs / Outputs + // ------------------------------------------------------------------------- + + @Input() hostElement: HTMLElement; + @Input() content: string; + @Input() placement: "top"|"bottom"|"left"|"right" = "bottom"; + @Input() animation: boolean = true; + + // ------------------------------------------------------------------------- + // Properties + // ------------------------------------------------------------------------- + + top: number = -100000; + left: number = -100000; + isIn: boolean = false; + isFade: boolean = false; + + // ------------------------------------------------------------------------- + // Constructor + // ------------------------------------------------------------------------- + + constructor(private element: ElementRef, + private cdr: ChangeDetectorRef) { + } + + // ------------------------------------------------------------------------- + // Lifecycle callbacks + // ------------------------------------------------------------------------- + + ngAfterViewInit(): void { + this.show(); + this.cdr.detectChanges(); + } + + // ------------------------------------------------------------------------- + // Public Methods + // ------------------------------------------------------------------------- + + show(): void { + if(!this.hostElement) { + return; + } + + const position = this.positionElement(this.hostElement, this.element.nativeElement.children[0], this.placement); + this.top = position.top; + this.left = position.left; + this.isIn = true; + if (this.animation) { + this.isFade = true; + } + } + + hide(): void { + this.top = -100000; + this.left = -100000; + this.isIn = true; + if(this.animation) { + this.isFade = false; + } + } + + // ------------------------------------------------------------------------- + // Private Methods + // ------------------------------------------------------------------------- + + private positionElement(hostElem: HTMLElement, targetElem: HTMLElement, positionStr: string, appendToBody: boolean = false): {top: number, left: number} { + let positionStrParts = positionStr.split("-"); + let pos0 = positionStrParts[0]; + let pos1 = positionStrParts[1] || "center"; + let hostElemPosition = appendToBody ? this.offset(hostElem) : this.position(hostElem); + let targetElemWidth = targetElem.offsetWidth; + let targetElemHeight = targetElem.offsetHeight; + let shiftWidth: any = { + center(): number { + return hostElemPosition.left + hostElemPosition.width / 2 - targetElemWidth / 2; + }, + left(): number { + return hostElemPosition.left; + }, + right(): number { + return hostElemPosition.left + hostElemPosition.width; + } + }; + + let shiftHeight: any = { + center: function (): number { + return hostElemPosition.top + hostElemPosition.height / 2 - targetElemHeight / 2; + }, + top: function (): number { + return hostElemPosition.top; + }, + bottom: function (): number { + return hostElemPosition.top + hostElemPosition.height; + } + } + + let targetElemPosition: {top: number, left: number}; + + switch (pos0) { + case "right": + targetElemPosition = { + top: shiftHeight[pos1](), + left: shiftWidth[pos0]() + }; + break; + + case "left": + targetElemPosition = { + top: shiftHeight[pos1](), + left: hostElemPosition.left - targetElemWidth + }; + break; + + case "bottom": + targetElemPosition = { + top: shiftHeight[pos0](), + left: shiftWidth[pos1]() + }; + break; + + default: + targetElemPosition = { + top: hostElemPosition.top - targetElemHeight, + left: shiftWidth[pos1]() + }; + break; + } + + return targetElemPosition; + } + + + private position(nativeElem: HTMLElement): {width: number, height: number, top: number, left: number} { + let offsetParentCBR = {top: 0, left: 0}; + const elemBCR = this.offset(nativeElem); + const offsetParentElem = this.parentOffsetElem(nativeElem); + if(offsetParentElem !== window.document) { + offsetParentCBR = this.offset(offsetParentElem); + offsetParentCBR.top += offsetParentElem.clientTop - offsetParentElem.scrollTop; + offsetParentCBR.left += offsetParentElem.clientLeft - offsetParentElem.scrollTop; + } + + const boundingClientRect = nativeElem.getBoundingClientRect(); + + return { + width: boundingClientRect.width || nativeElem.offsetWidth, + height: boundingClientRect.height || nativeElem.offsetHeight, + top: elemBCR.top - offsetParentCBR.top, + left: elemBCR.left - offsetParentCBR.left + }; + } + + private offset(nativeElem:any): {width: number, height: number, top: number, left: number} { + const boundingClientRect = nativeElem.getBoundingClientRect(); + return { + width: boundingClientRect.width || nativeElem.offsetWidth, + height: boundingClientRect.height || nativeElem.offsetHeight, + top: boundingClientRect.top + (window.pageYOffset || window.document.documentElement.scrollTop), + left: boundingClientRect.left + (window.pageXOffset || window.document.documentElement.scrollLeft) + }; + } + + private getStyle(nativeElem: HTMLElement, cssProperty: string): string { + if(window.getComputedStyle) { + return (window.getComputedStyle(nativeElem) as any)[cssProperty]; + } + + return (nativeElem.style as any)[cssProperty]; + } + + private isStaticPositioned(nativeElem: HTMLElement): boolean { + return (this.getStyle(nativeElem, "position") || "static") === "static"; + } + + private parentOffsetElem(nativeElem: HTMLElement): any { + let offsetParent: any = nativeElem.offsetParent || window.document; + while (offsetParent && offsetParent !== window.document && this.isStaticPositioned(offsetParent)) { + offsetParent = offsetParent.offsetParent; + } + + return offsetParent || window.document; + } +} diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts b/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts new file mode 100644 index 0000000000..e98b69003e --- /dev/null +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip.component.ts @@ -0,0 +1,81 @@ +import { + Directive, ComponentRef, ViewContainerRef, ComponentFactoryResolver, Input, HostListener +} from "@angular/core"; +import {TooltipContentComponent} from "./tooltip-content.component"; + +@Directive ({ + selector: "[tooltip]" +}) +export class TooltipComponent { + + // ------------------------------------------------------------------------- + // Properties + // ------------------------------------------------------------------------- + + private tooltip: ComponentRef<TooltipContentComponent>; + private visible: boolean; + + // ------------------------------------------------------------------------- + // Constructor + // ------------------------------------------------------------------------- + + constructor(private viewContainerRef: ViewContainerRef, + private resolver: ComponentFactoryResolver) { + } + + // ------------------------------------------------------------------------- + // Inputs / Outputs + // ------------------------------------------------------------------------- + + @Input("tooltip") content: string|TooltipContentComponent; + @Input() tooltipDisabled: boolean; + @Input() tooltipAnimation: boolean = true; + @Input() tooltipPlacement: "top"|"bottom"|"left"|"right" = "bottom"; + + // ------------------------------------------------------------------------- + // Public Methods + // ------------------------------------------------------------------------- + + @HostListener("mouseenter") + show(): void { + if(this.tooltipDisabled || this.visible || this.content === "") { + return; + } + + this.visible = true; + if (typeof this.content === "string") { + const factory = this.resolver.resolveComponentFactory(TooltipContentComponent); + if (!this.visible) { + return; + } + + this.tooltip = this.viewContainerRef.createComponent(factory); + this.tooltip.instance.hostElement = this.viewContainerRef.element.nativeElement; + this.tooltip.instance.content = this.content as string; + this.tooltip.instance.placement = this.tooltipPlacement; + this.tooltip.instance.animation = this.tooltipAnimation; + } else { + const tooltip = this.content as TooltipContentComponent; + tooltip.hostElement = this.viewContainerRef.element.nativeElement; + tooltip.placement = this.tooltipPlacement; + tooltip.animation = this.tooltipAnimation; + tooltip.show(); + } + } + + @HostListener("mouseleave") + hide(): void { + if (!this.visible) { + return; + } + + this.visible = false; + if (this.tooltip) { + this.tooltip.destroy(); + } + if (this.content instanceof TooltipContentComponent) { + (this.content as TooltipContentComponent).hide(); + } + } +} + diff --git a/catalog-ui/src/app/ng2/components/tooltip/tooltip.module.ts b/catalog-ui/src/app/ng2/components/tooltip/tooltip.module.ts new file mode 100644 index 0000000000..69976da6af --- /dev/null +++ b/catalog-ui/src/app/ng2/components/tooltip/tooltip.module.ts @@ -0,0 +1,25 @@ +import {NgModule} from "@angular/core"; +import {TooltipContentComponent} from "./tooltip-content.component"; +import {TooltipComponent} from "./tooltip.component"; +import {CommonModule} from "@angular/common"; + +@NgModule({ + declarations: [ + TooltipComponent, + TooltipContentComponent, + ], + imports: [ + CommonModule + ], + exports: [ + TooltipComponent, + TooltipContentComponent, + ], + entryComponents: [ + TooltipContentComponent + ], + providers: [] +}) +export class TooltipModule { + +} diff --git a/catalog-ui/src/app/ng2/pages/page404/page404.component.html b/catalog-ui/src/app/ng2/pages/page404/page404.component.html new file mode 100644 index 0000000000..d488587154 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/page404/page404.component.html @@ -0,0 +1,3 @@ +<div class="page404"> + Page404 +</div> diff --git a/catalog-ui/src/app/ng2/pages/page404/page404.component.less b/catalog-ui/src/app/ng2/pages/page404/page404.component.less new file mode 100644 index 0000000000..2672f22f27 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/page404/page404.component.less @@ -0,0 +1,4 @@ +.page404 { + font-size: 100px; + color: #ff0000; +} diff --git a/catalog-ui/src/app/ng2/pages/page404/page404.component.ts b/catalog-ui/src/app/ng2/pages/page404/page404.component.ts new file mode 100644 index 0000000000..a3baf4fd02 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/page404/page404.component.ts @@ -0,0 +1,9 @@ +import { Component, Inject } from '@angular/core'; + +@Component({ + templateUrl: './page404.component.html', + styleUrls: ['./page404.component.less'] +}) +export class PageNotFoundComponent { + +} diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts new file mode 100644 index 0000000000..6ef3e57678 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts @@ -0,0 +1,72 @@ +import { NgModule } from "@angular/core"; +import { PropertiesAssignmentComponent } from "./properties-assignment.page.component"; +import { HierarchyNavigationComponent } from "./../../components/hierarchy-navigtion/hierarchy-navigation.component"; +import { BrowserModule } from "@angular/platform-browser"; +import { FormsModule } from "@angular/forms"; +import { HttpModule } from "@angular/http"; +import { TabModule } from '../../shared/tabs/tabs.module'; +import { CheckboxModule} from '../../shared/checkbox/checkbox.module'; +import { PropertiesTableComponent } from '../../components/properties-table/properties-table.component'; +import { InputsTableComponent } from '../../components/inputs-table/inputs-table.component'; +import { ContentAfterLastDotPipe } from "../../pipes/contentAfterLastDot.pipe"; +import { SearchFilterPipe } from "../../pipes/searchFilter.pipe"; +import { FilterChildPropertiesPipe } from "../../pipes/filterChildProperties.pipe"; +import { DataTypeService } from './../../services/data-type.service'; +import { PropertiesService } from './../../services/properties.service'; +import { PropertiesUtils } from './properties.utils'; +import { PostsService } from "../../services/posts.service"; +import { PropertiesValueInnerTableComponent } from "./../../components/properties-table/properties-value-inner-table/properties-value-inner-table.component"; +import { ListPropertyComponent } from "./../../components/properties-table/list-property/list-property.component"; +import { MapPropertyComponent } from "./../../components/properties-table/map-property/map-property.component"; +import { DynamicElementModule } from 'app/ng2/components/dynamic-element/dynamic-element.module'; +import { DynamicPropertyComponent } from './../../components/properties-table/dynamic-property/dynamic-property.component'; +import { DerivedPropertyComponent } from './../../components/properties-table/derived-property/derived-property.component'; +// import {PopoverContentComponent} from "../../components/popover/popover-content.component" +// import {PopoverComponent} from "../../components/popover/popover.component" +import { PopoverModule } from "../../components/popover/popover.module" +import { FilterPropertiesAssignmentComponent } from "./../../components/filter-properties-assignment/filter-properties-assignment.component"; +import { GroupByPipe } from 'app/ng2/pipes/groupBy.pipe'; +import { KeysPipe } from 'app/ng2/pipes/keys.pipe'; +import {TooltipModule} from "../../components/tooltip/tooltip.module"; + +@NgModule({ + declarations: [ + PropertiesAssignmentComponent, + PropertiesTableComponent, + InputsTableComponent, + ContentAfterLastDotPipe, + GroupByPipe, + KeysPipe, + SearchFilterPipe, + FilterChildPropertiesPipe, + HierarchyNavigationComponent, + PropertiesValueInnerTableComponent, + ListPropertyComponent, + MapPropertyComponent, + DerivedPropertyComponent, + DynamicPropertyComponent, + // PopoverContentComponent, + // PopoverComponent, + FilterPropertiesAssignmentComponent + ], + imports: [ + BrowserModule, + FormsModule, + HttpModule, + TabModule, + CheckboxModule, + DynamicElementModule, + PopoverModule, + TooltipModule + ], + entryComponents: [PropertiesAssignmentComponent], + exports: [ + PropertiesAssignmentComponent + // PopoverContentComponent, + // PopoverComponent + ], + providers: [PropertiesService, PropertiesUtils, DataTypeService, PostsService, ContentAfterLastDotPipe, GroupByPipe, KeysPipe] +}) +export class PropertiesAssignmentModule { + +} diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html new file mode 100644 index 0000000000..d1b671cff2 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.html @@ -0,0 +1,57 @@ +<div class="properties-assignment-page"> + <div class="main-content"> + <div class="left-column"> + <tabs #propertyInputTabs tabStyle="round-tabs" (tabChanged)="tabChanged($event)" [hideIndicationOnTabChange]="true"> + <tab tabTitle="Properties"> + <properties-table class="properties-table" + [fePropertiesMap]="instanceFePropertiesMap | searchFilter:'name':searchQuery" + [selectedPropertyId]="selectedFlatProperty.uniqueId" + [propertyNameSearchText]="searchPropertyName" + (valueChanged)="propertyValueChanged($event)" + (propertySelected)="propertySelected($event)" + (selectPropertyRow)="selectPropertyRow($event)" + (selectChildProperty)="selectChildProperty($event)" + (updateCheckedPropertyCount)="updateCheckedPropertyCount($event)" + (selectInstanceRow)="selectInstanceRow($event)"> + </properties-table> + </tab> + <tab tabTitle="Inputs"> + <inputs-table class="properties-table" [inputs]="inputs | searchFilter:'name':searchQuery" (deleteInput)="deleteInput($event)" (inputValueChanged)="inputValueChanged($event)"></inputs-table> + </tab> + </tabs> + <div class="header"> + <div class="search-filter-container"> + <input type="text" class="search-box" placeholder="Search" [(ngModel)]="searchQuery" /> + <span class="sprite search-icon"></span> + <filter-properties-assignment *ngIf="!hideAdvanceSearch" #advanceSearch class="advance-search" [componentType]="component.componentType" (searchProperties)="searchPropertiesInstances($event)"></filter-properties-assignment> + <span *ngIf="displayClearSearch && !hideAdvanceSearch" (click)="clickOnClearSearch()" class="clear-filter">Clear All</span> + </div> + <button class="tlv-btn blue declare-button" [disabled]="!checkedPropertiesCount" (click)="declareProperties()">Declare</button> + </div> + </div> + <div class="right-column gray-border"> + <tabs #hierarchyNavTabs tabStyle="simple-tabs"> + <tab tabTitle="Composition"> + <div class="hierarchy-nav-container"> + <div class="hierarchy-header">{{component.name}}</div> + <div *ngIf="!instancesNavigationData || instancesNavigationData.length === 0">No data to display</div> + <hierarchy-navigation class="hierarchy-nav" (updateSelected)="onInstanceSelectedUpdate($event)" + [displayData]="instancesNavigationData" + [selectedItem]="selectedInstanceData.uniqueId" + [displayOptions]="hierarchyInstancesDisplayOptions"></hierarchy-navigation> + </div> + </tab> + <tab tabTitle="Property Structure"> + <div class="hierarchy-nav-container"> + <div class="hierarchy-header">{{propertyStructureHeader || selectedFlatProperty.name || "No Property Selected"}}</div> + <div *ngIf="!propertiesNavigationData || propertiesNavigationData.length === 0">No data to display</div> + <hierarchy-navigation class="hierarchy-nav" (updateSelected)="onPropertySelectedUpdate($event)" + [displayData]="propertiesNavigationData" + [selectedItem]="selectedFlatProperty.uniqueId" + [displayOptions]="hierarchyPropertiesDisplayOptions"></hierarchy-navigation> + </div> + </tab> + </tabs> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less new file mode 100644 index 0000000000..f7a62bbcb5 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.less @@ -0,0 +1,158 @@ +@import '../../../../assets/styles/variables'; +@ng2-shadow-gray: #f8f8f8; +@ng2-light-gray: #eaeaea; +@ng2-medium-gray: #d2d2d2; +@ng2-med-dark-gray: #999999; +@ng2-dark-gray: #5a5a5a; +@ng2-shadow-blue: #e6f6fb; +@ng2-bold-blue: #009fdb; +@ng2-success-green:#4ca90c; +@ng2-title-font-size:16px; +@ng2-text-font-size: 14px; + +:host { display:block; height: 100%; } +/deep/ tabs {display:flex; flex-direction:column; height:100%; } + +.properties-assignment-page { + height: 100%; + + .main-content { + display:flex; + flex-direction:row; + height: 100%; + } + + .left-column { + flex: 1 0 500px; + position: relative; + margin: 0 0 1em 0; + + /deep/ .tabs { + width:25%; + text-align:center; + + } + + /deep/ .tab { + padding: 10px .5em; + + &.active { + color:#009fdb; + border-color: #d2d2d2; + border-top: solid 4px #009fdb; + background-color: white; + padding-top:7px; + } + } + + .header { + position:absolute; + top:0; + right:0; + min-width:200px; + } + + .search-filter-container{ + position: relative; + right: 164px; + } + + .search-box { + border: 1px solid @ng2-medium-gray; + border-radius: 4px; + height: 32px; + margin: 0; + padding: 2px 20px 4px 10px; + outline: none; + font-style: italic; + color:@ng2-med-dark-gray; + margin-right:10px; + + &::-moz-placeholder { color:@ng2-med-dark-gray;} + &::-webkit-input-placeholder{ color:@ng2-med-dark-gray;} + } + .search-icon { + background-position: -48px -3137px; + width: 14px; + height: 14px; + position: relative; + right: 34px; + top: 4px; + } + .advance-search{ + position: relative; + right: 22px; + } + .clear-filter{ + cursor: pointer; + color: @main_color_c; + font-family: @font-omnes-medium-italic; + text-decoration: underline; + position: relative; + top: 4px; + right: 16px; + } + + .declare-button{ + position: absolute; + top: 0; + right: 0; + } + } + + .right-column { + display:flex; + flex:0 0 350px; + flex-direction:column; + margin: 3em 0 1em 1em; + padding: 10px; + overflow:auto; + + /deep/ .tabs { + width: 33%; + } + + /deep/ .tab { + padding: 0.5em 1em 0 1em; + white-space: nowrap; + font-size: 13px; + } + } + + .hierarchy-tabs { + flex: 0 0 40px; + } + + .gray-border { + border: 1px solid #ddd; + } + + + .hierarchy-nav-container { + flex:1; + overflow: auto; + flex-direction: column; + height: 100%; + } + + .hierarchy-header { + height:30px; + line-height: 2.5em; + display: flex; + width: 100%; + padding-left: 14px; + font-weight: bold; + text-align: left; + background-color: @ng2-light-gray; + font-size: 13px; + } + + .hierarchy-nav { + display: grid; + margin-top: 1em; + margin-left: 1em; + font-size: 12px; + padding-top: 1em; + } +} + diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts new file mode 100644 index 0000000000..299615b122 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -0,0 +1,344 @@ +import {Component, ViewChild, ElementRef, Renderer, Inject} from "@angular/core"; +import {PostsService} from "../../services/posts.service"; +import {PropertiesService, SimpleFlatProperty} from "../../services/properties.service"; +import { PropertiesUtils } from './properties.utils'; +import { PropertyFEModel, InstanceFePropertiesMap, InstanceBePropertiesMap, InstancePropertiesAPIMap, Component as ComponentData, FilterPropertiesAssignmentData } from "app/models"; +import { PROPERTY_TYPES, ResourceType } from "app/utils"; +import property = require("lodash/property"); +import {ComponentServiceNg2} from "../../services/component-services/component.service"; +import {ComponentInstanceServiceNg2} from "../../services/component-instance-services/component-instance.service" +import {InputFEModel, ComponentInstance, PropertyBEModel, DerivedFEProperty, ResourceInstance} from "app/models"; +import {HierarchyDisplayOptions} from "../../components/hierarchy-navigtion/hierarchy-display-options" +import {PropertyRowSelectedEvent} from "./../../components/properties-table/properties-table.component"; +import { KeysPipe } from 'app/ng2/pipes/keys.pipe'; +import {FilterPropertiesAssignmentComponent} from "../../components/filter-properties-assignment/filter-properties-assignment.component"; + +@Component({ + templateUrl: './properties-assignment.page.component.html', + styleUrls: ['./properties-assignment.page.component.less'] +}) +export class PropertiesAssignmentComponent { + title = "Properties & Inputs"; + + component:ComponentData; + + propertiesNavigationData = []; + instancesNavigationData = []; + + instanceFePropertiesMap:InstanceFePropertiesMap; + inputs: Array<InputFEModel> = []; + instances: Array<ComponentInstance> = []; + searchQuery: string; + propertyStructureHeader: string + + selectedFlatProperty: SimpleFlatProperty = new SimpleFlatProperty(); + selectedInstanceType: string; + selectedInstanceData: ComponentInstance = new ComponentInstance(); + checkedPropertiesCount: number = 0; + + hierarchyPropertiesDisplayOptions:HierarchyDisplayOptions = new HierarchyDisplayOptions('uniqueId', 'name', 'childrens'); + hierarchyInstancesDisplayOptions:HierarchyDisplayOptions = new HierarchyDisplayOptions('uniqueId', 'name'); + displayClearSearch = false; + searchPropertyName:string; + hideAdvanceSearch:boolean; + + @ViewChild('hierarchyNavTabs') hierarchyNavTabs: ElementRef; + @ViewChild('propertyInputTabs') propertyInputTabs: ElementRef; + @ViewChild('advanceSearch') advanceSearch: FilterPropertiesAssignmentComponent; + + constructor(private propertiesService:PropertiesService, + private propertiesUtils:PropertiesUtils, + private componentServiceNg2:ComponentServiceNg2, + private componentInstanceServiceNg2:ComponentInstanceServiceNg2, + @Inject("$stateParams") _stateParams, + private renderer: Renderer) { + + this.instanceFePropertiesMap = new InstanceFePropertiesMap(); + + /* This is the way you can access the component data, please do not use any data except metadata, all other data should be received from the new api calls on the first time + than if the data is already exist, no need to call the api again - Ask orit if you have any questions*/ + this.component = _stateParams.component; + } + + ngOnInit() { + console.log("==>" + this.constructor.name + ": ngOnInit"); + this.componentServiceNg2 + .getComponentResourceInstances(this.component) + .subscribe(response => { + this.instances = response.componentInstances; + + _.forEach(this.instances, (instance) => { + this.instancesNavigationData.push(instance); + }); + + this.selectFirstInstanceByDefault(); + }); + + this.componentServiceNg2 + .getComponentInputs(this.component) + .subscribe(response => { + _.forEach(response.inputs, (input: PropertyBEModel) => { + this.inputs.push(new InputFEModel(input)); + }); + }) + } + + selectFirstInstanceByDefault = () => { + if (this.instancesNavigationData[0] !== undefined) { + this.onInstanceSelectedUpdate(this.instancesNavigationData[0]); + } + } + + propertyValueChanged = (event) => { + console.log("==>" + this.constructor.name + ": propertyValueChanged " + event); + + if(this.selectedInstanceData.originType === ResourceType.VF) { + console.log("I want to update input value on the resource instance"); + let inputToUpdate = new PropertyBEModel(event); + this.componentInstanceServiceNg2 + .updateInstanceInput(this.component, this.selectedInstanceData.uniqueId, inputToUpdate) + .subscribe(response => { + console.log("update resource instance input and got this response: ",response); + }) + } + else { + // Copying the actual value from the object ref into the value if it's from a complex type + if(event.isDataType) { + event.value = JSON.stringify(event.valueObjectRef); + } + let propertyBe = new PropertyBEModel(event); + this.componentInstanceServiceNg2 + .updateInstanceProperty(this.component, this.selectedInstanceData.uniqueId, propertyBe) + .subscribe(response => { + console.log("updated resource instance property and got this response: ",response); + }); + console.log(event); + } + + }; + + inputValueChanged = (event) => { + console.log("==>" + this.constructor.name + ": inputValueChanged"); + let inputToUpdate = new PropertyBEModel(event); + + this.componentServiceNg2 + .updateComponentInput(this.component, inputToUpdate) + .subscribe(response => { + console.log("updated the component input and got this response: ", response); + }) + }; + + declareProperties = ():void => { + console.log("==>" + this.constructor.name + ": declareProperties"); + + let selectedProperties: InstanceBePropertiesMap = new InstanceBePropertiesMap(); + + let instancesNames = new KeysPipe().transform(this.instanceFePropertiesMap,[]); + angular.forEach(instancesNames, (instanceName:string):void=>{ + selectedProperties[instanceName] = this.propertiesService.getCheckedProperties(this.instanceFePropertiesMap[instanceName]); + //selectedProperties[this.selectedInstanceData.uniqueId] = this.propertiesService.getCheckedProperties(this.properties); + }); + + let inputsToCreate: InstancePropertiesAPIMap; + if (this.selectedInstanceType !== ResourceType.VF) { + inputsToCreate = new InstancePropertiesAPIMap(null, selectedProperties); + } else { + inputsToCreate = new InstancePropertiesAPIMap(selectedProperties, null); + } + this.componentServiceNg2 + .createInput(this.component, inputsToCreate) + .subscribe(response => { + this.setInputTabIndication(response.length); + this.checkedPropertiesCount = 0; + _.forEach(response, (input: PropertyBEModel) => { this.inputs.push(new InputFEModel(input)); }); + this.findAndDisableDeclaredProperties(); + }); + } + + //TODO: Can remove? no one use it + // getSelectedFEProps = (): Array<PropertyFEModel> => { + // return this.properties.filter(prop => prop.isSelected && !prop.isDeclared); + // } + + onInstanceSelectedUpdate = (resourceInstance: ResourceInstance) => { + console.log("==>" + this.constructor.name + ": onInstanceSelectedUpdate"); + let instanceBePropertiesMap: InstanceBePropertiesMap = new InstanceBePropertiesMap(); + this.selectedInstanceData = resourceInstance; + this.selectedInstanceType = resourceInstance.originType; + + if(resourceInstance.originType === ResourceType.VF) { + this.componentInstanceServiceNg2 + .getComponentInstanceInputs(this.component, resourceInstance) + .subscribe(response => { + instanceBePropertiesMap[resourceInstance.uniqueId] = response; + this.processInstancePropertiesResponse(instanceBePropertiesMap); + }); + } else { + this.componentInstanceServiceNg2 + .getComponentInstanceProperties(this.component, resourceInstance.uniqueId) + .subscribe(response => { + instanceBePropertiesMap[resourceInstance.uniqueId] = response; + this.processInstancePropertiesResponse(instanceBePropertiesMap); + }); + } + + if( this.searchPropertyName ){ + this.clearSearch(); + } + }; + + /** + * Entry point handling response from server + */ + processInstancePropertiesResponse = (instanceBePropertiesMap:InstanceBePropertiesMap) => { + this.instanceFePropertiesMap = this.propertiesUtils.convertPropertiesMapToFEAndCreateChildren(instanceBePropertiesMap); //create flattened children + this.findAndDisableDeclaredProperties(); //disable properties or flattened children that are declared + this.checkedPropertiesCount = 0; + }; + + /** + * Handle select node in navigation area, and select the row in table + */ + onPropertySelectedUpdate = ($event) => { + console.log("==>" + this.constructor.name + ": onPropertySelectedUpdate"); + this.selectedFlatProperty = $event; + let parentProperty:PropertyFEModel = this.propertiesService.getParentPropertyFEModelFromPath(this.instanceFePropertiesMap[this.selectedFlatProperty.instanceName], this.selectedFlatProperty.path); + parentProperty.expandedChildPropertyId = this.selectedFlatProperty.path; + }; + + /** + * When user select row in table, this will prepare the hirarchy object for the tree. + */ + selectPropertyRow = (propertyRowSelectedEvent:PropertyRowSelectedEvent) => { + console.log("==>" + this.constructor.name + ": selectPropertyRow " + propertyRowSelectedEvent.propertyModel.name); + let property = propertyRowSelectedEvent.propertyModel; + let instanceName = propertyRowSelectedEvent.instanceName; + this.propertyStructureHeader = null; + + // Build hirarchy tree for the navigation and update propertiesNavigationData with it. + if(this.selectedInstanceData.originType !== ResourceType.VF) { + let simpleFlatProperty:Array<SimpleFlatProperty>; + if (property instanceof PropertyFEModel) { + simpleFlatProperty = this.propertiesService.getSimplePropertiesTree(property, instanceName); + } else if (property instanceof DerivedFEProperty) { + // Need to find parent PropertyFEModel + let parentPropertyFEModel:PropertyFEModel = _.find(this.instanceFePropertiesMap[instanceName], (tmpFeProperty):boolean => { + return property.propertiesName.indexOf(tmpFeProperty.name)===0; + }); + simpleFlatProperty = this.propertiesService.getSimplePropertiesTree(parentPropertyFEModel, instanceName); + } + this.propertiesNavigationData = simpleFlatProperty; + } + + // Updatet the header in the navigation tree with property name. + if(property instanceof DerivedFEProperty) { + this.propertyStructureHeader = (property.propertiesName.split('#'))[0]; + } + + // Set selected property in table + this.selectedFlatProperty = new SimpleFlatProperty(property.uniqueId, null, property.name, null); + this.renderer.invokeElementMethod(this.hierarchyNavTabs, 'triggerTabChange', ['Property Structure']); + }; + + //TODO: Can remove? no one use it + // findParentProperty = (childProp: DerivedFEProperty): PropertyFEModel => { + // return this.properties.find(prop => prop.name == childProp.propertiesName.substring(0, childProp.propertiesName.indexOf("#"))); + // } + + //used for declare button, to keep count of newly checked properties (and ignore declared properties) + updateCheckedPropertyCount = (increment: boolean):void => { + this.checkedPropertiesCount += (increment) ? 1 : -1; + console.log("CheckedProperties count is now.... " + this.checkedPropertiesCount); + } + + selectInstanceRow = ($event) => {//get instance name + this.selectedInstanceData = _.find(this.instancesNavigationData, (instance:ComponentInstance) => { + return instance.name == $event; + }); + this.renderer.invokeElementMethod( + this.hierarchyNavTabs, 'triggerTabChange', ['Composition']); + } + + tabChanged = (event) => { + console.log("==>" + this.constructor.name + ": tabChanged " + event); + this.hideAdvanceSearch = event.title !== "Properties"; + this.searchQuery = ''; + }; + + deleteInput = (input:InputFEModel) => { + console.log("==>" + this.constructor.name + ": deleteInput"); + let inputToDelete = new PropertyBEModel(input); + + this.componentServiceNg2 + .deleteInput(this.component, inputToDelete) + .subscribe(response => { + this.inputs = this.inputs.filter(input => input.uniqueId !== response.uniqueId); + let propToEnable: PropertyFEModel = this.instanceFePropertiesMap[input.instanceName].find(prop => prop.name == input.propertyName); + propToEnable.setNonDeclared(response.inputPath); + this.propertiesService.undoDisableRelatedProperties(propToEnable, response.inputPath); + //this.propertiesService.initValueObjectRef(propToEnable); //TODO:speak to BE about value returned by server + }); + } + + setInputTabIndication = (numInputs: number): void => { + this.renderer.invokeElementMethod( this.propertyInputTabs, 'setTabIndication', ['Inputs', numInputs]); + } + + findAndDisableDeclaredProperties = () => { + this.inputs.filter(input => input.instanceName === this.selectedInstanceData.normalizedName).forEach(input => { + let prop: PropertyFEModel = this.instanceFePropertiesMap[this.selectedInstanceData.uniqueId].find(prop => prop.name === input.propertyName); + if (prop) { + prop.setAsDeclared(input.inputPath); //if a path was sent, its a child prop. this param is optional + this.propertiesService.disableRelatedProperties(prop, input.inputPath) + //this.propertiesService.initValueObjectRef(prop); + } + }); + }; + + searchPropertiesInstances = (filterData:FilterPropertiesAssignmentData) => { + //let filteredProperties = this.componentServiceNg2.filterComponentInstanceProperties(this.component, filterData); + let instanceBePropertiesMap:InstanceBePropertiesMap; + this.componentServiceNg2 + .filterComponentInstanceProperties(this.component, filterData) + .subscribe(response => { + //instanceBePropertiesMap=response; + //console.log("================filter results============="); + //console.table(instanceBePropertiesMap); + this.processInstancePropertiesResponse(response); + + + //this.properties = []; + // _.forEach(instanceBePropertiesMap, (InstanceProperties:Array<PropertyBEModel>, instanceName:string) => { + // this.properties = this.properties.concat(this.propertiesService.convertPropertiesToFEAndCreateChildren(InstanceProperties, instanceName)); + // }); + + + // this.instancesNavigationData = _.filter(this.instancesNavigationData, (instance:ComponentInstance) => { + // return instanceBePropertiesMap[instance.name]; + // }); + + // this.hierarchyPropertiesDisplayOptions.searchText = filterData.propertyName;//mark results in tree + this.searchPropertyName = filterData.propertyName;//mark in table + this.renderer.invokeElementMethod(this.hierarchyNavTabs, 'triggerTabChange', ['Composition']); + this.propertiesNavigationData = []; + this.displayClearSearch = true; + }); + + }; + + clearSearch = () => { + this.instancesNavigationData = this.instances; + this.searchPropertyName = ""; + this.hierarchyPropertiesDisplayOptions.searchText = ""; + this.displayClearSearch = false; + this.advanceSearch.clearAll(); + } + + clickOnClearSearch = () => { + this.clearSearch(); + this.selectFirstInstanceByDefault(); + this.renderer.invokeElementMethod( + this.hierarchyNavTabs, 'triggerTabChange', ['Composition']); + } + +} diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts new file mode 100644 index 0000000000..79769e21b5 --- /dev/null +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts @@ -0,0 +1,78 @@ +import { Injectable } from '@angular/core'; +import { DataTypeModel, PropertyFEModel, PropertyBEModel, InstanceBePropertiesMap, InstanceFePropertiesMap, SchemaProperty, DerivedFEProperty, DerivedFEPropertyMap, DerivedPropertyType, InputFEModel} from "app/models"; +import { DataTypeService } from "app/ng2/services/data-type.service"; +import { PROPERTY_TYPES } from "app/utils"; +import { UUID } from "angular2-uuid"; + +@Injectable() +export class PropertiesUtils { + + constructor(private dataTypeService:DataTypeService) {} + + /** + * Entry point when getting properties from server + * Returning InstanceFePropertiesMap + */ + public convertPropertiesMapToFEAndCreateChildren = (instancePropertiesMap:InstanceBePropertiesMap): InstanceFePropertiesMap => { + let instanceFePropertiesMap:InstanceFePropertiesMap = new InstanceFePropertiesMap(); + angular.forEach(instancePropertiesMap, (properties:Array<PropertyBEModel>, instanceName:string) => { + instanceFePropertiesMap[instanceName] = this.convertPropertiesToFEAndCreateChildren(properties); + }); + return instanceFePropertiesMap; + } + + /** + * Convert the properties Array<PropertyBEModel> to Array<PropertyFEModel> + */ + private convertPropertiesToFEAndCreateChildren = (properties: Array<PropertyBEModel>): Array<PropertyFEModel> => { + let propertyFeArray: Array<PropertyFEModel> = []; + _.forEach(properties, (property: PropertyBEModel, index: number) => { + //console.log("=======" + property.name + "========"); + if(!this.dataTypeService.getDataTypeByTypeName(property.type)){ // if type not exist in data types remove property from list + console.log("ERROR: missing type " + property.type + " in dataTypes , of property ",property); + return; + } + let propertyFe:PropertyFEModel = new PropertyFEModel(property); + if (propertyFe.isDataType) { //prop is not simple, list, or map. Need to create children. + let tempProps: Array<DerivedFEProperty> = []; + let dataTypeObj: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(propertyFe.type); + this.dataTypeService.getDerivedDataTypeProperties(dataTypeObj, tempProps, propertyFe.name); + propertyFe.flattenedChildren = tempProps; + propertyFe.expandedChildPropertyId = propertyFe.name; + this.initValueObjectRef(propertyFe); + } + propertyFeArray.push(propertyFe); + + + }); + return propertyFeArray; + + //TODO: need to look at schema to create the nested properties for the following cases: + // 1 - when value is populated for a complex type (list or map) + // 2 - when adding new entries to a complex type (eg. adding a new entry to a list of AddressRequirements) + } + + public initValueObjectRef = (property: PropertyFEModel): void => { + //console.log("Property " + property.name + " has value: " + property.value); + if (!property.isDataType || property.isDeclared) { //if property is declared, it gets a simple input instead. List and map values and pseudo-children will be handled in property component + property.value = property.value || property.defaultValue; + } else if (property.value){ //we have a complex property with a value. Lets parse property.value and populate our flattened children with those values + this.assignValuesRecursively(JSON.parse(property.value), property.flattenedChildren, property.name); + } + } + + public assignValuesRecursively = (valueJSON: any, derivedPropArray: Array<DerivedFEProperty>, propName: string) => { + if (valueJSON && Object.keys(valueJSON)) { + Object.keys(valueJSON).forEach(valueKey => { + let childProp: DerivedFEProperty = derivedPropArray.find(prop => prop.propertiesName == propName + "#" + valueKey); + if (!childProp) return; + if (childProp.isDeclared || (childProp.derivedDataType != DerivedPropertyType.COMPLEX && !_.isEmpty(valueJSON[valueKey]))) { + childProp.value = (typeof valueJSON[valueKey] === 'object')? JSON.stringify(valueJSON[valueKey]) : valueJSON[valueKey]; + } else { + this.assignValuesRecursively(valueJSON[valueKey], derivedPropArray, childProp.propertiesName) + } + }); + } + } + +} diff --git a/catalog-ui/src/app/ng2/pipes/contentAfterLastDot.pipe.ts b/catalog-ui/src/app/ng2/pipes/contentAfterLastDot.pipe.ts new file mode 100644 index 0000000000..68fba92b77 --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/contentAfterLastDot.pipe.ts @@ -0,0 +1,8 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'contentAfterLastDot' }) +export class ContentAfterLastDotPipe implements PipeTransform { + transform(value:string): string { + return value.split('.').pop(); + } +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts b/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts new file mode 100644 index 0000000000..d2eaef0391 --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/filterChildProperties.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { DerivedFEProperty } from 'app/models'; + +@Pipe({ + name: 'filterChildProperties', +}) +export class FilterChildPropertiesPipe implements PipeTransform { + public transform(childProperties: Array<DerivedFEProperty>, parentId: string) { + if (!parentId || !childProperties) return childProperties; + + let validParents: Array<string> = [parentId]; + while (parentId.lastIndexOf('#') > 0) { + parentId = parentId.substring(0, parentId.lastIndexOf('#')); + validParents.push(parentId); + } + return childProperties.filter(derivedProp => validParents.indexOf(derivedProp.parentName) > -1); + } +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/pipes/groupBy.pipe.ts b/catalog-ui/src/app/ng2/pipes/groupBy.pipe.ts new file mode 100644 index 0000000000..17ccc0ca75 --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/groupBy.pipe.ts @@ -0,0 +1,19 @@ +/** + * Created by rc2122 on 5/17/2017. + */ +import {Pipe, PipeTransform} from '@angular/core'; + +@Pipe({name: 'groupBy'}) +export class GroupByPipe implements PipeTransform { + transform(value: Array<any>, field: string): Array<any> { + const groupedObj = value.reduce((prev, cur)=> { + if(!prev[cur[field]]) { + prev[cur[field]] = [cur]; + } else { + prev[cur[field]].push(cur); + } + return prev; + }, {}); + return Object.keys(groupedObj).map((key:string) => {return { key, value: groupedObj[key] }; }); + } +} diff --git a/catalog-ui/src/app/ng2/pipes/keys.pipe.ts b/catalog-ui/src/app/ng2/pipes/keys.pipe.ts new file mode 100644 index 0000000000..13bd26969c --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/keys.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({name: 'keys'}) +export class KeysPipe implements PipeTransform { + transform(value, args:string[]) : any { + let keys = []; + for (let key in value) { + keys.push(key); + } + return keys; + } +} diff --git a/catalog-ui/src/app/ng2/pipes/searchFilter.pipe.ts b/catalog-ui/src/app/ng2/pipes/searchFilter.pipe.ts new file mode 100644 index 0000000000..7e017e8590 --- /dev/null +++ b/catalog-ui/src/app/ng2/pipes/searchFilter.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'searchFilter', +}) +export class SearchFilterPipe implements PipeTransform { + public transform(value, key: string, term: string) { + if (!term || !term.length) return value; + return value.filter((item) => { + if (item.hasOwnProperty(key)) { + let regExp = new RegExp(term, 'gi'); + return regExp.test(item[key]); + } else { + return false; + } + }); + } +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/services/authentication.service.ts b/catalog-ui/src/app/ng2/services/authentication.service.ts new file mode 100644 index 0000000000..7fe3e22f4c --- /dev/null +++ b/catalog-ui/src/app/ng2/services/authentication.service.ts @@ -0,0 +1,40 @@ +import { Injectable } from '@angular/core'; +import { sdc2Config } from './../../../main'; +import {IAppConfigurtaion, ICookie} from "../../models/app-config"; +import {Response, Headers, RequestOptions, Http} from '@angular/http'; +import {Cookie2Service} from "./cookie.service"; +import { Observable } from 'rxjs/Observable'; + +@Injectable() +export class AuthenticationService { + + private cookieService:Cookie2Service; + private http:Http; + + constructor(cookieService:Cookie2Service, http: Http) { + this.cookieService = cookieService; + this.http = http; + } + + private getAuthHeaders():any { + let cookie:ICookie = sdc2Config.cookie; + let authHeaders:any = {}; + authHeaders[cookie.userFirstName] = this.cookieService.getFirstName(); + authHeaders[cookie.userLastName] = this.cookieService.getLastName(); + authHeaders[cookie.userEmail] = this.cookieService.getEmail(); + authHeaders[cookie.userIdSuffix] = this.cookieService.getUserId(); + return authHeaders; + } + + public authenticate(): Observable<JSON> { + let options = new RequestOptions({ + headers: new Headers(this.getAuthHeaders()) + }); + + let authUrl = sdc2Config.api.root + sdc2Config.api.GET_user_authorize; + return this.http + .get(authUrl, options) + .map((res: Response) => res.json()); + } + +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts new file mode 100644 index 0000000000..85709894ff --- /dev/null +++ b/catalog-ui/src/app/ng2/services/component-instance-services/component-instance.service.ts @@ -0,0 +1,51 @@ +import {Injectable} from '@angular/core'; +import {Response, RequestOptions, Headers} from '@angular/http'; +import { Observable } from 'rxjs/Observable'; +import {HttpService} from "../http.service"; +import {sdc2Config} from "../../../../main"; +import {PropertyBEModel} from "app/models"; +import {CommonUtils} from "app/utils"; +import {Component, ComponentInstance, InputModel} from "app/models"; + +@Injectable() +export class ComponentInstanceServiceNg2 { + + protected baseUrl; + + constructor(private http: HttpService) { + this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root; + } + + getComponentInstanceProperties(component: Component, componentInstanceId: string): Observable<Array<PropertyBEModel>> { + + return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstanceId + '/properties') + .map((res: Response) => { + return CommonUtils.initBeProperties(res.json()); + }) + } + + getComponentInstanceInputs(component: Component, componentInstance: ComponentInstance): Observable<Array<PropertyBEModel>> { + return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/componentInstances/' + componentInstance.uniqueId + '/' + componentInstance.componentUid + '/inputs') + .map((res: Response) => { + return CommonUtils.initInputs(res.json()); + }) + } + + updateInstanceProperty(component: Component, componentInstanceId: string, property: PropertyBEModel): Observable<PropertyBEModel> { + + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/property', property) + .map((res: Response) => { + return new PropertyBEModel(res.json()); + }) + } + + updateInstanceInput(component: Component, componentInstanceId: string, input: PropertyBEModel): Observable<PropertyBEModel> { + + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/resourceInstance/' + componentInstanceId + '/input', input) + .map((res: Response) => { + return new PropertyBEModel(res.json()); + }) + } + + +} diff --git a/catalog-ui/src/app/ng2/services/component-services/component.service.ts b/catalog-ui/src/app/ng2/services/component-services/component.service.ts new file mode 100644 index 0000000000..3fa9fde40c --- /dev/null +++ b/catalog-ui/src/app/ng2/services/component-services/component.service.ts @@ -0,0 +1,149 @@ +import {Injectable, Query} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/toPromise'; +import {Response, URLSearchParams} from '@angular/http'; +import { Component, PropertyBEModel, InstancePropertiesAPIMap, FilterPropertiesAssignmentData} from "app/models"; +import {downgradeInjectable} from '@angular/upgrade/static'; +import {HttpService} from "../http.service"; +import {COMPONENT_FIELDS} from "app/utils"; +import {ComponentGenericResponse} from "../responses/component-generic-response"; +import {sdc2Config} from "../../../../main"; +import {InstanceBePropertiesMap} from "../../../models/properties-inputs/property-fe-map"; +import {API_QUERY_PARAMS} from "app/utils"; +import {ComponentType, ServerTypeUrl} from "../../../utils/constants"; + +declare var angular:angular.IAngularStatic; + +@Injectable() +export class ComponentServiceNg2 { + + protected baseUrl; + + constructor(private http:HttpService) { + this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root; + } + + private getComponentDataByFieldsName(componentType:string, componentId: string, fields:Array<string>):Observable<ComponentGenericResponse> { + + let params:URLSearchParams = new URLSearchParams(); + _.forEach(fields, (field:string):void => { + params.append(API_QUERY_PARAMS.INCLUDE, field); + }); + + return this.http.get(this.baseUrl + this.getServerTypeUrl(componentType) + componentId + '/filteredDataByParams', {search: params}) + .map((res:Response) => { + return new ComponentGenericResponse().deserialize(res.json()); + }).do(error => console.log('server data:', error)); + } + + private getServerTypeUrl = (componentType:string):string => { + switch (componentType) { + case ComponentType.PRODUCT: + return ServerTypeUrl.PRODUCTS; + case ComponentType.SERVICE: + return ServerTypeUrl.SERVICES; + default: + return ServerTypeUrl.RESOURCES; + } + } + + getComponentMetadata(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_METADATA]); + } + + getComponentInstanceAttributesAndProperties(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_PROPERTIES, COMPONENT_FIELDS.COMPONENT_INSTANCES_ATTRIBUTES]); + } + + getComponentAttributes(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_ATTRIBUTES]); + } + + getComponentInstancesAndRelation(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_RELATION, COMPONENT_FIELDS.COMPONENT_INSTANCES]); + } + + getComponentResourceInstances(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES]); + } + + getComponentInputs(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INPUTS]); + } + + getComponentDeploymentArtifacts(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_DEPLOYMENT_ARTIFACTS]); + } + + getComponentInformationalArtifacts(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INFORMATIONAL_ARTIFACTS]); + } + + getComponentInformationalArtifactsAndInstances(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INFORMATIONAL_ARTIFACTS, COMPONENT_FIELDS.COMPONENT_INSTANCES]); + } + + getComponentToscaArtifacts(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_TOSCA_ARTIFACTS]); + } + + getComponentProperties(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_PROPERTIES]); + } + + getCapabilitiesAndRequirements(componentType: string, componentId:string):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(componentType, componentId, [COMPONENT_FIELDS.COMPONENT_REQUIREMENTS, COMPONENT_FIELDS.COMPONENT_CAPABILITIES]); + } + + getDeploymentGraphData(component:Component):Observable<ComponentGenericResponse> { + return this.getComponentDataByFieldsName(component.componentType, component.uniqueId, [COMPONENT_FIELDS.COMPONENT_INSTANCES_RELATION, COMPONENT_FIELDS.COMPONENT_INSTANCES, COMPONENT_FIELDS.COMPONENT_GROUPS]); + } + + createInput(component:Component, inputsToCreate:InstancePropertiesAPIMap):Observable<any> { + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/create/inputs', inputsToCreate) + .map(res => { + return res.json(); + }) + } + + deleteInput(component:Component, input:PropertyBEModel):Observable<PropertyBEModel> { + + return this.http.delete(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/delete/' + input.uniqueId + '/input') + .map((res:Response) => { + return new PropertyBEModel(res.json()); + }) + } + + updateComponentInput(component:Component, input:PropertyBEModel):Observable<PropertyBEModel> { + + return this.http.post(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/update/inputs', input) + .map((res:Response) => { + return new PropertyBEModel(res.json()) + }) + } + + filterComponentInstanceProperties(component: Component, filterData:FilterPropertiesAssignmentData): Observable<InstanceBePropertiesMap> {//instance-property-be-map + let params: URLSearchParams = new URLSearchParams(); + _.forEach(filterData.selectedTypes, (type:string) => { + params.append('resourceType', type); + }); + + return this.http.get(this.baseUrl + component.getTypeUrl() + component.uniqueId + '/filteredproperties/' + filterData.propertyName, {search: params}) + .map((res: Response) => { + return res.json(); + }); + + // return {'ExtVL 0':[{definition: false,name:"network_assignments",password:false,required:true,type:"org.openecomp.datatypes.network.NetworkAssignments",uniqueId:"623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_assignments"}, + // {definition: false,name: "exVL_naming",password: false,required: true,type: "org.openecomp.datatypes.Naming",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.exVL_naming"}, + // {definition: false,name: "network_flows",password: false,required: false,type: "org.openecomp.datatypes.network.NetworkFlows",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_flows"}, + // {definition: false,name: "provider_network",password: false,required: true,type: "org.openecomp.datatypes.network.ProviderNetwork",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.provider_network"}, + // {definition: false,name: "network_homing",password: false,required: true,type: "org.openecomp.datatypes.EcompHoming",uniqueId: "623cca1c-d605-4c9c-9f2b-935ec85ebcf8.network_homing"}], + // 'NetworkCP 0':[{definition: false,description: "identifies MAC address assignments to the CP",name: "mac_requirements",password: false,required: false,type: "org.openecomp.datatypes.network.MacRequirements",uniqueId: "26ec2bfd-b904-46c7-87ed-b32775120f2c.mac_requirements"}], + // 'NetworkCP 1':[{definition: false,description: "identifies MAC address assignments to the CP",name: "mac_requirements",password: false,required: false,type: "org.openecomp.datatypes.network.MacRequirements",uniqueId: "26ec2bfd-b904-46c7-87ed-b32775120f2c.mac_requirements"}]}; + + + } +} + +angular.module('Sdc.Services').factory('ComponentServiceNg2', downgradeInjectable(ComponentServiceNg2)); // This is in order to use the service in angular1 till we finish remove all angular1 code diff --git a/catalog-ui/src/app/ng2/services/component-services/resource.service.ts b/catalog-ui/src/app/ng2/services/component-services/resource.service.ts new file mode 100644 index 0000000000..650f244d38 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/component-services/resource.service.ts @@ -0,0 +1,18 @@ +import { Injectable } from '@angular/core'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/toPromise'; +import { Http, Response, Headers, RequestOptions } from '@angular/http'; + +@Injectable() +export class ResourceServiceNg2 { + + protected baseUrl = ""; + + constructor(private http: Http) { + + } + + + + +} diff --git a/catalog-ui/src/app/ng2/services/component-services/service.service.ts b/catalog-ui/src/app/ng2/services/component-services/service.service.ts new file mode 100644 index 0000000000..b47b64c5c2 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/component-services/service.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/toPromise'; +import { Response } from '@angular/http'; +import {Service} from "app/models"; +import { downgradeInjectable } from '@angular/upgrade/static'; +import {sdc2Config} from "../../../../main"; +import {HttpService} from "../http.service"; + + +@Injectable() +export class ServiceServiceNg2 { + + protected baseUrl = ""; + + constructor(private http: HttpService) { + this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root; + } + + validateConformanceLevel(service: Service): Observable<boolean> { + + return this.http.get(this.baseUrl + service.getTypeUrl() + service.uniqueId + '/conformanceLevelValidation') + .map((res: Response) => { + return res.json(); + }); + } + +} + +angular.module('Sdc.Services').factory('ServiceServiceNg2', downgradeInjectable(ServiceServiceNg2)); // This is in order to use the service in angular1 till we finish remove all angular1 code diff --git a/catalog-ui/src/app/ng2/services/config.service.ts b/catalog-ui/src/app/ng2/services/config.service.ts new file mode 100644 index 0000000000..0ac3b5a397 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/config.service.ts @@ -0,0 +1,51 @@ +/** + * Created by ob0695 on 4/9/2017. + */ + +import { Injectable } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import 'rxjs/add/operator/toPromise'; +import {IAppConfigurtaion, ValidationConfiguration, Validations} from "app/models"; +import {sdc2Config} from './../../../main'; + +declare var __ENV__: string; + +@Injectable() +export class ConfigService { + + private baseUrl; + public configuration: IAppConfigurtaion; + + constructor(private http: Http) { + this.baseUrl = sdc2Config.api.root + sdc2Config.api.component_api_root; + } + + loadValidationConfiguration(): Promise<ValidationConfiguration> { + let url: string = sdc2Config.validationConfigPath; + let promise: Promise<ValidationConfiguration> = this.http.get(url).map((res: Response) => res.json()).toPromise(); + promise.then((validationData: Validations) => { + ValidationConfiguration.validation = validationData; + }).catch((ex) => { + console.error('Error loading validation.json configuration file, using fallback data', ex); + + let fallback:Validations = { + "propertyValue": { + "max": 2500, + "min": 0 + }, + + "validationPatterns": { + "string": "^[\\sa-zA-Z0-9+-]+$", + "comment": "^[\\sa-zA-Z0-9+-_\\{\\}\"]+$", + "integer": "^(([-+]?\\d+)|([-+]?0x[0-9a-fA-F]+))$" + } + }; + + ValidationConfiguration.validation = fallback; + + }); + + return promise; + } + +} diff --git a/catalog-ui/src/app/ng2/services/cookie.service.ts b/catalog-ui/src/app/ng2/services/cookie.service.ts new file mode 100644 index 0000000000..2dc2ac3e6b --- /dev/null +++ b/catalog-ui/src/app/ng2/services/cookie.service.ts @@ -0,0 +1,65 @@ +import { Injectable } from '@angular/core'; +import {IAppConfigurtaion, ICookie} from "../../models/app-config"; +import {sdc2Config} from './../../../main'; + +@Injectable() +export class Cookie2Service { + + private cookie:ICookie; + private cookiePrefix:string; + + constructor() { + this.cookie = sdc2Config.cookie; + + this.cookiePrefix = ''; + let junctionName:string = this.getCookieByName(this.cookie.junctionName); + if ((junctionName !== null) && (junctionName !== '')) { + this.cookiePrefix = this.cookie.prefix + junctionName + '!'; + } + console.log("junctionName:" + junctionName); + } + + private getCookieByName = (cookieName:string):string => { + cookieName += '='; + let cookies:Array<string> = document.cookie.split(';'); + let cookieVal:string = ''; + cookies.forEach((cookie:string) => { + while (cookie.charAt(0) === ' ') { + cookie = cookie.substring(1); + } + if (cookie.indexOf(cookieName) === 0) { + cookieVal = cookie.substring(cookieName.length, cookie.length); + return; + } + }); + return cookieVal; + }; + + public getUserIdSuffix = ():string => { + return this.cookie.userIdSuffix; + }; + + public getUserId = ():string => { + let userIdCookieName:string = this.cookiePrefix + this.cookie.userIdSuffix; + let userId:string = this.getCookieByName(userIdCookieName); + return userId; + }; + + public getFirstName = ():string => { + let firstNameCookieName:string = this.cookiePrefix + this.cookie.userFirstName; + let firstName:string = this.getCookieByName(firstNameCookieName); + return firstName; + }; + + public getLastName = ():string => { + let lastNameCookieName:string = this.cookiePrefix + this.cookie.userLastName; + let lastName:string = this.getCookieByName(lastNameCookieName); + return lastName; + }; + + public getEmail = ():string => { + let emailCookieName:string = this.cookiePrefix + this.cookie.userEmail; + let email:string = this.getCookieByName(emailCookieName); + return email; + } +} diff --git a/catalog-ui/src/app/ng2/services/data-type.service.ts b/catalog-ui/src/app/ng2/services/data-type.service.ts new file mode 100644 index 0000000000..e7ea1a8430 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/data-type.service.ts @@ -0,0 +1,69 @@ +import { Injectable } from '@angular/core'; +import { DataTypeModel, DataTypesMap, PropertyBEModel, PropertyFEModel, DerivedFEProperty, DerivedFEPropertyMap } from "app/models"; +import { DataTypesService } from "app/services/data-types-service"; +import { PROPERTY_DATA, PROPERTY_TYPES } from "app/utils"; + +/** This is a new service for NG2, to eventually replace app/services/data-types-service.ts + * + * This service is a singleton that holds a map of all DataTypes, recieved from server on load. + * It also contains convenience methods to check if a string is a valid dataType, and to retrieve a dataType's properties recursively + */ + +@Injectable() +export class DataTypeService { + private dataTypes: DataTypesMap; + + constructor(private dataTypeService: DataTypesService) { + this.dataTypes = dataTypeService.getAllDataTypes(); //This should eventually be replaced by an NG2 call to the backend instead of utilizing Angular1 downgraded component. + } + + public getDataTypeByTypeName(typeName: string): DataTypeModel { + return this.dataTypes[typeName]; + } +/* + //if the dt derived from simple- return the first parent type, else- return null + public getTypeForDataTypeDerivedFromSimple = (dataTypeName:string):string => { + /////////temporary hack for tosca primitives/////////////////////// + if (!this.dataTypes[dataTypeName]) { + return PROPERTY_TYPES.STRING; + } + /////////////////////////////////////////////////////////////////// + if (this.dataTypes[dataTypeName].derivedFromName == PROPERTY_DATA.ROOT_DATA_TYPE || this.dataTypes[dataTypeName].properties) { + return null; + } + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.dataTypes[dataTypeName].derivedFromName) > -1) { + return this.dataTypes[dataTypeName].derivedFromName + } + return this.getTypeForDataTypeDerivedFromSimple(this.dataTypes[dataTypeName].derivedFromName); + }; + + /** + * The function returns all properties for the DataType passed in, and recurses through parent dataTypes (derivedFrom) to retrieve their properties as well + * @param dataTypeObj + * + public getDataTypePropertiesRecursively(dataTypeObj: DataTypeModel): Array<PropertyBEModel> { + let propertiesArray: Array<PropertyBEModel> = dataTypeObj.properties || []; + if (PROPERTY_DATA.ROOT_DATA_TYPE !== dataTypeObj.derivedFromName) { + propertiesArray = propertiesArray.concat(this.getDataTypePropertiesRecursively(dataTypeObj.derivedFrom)); + } + return propertiesArray; + } +*/ + + public getDerivedDataTypeProperties(dataTypeObj: DataTypeModel, propertiesArray: Array<DerivedFEProperty>, parentName: string) { + //push all child properties to array + if (dataTypeObj.properties) { + dataTypeObj.properties.forEach((derivedProperty) => { + propertiesArray.push(new DerivedFEProperty(derivedProperty, parentName)); + let derivedDataTypeObj: DataTypeModel = this.getDataTypeByTypeName(derivedProperty.type); + this.getDerivedDataTypeProperties(derivedDataTypeObj, propertiesArray, parentName + "#" + derivedProperty.name); + }); + } + //recurse parent (derivedFrom), in case one of parents contains properties + if (PROPERTY_DATA.ROOT_DATA_TYPE !== dataTypeObj.derivedFrom.name) { + this.getDerivedDataTypeProperties(dataTypeObj.derivedFrom, propertiesArray, parentName); + } + } + +} + diff --git a/catalog-ui/src/app/ng2/services/http.service.ts b/catalog-ui/src/app/ng2/services/http.service.ts new file mode 100644 index 0000000000..92e8ced142 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/http.service.ts @@ -0,0 +1,73 @@ +import {Injectable} from '@angular/core'; +import {Http, XHRBackend, RequestOptions, Request, RequestOptionsArgs, Response, Headers} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {UUID} from 'angular2-uuid'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/catch'; +import {Dictionary} from "../../utils/dictionary/dictionary"; +import {SharingService, CookieService} from "app/services"; +import {sdc2Config} from './../../../main'; + +@Injectable() +export class HttpService extends Http { + + constructor(backend:XHRBackend, options:RequestOptions, private sharingService:SharingService, private cookieService: CookieService) { + super(backend, options); + this._defaultOptions.withCredentials = true; + this._defaultOptions.headers.append(cookieService.getUserIdSuffix(), cookieService.getUserId()); + } + + request(request:string|Request, options?:RequestOptionsArgs):Observable<Response> { + /** + * For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header. + * Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header. + */ + if (typeof request === 'string') { // meaning we have to add the token to the options, not in url + if (!options) { + // make option object + options = {headers: new Headers()}; + } + + var uuidValue = this.getUuidValue(request); + if(uuidValue!= ''){ + options.headers['X-ECOMP-ServiceID'] = uuidValue; + + } + options.headers.set('X-ECOMP-RequestID', UUID.UUID()); + + } else { + // we have to add the token to the url object + var uuidValue = this.getUuidValue((<Request>request).url); + if(uuidValue!= ''){ + request.headers.set('X-ECOMP-ServiceID',uuidValue); + + } + request.headers.set('X-ECOMP-RequestID', UUID.UUID()); + } + return super.request(request, options).catch(this.catchAuthError(this)); + } + + private getUuidValue = (url: string) :string => { + let map:Dictionary<string, string> = this.sharingService.getUuidMap(); + if (map && url.indexOf(sdc2Config.api.root) > 0) { + map.forEach((key:string) => { + if (url.indexOf(key) !== -1) { + return this.sharingService.getUuidValue(key); + } + }); + } + return ''; + } + + private catchAuthError(self:HttpService) { + // we have to pass HttpService's own instance here as `self` + return (res:Response) => { + console.log(res); + if (res.status === 401 || res.status === 403) { + // if not authenticated + console.log(res); + } + return Observable.throw(res); + }; + } +} diff --git a/catalog-ui/src/app/ng2/services/mocks/properties.mock.ts b/catalog-ui/src/app/ng2/services/mocks/properties.mock.ts new file mode 100644 index 0000000000..0ce253e80b --- /dev/null +++ b/catalog-ui/src/app/ng2/services/mocks/properties.mock.ts @@ -0,0 +1,16 @@ +// import { PropertiesResponse } from './../../services/responses/properties.response'; +// +// export const PROPERTIES_RESPONSE: PropertiesResponse = { +// "status":"ok", +// "errorcode":0, +// "properties": [ +// {"name": "name1"}, +// {"name": "name2"} +// ] +// }; + + +export const COMPONENT_INSTANCE_RESPONSE: any = [{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.724ef51f-7595-4336-a8ef-b144e1c937da.contrailv2vlansubinterface5","name":"CP2","normalizedName":"cp2","componentUid":"724ef51f-7595-4336-a8ef-b144e1c937da","creationTime":1489586037851,"modificationTime":1489586037851,"posX":"549","posY":"531","propertyValueCounter":1,"inputValueCounter":1,"originType":"CP","customizationUUID":"0222925a-06c6-48ca-8573-13ba3b650539"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.8ac5a229-60d8-4d7f-8e0f-b630da55c3ae.ldsa_os27","name":"VF22","normalizedName":"vf22","componentUid":"8ac5a229-60d8-4d7f-8e0f-b630da55c3ae","creationTime":1489590640842,"modificationTime":1489590640842,"posX":"644","posY":"359","propertyValueCounter":1,"inputValueCounter":1,"originType":"VF","customizationUUID":"fb34e6a1-f0cc-42e3-853f-178fb122d670"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.00ac92c4-a0c5-4567-aefb-f2b7f3fecba9.vl4","name":"VL1","normalizedName":"vl1","componentUid":"00ac92c4-a0c5-4567-aefb-f2b7f3fecba9","creationTime":1489586006630,"modificationTime":1489586006630,"posX":"486","posY":"530","propertyValueCounter":1,"inputValueCounter":1,"originType":"VL","customizationUUID":"8d156a97-38ca-4637-a6a6-9268dd708431"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.39bf293d-2aa9-4596-b85d-a6fdef18aadc.newvf428","name":"VF11","normalizedName":"vf11","componentUid":"39bf293d-2aa9-4596-b85d-a6fdef18aadc","creationTime":1489590742501,"modificationTime":1489590742501,"posX":"350","posY":"76","propertyValueCounter":1,"inputValueCounter":1,"originType":"VF","customizationUUID":"253f646d-87d0-4b84-bc20-20343b6e28a2"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.f8f30484-5761-4de8-9de8-12f288ee0a54.contrailport7","name":"CP1","normalizedName":"cp1","componentUid":"f8f30484-5761-4de8-9de8-12f288ee0a54","creationTime":1489587207447,"modificationTime":1489587207447,"posX":"418","posY":"531","propertyValueCounter":1,"inputValueCounter":1,"originType":"CP","customizationUUID":"206b4ffa-e520-496a-b57b-0c103eff8c17"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.16022d8c-80cf-46e5-a730-5b4f634ea905.extcp38","name":"ExtCP 38","normalizedName":"extcp38","componentUid":"16022d8c-80cf-46e5-a730-5b4f634ea905","creationTime":1489654844116,"modificationTime":1489654844116,"posX":"473","posY":"419","propertyValueCounter":5,"inputValueCounter":1,"originType":"CP","customizationUUID":"21ebc94a-65b9-463e-b696-07cea08f789a"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.f8f30484-5761-4de8-9de8-12f288ee0a54.contrailport44","name":"ContrailPort 44","normalizedName":"contrailport44","componentUid":"f8f30484-5761-4de8-9de8-12f288ee0a54","creationTime":1489939897435,"modificationTime":1489939897435,"posX":"480","posY":"265","propertyValueCounter":1,"inputValueCounter":1,"originType":"CP","customizationUUID":"607e5819-fa19-4aac-97f6-04f092493a02"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.8ac5a229-60d8-4d7f-8e0f-b630da55c3ae.ldsa_os6","name":"VF2","normalizedName":"vf2","componentUid":"8ac5a229-60d8-4d7f-8e0f-b630da55c3ae","creationTime":1489586613957,"modificationTime":1489586613957,"posX":"638","posY":"531","propertyValueCounter":1,"inputValueCounter":1,"originType":"VF","customizationUUID":"12501356-44cc-427b-8749-c114d3434271"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.8ac5a229-60d8-4d7f-8e0f-b630da55c3ae.ldsa_os8","name":"VF1","normalizedName":"vf1","componentUid":"8ac5a229-60d8-4d7f-8e0f-b630da55c3ae","creationTime":1489587393612,"modificationTime":1489587393612,"posX":"334","posY":"529","propertyValueCounter":1,"inputValueCounter":1,"originType":"VF","customizationUUID":"cbca1972-e64c-4119-a430-ec90aa1397a7"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.8ac5a229-60d8-4d7f-8e0f-b630da55c3ae.ldsa_os32","name":"VF12","normalizedName":"vf12","componentUid":"8ac5a229-60d8-4d7f-8e0f-b630da55c3ae","creationTime":1489591429630,"modificationTime":1489591429630,"posX":"367","posY":"269","propertyValueCounter":1,"inputValueCounter":1,"originType":"VF","customizationUUID":"ac9c77c1-e84d-4967-9ea2-d929b56d10a8"}]; +export const COMPONENT_INPUT_RESPONSE: any = [{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.extcp38_mac_requirements_mac_range_plan","type":"string","required":true,"definition":false,"description":"reference to a MAC address range plan","password":false,"name":"extcp38_mac_requirements_mac_range_plan","parentUniqueId":"23b78e64-1734-4898-889d-eab9eba50019"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.extcp38_order","type":"integer","required":true,"definition":false,"description":"The order of the CP on the compute instance (e.g. eth2).","schema":{"property":{"definition":true,"password":false}},"password":false,"name":"extcp38_order","parentUniqueId":"23b78e64-1734-4898-889d-eab9eba50019"},{"uniqueId":"23b78e64-1734-4898-889d-eab9eba50019.extcp38_network_role_tag","type":"string","required":true,"definition":false,"description":"Must correlate to the set of defined “network-role” tag identifiers from the associated HEAT template","schema":{"property":{"definition":true,"password":false}},"password":false,"name":"extcp38_network_role_tag","parentUniqueId":"23b78e64-1734-4898-889d-eab9eba50019"}]; +export const COMPONENT_PROPERTIES_RESPONSE: any =[{"schema":{"property":{"password":false,"definition":false}},"password":false,"parentUniqueId":"b80765f0-ef2b-43b1-b658-04e13970b5cf","defaultValue":"{\"naming_policy\":\"ggg\",\"ecomp_generated_naming\":false,\"supplemental_data\":{\"fff\":\"44\",\"uuu\":\"56\"}}","name":"inner-map-1","definition":false,"type":"org.openecomp.datatypes.EcompNaming","uniqueId":"property.b80765f0-ef2b-43b1-b658-04e13970b5cf.inner-map-1","required":false},{"schema":{"property":{"password":false,"definition":false}},"password":false,"parentUniqueId":"b80765f0-ef2b-43b1-b658-04e13970b5cf","defaultValue":"{\"min_subnets_count\":1,\"supplemental_data\":{\"aa\":\"11\",\"bb\":\"22\"},\"cidr_mask\":23,\"dhcp_enabled\":false,\"ip_version\":3}","name":"inner-simple-map","definition":false,"type":"org.openecomp.datatypes.network.IPv4SubnetAssignments","uniqueId":"property.b80765f0-ef2b-43b1-b658-04e13970b5cf.inner-simple-map","required":false},{"schema":{"property":{"password":false,"definition":false,"type":"org.openecomp.datatypes.heat.network.AddressPair"}},"password":false,"parentUniqueId":"b80765f0-ef2b-43b1-b658-04e13970b5cf","defaultValue":"{\"aaa\":{\"mac_address\":\"34\",\"ip_address\":\"56\"},\"bbb\":{\"mac_address\":\"sddf\",\"ip_address\":\"dfdg\"}}","name":"data-type-map","definition":false,"type":"map","uniqueId":"property.b80765f0-ef2b-43b1-b658-04e13970b5cf.data-type-map","required":false},{"schema":{"property":{"password":false,"definition":false,"type":"string"}},"password":false,"parentUniqueId":"b80765f0-ef2b-43b1-b658-04e13970b5cf","defaultValue":"{\"www\":\"dfsdf\",\"aaaa\":\"ert\"}","name":"simple-map","definition":false,"type":"map","uniqueId":"property.b80765f0-ef2b-43b1-b658-04e13970b5cf.simple-map","required":false}]; + diff --git a/catalog-ui/src/app/ng2/services/posts.service.ts b/catalog-ui/src/app/ng2/services/posts.service.ts new file mode 100644 index 0000000000..dbfd44f219 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/posts.service.ts @@ -0,0 +1,54 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/toPromise'; +import 'rxjs/Rx'; +import {Response, Headers, RequestOptions, Http} from '@angular/http'; +import { COMPONENT_INSTANCE_RESPONSE,COMPONENT_INPUT_RESPONSE,COMPONENT_PROPERTIES_RESPONSE } from './mocks/properties.mock'; +import { HttpService } from './http.service'; +import { sdc2Config } from './../../../main'; +import {IAppConfigurtaion} from "../../models/app-config"; + +@Injectable() +export class PostsService { + + private base; + + constructor(private http: HttpService) { + this.base = sdc2Config.api.root; + } + + getAppVersion(): Observable<JSON> { + return this.http + .get(this.base + sdc2Config.api.GET_SDC_Version) + .map((res: Response) => res.json()); + } + + // getProperties(id:string): Observable<any> { + // return this.http + // .get(this.base + sdc2Config.api.GET_SDC_Version) + // .map((res: Response) => res.json()); + // } + + getProperties(): Observable<any> { + return Observable.create(observer => { + observer.next(COMPONENT_PROPERTIES_RESPONSE); + observer.complete(); + }); + } + + getInstance(): Observable<any> { + return Observable.create(observer => { + observer.next(COMPONENT_INSTANCE_RESPONSE); + observer.complete(); + }); + } + + getInputs(): Observable<any> { + return Observable.create(observer => { + observer.next(COMPONENT_INPUT_RESPONSE); + observer.complete(); + }); + } + +} diff --git a/catalog-ui/src/app/ng2/services/properties.service.ts b/catalog-ui/src/app/ng2/services/properties.service.ts new file mode 100644 index 0000000000..638e537cd1 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/properties.service.ts @@ -0,0 +1,249 @@ +import { Injectable } from '@angular/core'; +import { DataTypeModel, PropertyFEModel, PropertyBEModel, SchemaProperty, DerivedFEProperty, DerivedFEPropertyMap, DerivedPropertyType, InputFEModel} from "app/models"; +import { DataTypeService } from "./data-type.service"; +import { PROPERTY_TYPES } from "app/utils"; +import { ContentAfterLastDotPipe } from "../pipes/contentAfterLastDot.pipe"; +import { UUID } from "angular2-uuid"; + +@Injectable() +export class PropertiesService { + + constructor(private dataTypeService:DataTypeService, private contentAfterLastDotPipe:ContentAfterLastDotPipe) { + } + + public getParentPropertyFEModelFromPath = (properties:Array<PropertyFEModel>, path:string) => { + let parent:PropertyFEModel = _.find(properties, (property:PropertyFEModel):boolean=>{ + return property.name === path.substring(0, path.indexOf('#')); + }); + return parent; + } + + //undo disabling of parent and child props= + public undoDisableRelatedProperties = (property: PropertyFEModel, childPath?: string): void => { + property.isDisabled = false; + if (!childPath) { + property.isSelected = false; + property.flattenedChildren && property.flattenedChildren.map(child => child.isDisabled = false); + } else { //QND - unselect everything and then re-do the disabling of declared props. TODO: put a flag on propertyFEModel instead to indicate who's causing them to be disabled instead + property.flattenedChildren.filter(child => child.isDisabled && !child.isDeclared).map(child => child.isDisabled = false); + property.flattenedChildren.filter(child => child.isDeclared || child.isSelected).forEach((childProp) => { //handle brothers who are selected - redo their disabled relatives as well + this.disableRelatedProperties(property, childProp.propertiesName); + }); + } + } + + //disable parents and children of prop + public disableRelatedProperties = (property:PropertyFEModel, childPath?: string): void => { + if (!childPath) { //selecting the parent property + property.isSelected = true; + property.flattenedChildren && property.flattenedChildren.map(child => { child.isSelected = false; child.isDisabled = true; }); + } else { + property.isSelected = false; + property.isDisabled = true; + property.flattenedChildren.filter((childProp: DerivedFEProperty) => { + return (childProp.propertiesName.indexOf(childPath + "#") > -1 //is child of prop to disable + || childPath.indexOf(childProp.propertiesName + "#") > -1); //is parent of prop to disable + }).map((child: DerivedFEProperty) => { child.isSelected = false; child.isDisabled = true; }); + } + } + + public getCheckedProperties = (properties:Array<PropertyFEModel>): Array<PropertyBEModel> => { + let selectedProps: Array<PropertyBEModel> = []; + properties.forEach(prop => { + if (prop.isSelected && !prop.isDeclared && !prop.isDisabled) { + selectedProps.push(new PropertyBEModel(prop)); + } else if(prop.flattenedChildren) { + prop.flattenedChildren.forEach((child) => { + if (child.isSelected && !child.isDeclared && !child.isDisabled) { + let childProp = new PropertyBEModel(prop, child); //create it from the parent + selectedProps.push(childProp); + } + }) + } + }); + return selectedProps; + } + + /** + * Build hirarchy structure for the tree when user selects on table row. + * First create Array<SimpleFlatProperty> and insert also the parent (PropertyFEModel) to this array. + * The Array is flat and contains SimpleFlatProperty that has parentName and uniqueId. + * Now we build hirarchy from this Array (that includes childrens) and return it for the tree + * + * @argument property: PropertyFEModel - property contains flattenedChildren array of DerivedFEProperty + * @returns Array<SimpleFlatProperty> - containing childrens Array<SimpleFlatProperty>, augmantin childrens to SimpleFlatProperty. + */ + public getSimplePropertiesTree(property: PropertyFEModel, instanceName:string):Array<SimpleFlatProperty> { + // Build Array of SimpleFlatProperty before unflatten function + let flattenProperties:Array<SimpleFlatProperty> = []; + flattenProperties.push(new SimpleFlatProperty(property.uniqueId, property.name, property.name, '', instanceName)); // Push the root property + _.each(property.flattenedChildren, (child:DerivedFEProperty):void => { + flattenProperties.push(new SimpleFlatProperty(child.uniqueId, child.propertiesName, child.name, child.parentName, instanceName)); + }); + + let tree = this.unflatten(flattenProperties, '', []); + return tree[0].childrens; // Return the childrens without the root. + } + + /** + * Unflatten Array<SimpleFlatProperty> and build hirarchy. + * The result will be Array<SimpleFlatProperty> that augmantin with childrens for each SimpleFlatProperty. + */ + private unflatten( array:Array<SimpleFlatProperty>, parent:any, tree?:any ):any { + tree = typeof tree!=='undefined' ? tree : []; + parent = typeof parent!=='undefined' && parent!=='' ? parent : { path: '' }; + + var childrens = _.filter( array, (child:SimpleFlatProperty):boolean => { + return child.parentName == parent.path; + }); + + if( !_.isEmpty( childrens ) ){ + if( parent.path == '' ){ + tree = childrens; + } else { + parent['childrens'] = childrens; + } + _.each( childrens, ( child ):void => { + this.unflatten( array, child ); + }); + } + return tree; + } + + // TODO: To remove + // public convertPropertiesToFEAndInitialize(properties: Array<PropertyBEModel>): Array<PropertyFEModel> { + // let props:Array<PropertyFEModel> = []; + // _.forEach(properties, (property: PropertyFEModel, index: number) => { + // props[index] = new PropertyFEModel(property); + // this.initValueObjectRef(props[index]); + // if (props[index].isDataType || + // ((props[index].type === PROPERTY_TYPES.MAP || props[index].type === PROPERTY_TYPES.LIST) && props[index].schema.property.isDataType)) { + // props[index].valueObjectRef = props[index].valueObjectRef || {}; + // let defaultValueObject:any = props[index].defaultValue ? JSON.parse(props[index].defaultValue): null; + // this.createPropertiesTreeForProp(props[index], true, defaultValueObject); + // } + // }); + // return props; + // } + + + /** + * Converts a property's map values to properties and adds them to property.childrenProperties + * @param property - property to add children to + * @param onlyFirstLevel - recursively retrieve properties for each dataType? + */ + //TODO: To remove + // public createPropertyNodesForMapOfDataTypes(property: PropertyFEModel, onlyFirstLevel:boolean):void { + // property.childrenProperties = []; + // angular.forEach(property.valueObjectRef,function(itemInMap:any, keyInMap:string){ + // let newProperty: PropertyFEModel = new PropertyFEModel(keyInMap, + // property.schema.property.type, + // UUID.UUID(), + // property, + // property.valueObjectRef[keyInMap]); + // !onlyFirstLevel && this.createPropertiesTreeForProp(newProperty); + // property.childrenProperties.push(newProperty); + // },this); + // } + + + /** + * Converts a property's list values to properties and adds them to property.childrenProperties + * @param property - property to add children to + * @param onlyFirstLevel - recursively retrieve properties for each dataType? + */ + //TODO: To remove + // public createPropertyNodesForListOfDataTypes(property: PropertyFEModel, onlyFirstLevel:boolean):void { + // property.childrenProperties = []; + // property.valueObjectRef.forEach((itemInList:any, index:number):void =>{ + // let newProperty: PropertyFEModel = new PropertyFEModel(this.contentAfterLastDotPipe.transform(property.schema.property.type), + // property.schema.property.type, + // UUID.UUID(), + // property, + // property.valueObjectRef[index]); + // !onlyFirstLevel && this.createPropertiesTreeForProp(newProperty); + // property.childrenProperties.push(newProperty); + // }); + // } + + // private checkIfPropertyDerivedFromSimpleAndUpdateProp(property:PropertyFEModel | SchemaProperty): boolean{ + // property.derivedFromSimpleTypeName = this.dataTypeService.getTypeForDataTypeDerivedFromSimple(property.type); + // if(property.derivedFromSimpleTypeName){ + // property.isSimpleType = true; + // property.isDataType = false; + // } + // return property.isSimpleType; + // } + + // TODO: Remove + public createPropertiesTreeForProp(property: PropertyFEModel, onlyFirstLevel?: boolean, defaultValueObj?: any): void { + } + + public getPropertyFEModelFromDerivedPropertyUniqueId(properties: Array<PropertyFEModel>, uniqueId: string): PropertyFEModel { + // _.each(properties, (property):void => { + // property.flattenedChildren + + // }); + + // let rootProperty = _.find(properties, (property):boolean => { return property.uniqueId === uniqueId; }); + // if + return null; + } + + /** + * Utilizes the dataTypeService to retrieve children properties from dataTypes recursively. + * @param property + * @param onlyFirstLevel + */ + // TODO: To remove + // public createPropertiesTreeForProp(property: PropertyFEModel, onlyFirstLevel?:boolean, defaultValueObj?:any ):void{ + // if (property.isDataType && !this.checkIfPropertyDerivedFromSimpleAndUpdateProp(property)){ + // let dataType: DataTypeModel = this.dataTypeService.getDataTypeByTypeName(property.type); + // property.childrenProperties = []; + // let childrenProperties = this.dataTypeService.getDataTypePropertiesRecursively(dataType); + // childrenProperties.forEach((childProperty: PropertyBEModel):void => { + // let childDataTypePropertyObj: PropertyFEModel = new PropertyFEModel(childProperty.name, childProperty.type,UUID.UUID(),property, {}, childProperty.schema); + // //init empty object in valueObjectRef[childProperty.name] because this property's children should has ref to this obj. + // if(!property.valueObjectRef[childDataTypePropertyObj.name]){ + // if ((childDataTypePropertyObj.isDataType && !this.checkIfPropertyDerivedFromSimpleAndUpdateProp(childDataTypePropertyObj)) + // || childDataTypePropertyObj.type === PROPERTY_TYPES.MAP){ + // property.valueObjectRef[childDataTypePropertyObj.name] = {}; + // }else if(childDataTypePropertyObj.type === PROPERTY_TYPES.LIST){ + // property.valueObjectRef[childDataTypePropertyObj.name] = []; + // } + // } + // childDataTypePropertyObj.valueObjectRef = property.valueObjectRef[childDataTypePropertyObj.name]; + // property.valueObjectRef[childDataTypePropertyObj.name] = property.valueObjectRef[childProperty.name] || childDataTypePropertyObj.defaultValue; + // if( !childDataTypePropertyObj.isDataType && defaultValueObj ){//init property default value + // childDataTypePropertyObj.defaultValue = JSON.stringify(defaultValueObj[childDataTypePropertyObj.name]); + // } + // property.childrenProperties.push(childDataTypePropertyObj); + // !onlyFirstLevel && this.createPropertiesTreeForProp(childDataTypePropertyObj, false, (defaultValueObj ? defaultValueObj[childDataTypePropertyObj.name] : null)); + // }); + // } else if (property.type == PROPERTY_TYPES.MAP && property.schema.property.isDataType && !this.checkIfPropertyDerivedFromSimpleAndUpdateProp(property.schema.property)){ + // if( property.valueObjectRef && !_.isEmpty(property.valueObjectRef)){ + // this.createPropertyNodesForMapOfDataTypes(property, onlyFirstLevel); + // } + // } else if (property.type == PROPERTY_TYPES.LIST && property.schema.property.isDataType && !this.checkIfPropertyDerivedFromSimpleAndUpdateProp(property.schema.property)){ + // if( property.valueObjectRef && property.valueObjectRef.length){ + // this.createPropertyNodesForListOfDataTypes(property, onlyFirstLevel); + // } + // } + // } +} + +export class SimpleFlatProperty { + uniqueId:string; + path:string; + name:string; + parentName:string; + instanceName:string; + + constructor(uniqueId?:string, path?:string, name?: string, parentName?:string, instanceName?:string) { + this.uniqueId = uniqueId; + this.path = path; + this.name = name; + this.parentName = parentName; + this.instanceName = instanceName; + } +} diff --git a/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts new file mode 100644 index 0000000000..7dcd95d712 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/responses/component-generic-response.ts @@ -0,0 +1,77 @@ +/** + * Created by ob0695 on 4/18/2017. + */ + +import { ArtifactGroupModel, PropertyModel, PropertiesGroup, AttributeModel, AttributesGroup, ComponentInstance, + InputModel, Module, ComponentMetadata, RelationshipModel, RequirementsGroup, CapabilitiesGroup,InputFEModel} from "app/models"; +import {CommonUtils} from "app/utils"; +import {Serializable} from "../utils/serializable"; +import {PropertyBEModel} from "../../../models/properties-inputs/property-be-model"; + +export class ComponentGenericResponse implements Serializable<ComponentGenericResponse> { + + public metadata: ComponentMetadata; + public deploymentArtifacts:ArtifactGroupModel; + public artifacts:ArtifactGroupModel; + public toscaArtifacts:ArtifactGroupModel; + public componentInstancesProperties:PropertiesGroup; + public componentInstancesAttributes:AttributesGroup; + public componentInstancesRelations:Array<RelationshipModel>; + public componentInstances:Array<ComponentInstance>; + public inputs:Array<PropertyBEModel>; + public capabilities:CapabilitiesGroup; + public requirements:RequirementsGroup; + public properties:Array<PropertyModel>; + public attributes:Array<AttributeModel>; + public groups:Array<Module>; + public interfaces:any; + public additionalInformation:any; + public derivedList:Array<any>; + + deserialize (response): ComponentGenericResponse { + + if(response.componentInstancesProperties) { + this.componentInstancesProperties = new PropertiesGroup(response.componentInstancesProperties); + } + if(response.componentInstancesAttributes) { + this.componentInstancesAttributes = new AttributesGroup(response.componentInstancesAttributes); + } + if(response.componentInstances) { + this.componentInstances = CommonUtils.initComponentInstances(response.componentInstances); + } + if(response.componentInstancesRelations) { + this.componentInstancesRelations = CommonUtils.initComponentInstanceRelations(response.componentInstancesRelations); + } + if(response.deploymentArtifacts) { + this.deploymentArtifacts = new ArtifactGroupModel(response.deploymentArtifacts); + } + if(response.inputs) { + this.inputs = CommonUtils.initInputs(response.inputs); + } + if(response.attributes) { + this.attributes = CommonUtils.initAttributes(response.attributes); + } + if(response.artifacts) { + this.artifacts = new ArtifactGroupModel(response.artifacts); + } + if(response.properties) { + this.properties = CommonUtils.initProperties(response.properties); + } + if(response.capabilities) { + this.capabilities = new CapabilitiesGroup(response.capabilities); + } + if(response.requirements) { + this.requirements = new RequirementsGroup(response.requirements); + } + if(response.toscaArtifacts) { + this.toscaArtifacts = new ArtifactGroupModel(response.toscaArtifacts); + } + if(response.metadata) { + this.metadata = new ComponentMetadata().deserialize(response.metadata); + } + if(response.groups) { + this.groups = CommonUtils.initModules(response.groups); + } + return this; + } +} diff --git a/catalog-ui/src/app/ng2/services/responses/properties.response.ts b/catalog-ui/src/app/ng2/services/responses/properties.response.ts new file mode 100644 index 0000000000..a3d82500eb --- /dev/null +++ b/catalog-ui/src/app/ng2/services/responses/properties.response.ts @@ -0,0 +1,7 @@ +export class PropertiesResponse { + properties: Array<Property>; +} + +class Property { + name: string +} diff --git a/catalog-ui/src/app/ng2/services/utils/serializable.ts b/catalog-ui/src/app/ng2/services/utils/serializable.ts new file mode 100644 index 0000000000..f8be120613 --- /dev/null +++ b/catalog-ui/src/app/ng2/services/utils/serializable.ts @@ -0,0 +1,6 @@ +/** + * Created by ob0695 on 4/26/2017. + */ +export interface Serializable<T> { + deserialize(input: Object): T; +} diff --git a/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.html b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.html new file mode 100644 index 0000000000..efe830d6e0 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.html @@ -0,0 +1,8 @@ +<div class="checkbox-container {{checkboxStyle}}"> + <div class="checkbox-animation" [@checkEffect]="checked"></div> + <label class="checkbox-label" > + <input type="checkbox" class="checkbox-hidden" [ngModel]="checked" (ngModelChange)="toggleState($event)" [disabled]="disabled" /> + <div class="checkbox-icon"></div> + <span *ngIf="label" class="checkbox-label-content">{{label}}</span> + </label> +</div>
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.less b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.less new file mode 100644 index 0000000000..7ed8a22194 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.less @@ -0,0 +1,64 @@ + @import '../../../../assets/styles/tlv-sprite'; + +.checkbox-container { + display:inline-block; + position:relative; + text-align: left; + height: 20px; + + + .checkbox-icon { + display: inline-block; + } + + .checkbox-label { + font-weight: normal; + font-size: inherit; + } + + .checkbox-label-content { + margin-left:2px; + } + + .checkbox-icon::before { + .tlv-sprite; + background-position: -10px -60px; + width: 14px; + height: 14px; + content: ''; + display: inline-block; + margin-right: 0px; + margin-top: -2px; + vertical-align: middle; + } + + input[type=checkbox].checkbox-hidden { + width:0; + height:0; + display:none; + &:checked ~ .checkbox-icon::before{ + background-position: -10px -120px; + } + &[disabled] ~ .checkbox-icon::before { + /* TODO: add disabled styles here */ + background-image: none; + background-color: #EFEFEF; + border-radius: 2px; + border: solid #CCC 1px; + } + } + + .checkbox-animation { + background-color: #009fdb; + position: absolute; + left: 2px; + top: 5px; + width:10px; + height:10px; + border-radius: 50%; + z-index: 1; + pointer-events: none; + opacity:0; + } + +} diff --git a/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.ts b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.ts new file mode 100644 index 0000000000..5a9954c336 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.component.ts @@ -0,0 +1,30 @@ +import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core'; +import { trigger, state, style, transition, animate, keyframes } from '@angular/core'; + +@Component({ + selector: 'checkbox', + templateUrl: './checkbox.component.html', + styleUrls: ['./checkbox.component.less'], + encapsulation: ViewEncapsulation.None, + animations: [ + trigger('checkEffect', [ + state('true', style({ position: 'absolute', left: '2px', top: '5px', width: '10px', height: '10px', display: 'none', opacity: '.5' })), + state('false', style({ left: '-18px', top: '-15px', height: '50px', width: '50px', opacity: '0' })), + transition('1 => 0', animate('150ms ease-out')), + transition('0 => 1', animate('150ms ease-in')) + ]) + ] +}) +export class CheckboxComponent { + + @Input() checkboxStyle: string; + @Input() label: string; + @Input() checked: boolean; + @Input() disabled: boolean; + @Output() checkedChange: EventEmitter<any> = new EventEmitter<any>(); + + toggleState(newValue:boolean) { + this.checkedChange.emit(newValue); + } +} + diff --git a/catalog-ui/src/app/ng2/shared/checkbox/checkbox.module.ts b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.module.ts new file mode 100644 index 0000000000..116aa7f025 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/checkbox/checkbox.module.ts @@ -0,0 +1,28 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { BrowserModule } from '@angular/platform-browser'; +import { CheckboxComponent } from './checkbox.component'; + + +@NgModule({ + imports: [CommonModule, BrowserModule, FormsModule], + declarations: [CheckboxComponent], + bootstrap: [], + exports: [CheckboxComponent] +}) +export class CheckboxModule { } + +/** README: **/ + +/** USAGE Example: + *In page.module.ts: import CheckboxModule + *In HTML: + *<checkbox checkboxStyle="class-goes-here" [label]="'Text goes here'" [disabled]="variable-goes-here" [(checked)]="default-or-variable-goes-here" (checkedChange)="change-event-goes-here()"></checkbox> + */ + +/**STYLING: (ViewEncapsulation is set to None to allow styles to be overridden or customized) + * + * To create or override styles: + * Use /deep/ or >>> prefix to override styles via other components stylesheets + */
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar-routes.config.ts b/catalog-ui/src/app/ng2/shared/navbar/navbar-routes.config.ts new file mode 100644 index 0000000000..d8a21e66c8 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar-routes.config.ts @@ -0,0 +1,7 @@ +import { MenuType, RouteInfo } from './navbar.metadata'; + +export const ROUTES: RouteInfo[] = [ + { path: 'page1', title: 'Logo', menuType: MenuType.BRAND }, + { path: 'page1', title: 'Page 1', menuType: MenuType.LEFT }, + { path: 'page2', title: 'Page 2', menuType: MenuType.LEFT } +]; diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar.component.html b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.html new file mode 100644 index 0000000000..d783be4c27 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.html @@ -0,0 +1,23 @@ +<nav class="navbar navbar-dark"> + <div class="clearfix"> + <button (click)="isCollapsed = !isCollapsed" + class="navbar-toggler pull-xs-right hidden-sm-up" type="button" + aria-controls="bd-main-nav" + aria-label="Toggle navigation"> + {{menuIcon}} + </button> + <a (click)="isCollapsed = true" class="navbar-brand hidden-sm-up" [routerLink]="[brandMenu.path]"> + {{brandMenu.title}} + </a> + </div> + <div class="navbar-toggleable-xs navbar-collapse" id="bd-main-nav" [attr.aria-expanded]="!isCollapsed" [ngClass]="{collapse: isCollapsed}"> + <ul class="nav navbar-nav"> + <li (click)="isCollapsed = true" class="nav-item" routerLinkActive="active"> + <a class="navbar-brand hidden-xs-down" [routerLink]="[brandMenu.path]">{{brandMenu.title}}</a> + </li> + <li (click)="isCollapsed = true" *ngFor="let menuItem of menuItems" class="nav-item" routerLinkActive="active" [ngClass]="getMenuItemClasses(menuItem)"> + <a class="nav-item nav-link" [routerLink]="[menuItem.path]" routerLinkActive="active">{{menuItem.title}}</a> + </li> + </ul> + </div> +</nav> diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar.component.less b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.less new file mode 100644 index 0000000000..3e5165b798 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.less @@ -0,0 +1,11 @@ +.active { + color: #ffffff; +} +.navbar-toggler { + border: solid 1px #cccccc; + color: #ff0000; +} +.navbar { + background-color: #0000ff; + border-radius: 0; +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar.component.ts b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.ts new file mode 100644 index 0000000000..b174f9d18d --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar.component.ts @@ -0,0 +1,32 @@ +import {Component, OnInit, ViewEncapsulation} from '@angular/core'; +import { ROUTES } from './navbar-routes.config'; +import { MenuType, RouteInfo } from './navbar.metadata'; + +@Component({ + selector: 'app-navbar', + templateUrl: './navbar.component.html', + styleUrls: [ './navbar.component.less' ], + encapsulation: ViewEncapsulation.None +}) +export class NavbarComponent implements OnInit { + public menuItems: Array<RouteInfo>; + public brandMenu: RouteInfo; + isCollapsed = true; + + constructor() {} + + ngOnInit() { + this.menuItems = ROUTES.filter(menuItem => menuItem.menuType !== MenuType.BRAND); + this.brandMenu = ROUTES.filter(menuItem => menuItem.menuType === MenuType.BRAND)[0]; + } + + public get menuIcon(): string { + return this.isCollapsed ? '☰' : '✖'; + } + + public getMenuItemClasses(menuItem: any) { + return { + 'pull-xs-right': this.isCollapsed && menuItem.menuType === MenuType.RIGHT + }; + } +} diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar.metadata.ts b/catalog-ui/src/app/ng2/shared/navbar/navbar.metadata.ts new file mode 100644 index 0000000000..245d0e6cfe --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar.metadata.ts @@ -0,0 +1,11 @@ +export enum MenuType { + BRAND, + LEFT, + RIGHT +} + +export interface RouteInfo { + path: string; + title: string; + menuType: MenuType; +} diff --git a/catalog-ui/src/app/ng2/shared/navbar/navbar.module.ts b/catalog-ui/src/app/ng2/shared/navbar/navbar.module.ts new file mode 100644 index 0000000000..18120a61fb --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/navbar/navbar.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { NavbarComponent } from "./navbar.component"; + +@NgModule({ + imports: [ + RouterModule, + CommonModule + ], + declarations: [ NavbarComponent ], + exports: [ + NavbarComponent + ] +}) +export class NavbarModule {} diff --git a/catalog-ui/src/app/ng2/shared/shared.module.ts b/catalog-ui/src/app/ng2/shared/shared.module.ts new file mode 100644 index 0000000000..3e59e04441 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/shared.module.ts @@ -0,0 +1,20 @@ +import { NgModule } from '@angular/core'; + +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { NavbarModule } from "./navbar/navbar.module"; + +@NgModule({ + declarations: [ + + ], + imports: [ + CommonModule, + RouterModule, + NavbarModule + ], + exports: [ + ] +}) + +export class SharedModule {} diff --git a/catalog-ui/src/app/ng2/shared/tabs/tab/tab.component.ts b/catalog-ui/src/app/ng2/shared/tabs/tab/tab.component.ts new file mode 100644 index 0000000000..06dcfa0b16 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/tabs/tab/tab.component.ts @@ -0,0 +1,18 @@ +import { Component, Input } from '@angular/core'; +import { ViewEncapsulation } from '@angular/core'; + +@Component({ + selector: 'tab', + template: ` + <div *ngIf="active" class="tab-content"> + <ng-content></ng-content> + </div> + `, + encapsulation: ViewEncapsulation.None +}) +export class Tab { + @Input('tabTitle') title: string; + @Input() active:boolean = false; + @Input() indication?: number; + +}
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/shared/tabs/tabs.component.html b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.html new file mode 100644 index 0000000000..3e263a3862 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.html @@ -0,0 +1,9 @@ +<div class="tabs {{tabStyle}}"> + <div class="tab" *ngFor="let tab of tabs" (click)="selectTab(tab)" [class.active]="tab.active"> + {{tab.title}} + <div class="tab-indication" *ngIf="tab.indication" [@indicatorAnimation]="tab.indication">{{tab.indication}}</div> + </div> +</div> +<div class="tab-content-container"> + <ng-content></ng-content> +</div>
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/shared/tabs/tabs.component.less b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.less new file mode 100644 index 0000000000..aa59428a64 --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.less @@ -0,0 +1,85 @@ +@import '../../../../assets/styles/variables'; + +.tabs { + display:flex; + flex: 0 0 auto; + flex-direction:row; +} + +.tab { + flex: 1 0 auto; + cursor: pointer; + padding: .5em; +} + +.tab-content-container { + flex: 1; + height: 100%; + overflow: hidden; + width:100%; +} + +.tab-content { + height:100%; +} + +/*Tab styles*/ +.tabs{ + &.round-tabs .tab{ + background-color: #f8f8f8; + color: #959595; + border: solid 1px #d2d2d2; + border-bottom:none; + border-left:none; + position:relative; + + &:first-child { + border-top-left-radius: 8px; + border-left:solid 1px #d2d2d2; + } + &:last-child { + border-top-right-radius: 8px; + } + + &.active { + background-color:#009fdb; + color:#e9e9e9; + border-color:#009fdb; + } + + .tab-indication { + position: absolute; + top: -10px; + background-color: #009fdb; + right: 10px; + padding: 2px 0; + border-radius: 15px; + border: solid 1px #d2d2d2; + color:white; + width: 25px; + height: 25px; + text-align: center; + + } + } + + &.simple-tabs .tab { + font-size: 12px; + color: @main_color_n; + + &:after { + display:block; + content: ''; + border-bottom: 2px solid @main_color_a; + transform: scaleX(0); + transition: transform 200ms ease-in-out; + } + + &.active { + color: @main_color_a; + &:after { + transform: scaleX(1); + } + } + } +} diff --git a/catalog-ui/src/app/ng2/shared/tabs/tabs.component.ts b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.ts new file mode 100644 index 0000000000..dc5616c6cb --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/tabs/tabs.component.ts @@ -0,0 +1,58 @@ +import { Component, ContentChildren, QueryList, AfterContentInit, Input, Output, EventEmitter } from '@angular/core'; +import { Tab } from './tab/tab.component'; +import { ViewEncapsulation } from '@angular/core'; +import { trigger, state, style, transition, animate, keyframes } from '@angular/core'; + +@Component({ + selector: 'tabs', + templateUrl: './tabs.component.html', + styleUrls: ['./tabs.component.less'], + encapsulation: ViewEncapsulation.None, + animations: [ + trigger('indicatorAnimation', [ + transition(':enter', [style({ transform: 'translateY(-50%)', opacity: 0 }), animate('250ms', style({ transform: 'translateY(0)', opacity: 1 })) ]), + transition(':leave', [style({ opacity: 1 }), animate('500ms', style({ opacity: 0 })) ]) + ]) + ] +}) +export class Tabs implements AfterContentInit { + + @Input() tabStyle: string; + @Input() hideIndicationOnTabChange?: boolean = false; + @ContentChildren(Tab) tabs: QueryList<Tab>; + @Output() tabChanged: EventEmitter<Tab> = new EventEmitter<Tab>(); + + + ngAfterContentInit() { + //after contentChildren are set, determine active tab. If no active tab set, activate the first one + let activeTabs = this.tabs.filter((tab) => tab.active); + + if (activeTabs.length === 0) { + this.selectTab(this.tabs.first); + } + } + + selectTab(tab: Tab) { + //activate the tab the user clicked. + this.tabs.toArray().forEach(tab => { + tab.active = false; + if (this.hideIndicationOnTabChange && tab.indication) { + tab.indication = null; + } + }); + tab.active = true; + this.tabChanged.emit(tab); + } + + triggerTabChange(tabTitle) { + this.tabs.toArray().forEach(tab => { + tab.active = (tab.title == tabTitle) ? true : false; + }); + } + + setTabIndication(tabTitle:string, indication?:number) { + let selectedTab: Tab = this.tabs.toArray().find(tab => tab.title == tabTitle); + selectedTab.indication = indication || null; + } + +} diff --git a/catalog-ui/src/app/ng2/shared/tabs/tabs.module.ts b/catalog-ui/src/app/ng2/shared/tabs/tabs.module.ts new file mode 100644 index 0000000000..36c7335fde --- /dev/null +++ b/catalog-ui/src/app/ng2/shared/tabs/tabs.module.ts @@ -0,0 +1,35 @@ +import { Component, NgModule } from '@angular/core' +import { BrowserModule } from '@angular/platform-browser' + +import { Tabs } from './tabs.component'; +import { Tab } from './tab/tab.component'; + + +@NgModule({ + imports: [BrowserModule], + declarations: [Tabs, Tab], + bootstrap: [], + exports: [Tabs, Tab] +}) +export class TabModule { } + +/** README: **/ + +/** USAGE Example: + *In page.module.ts: import TabModule + *In HTML: + *<tabs tabStyle="class-goes-here" (tabChanged)="tabChangedEvent($event) [hideIndicationOnTabChange]="optional-boolean"> + * <tab [tabTitle]="'Tab 1'">Content of tab 1</tab> + * <tab tabTitle="Tab 2" >Content of tab 2</tab> + * ... + *</tabs> + */ + +/**STYLING: (ViewEncapsulation is set to None to allow styles to be overridden or customized) + * Existing options: + * tabStyle="round-tabs" will provide generic rounded tab look + * + * To create or override styles: + * Parent div has class ".tabs". Each tab has class ".tab". Active tab has class ".active". + * Use /deep/ or >>> prefix to override styles via other components stylesheets + */
\ No newline at end of file diff --git a/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts b/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts new file mode 100644 index 0000000000..c8c1d9b721 --- /dev/null +++ b/catalog-ui/src/app/ng2/utils/ng1-upgraded-provider.ts @@ -0,0 +1,51 @@ +/** + * Created by rc2122 on 4/6/2017. + */ +import {DataTypesService} from "../../services/data-types-service"; +import ICacheObject = angular.ICacheObject; +import {SharingService} from "../../services/sharing-service"; +import {CookieService} from "../../services/cookie-service"; + +/** Services we need to upgrade from angular1 to angular2 - in the future we need to rewrite them all to angular2 **/ + +export function dataTypesServiceFactory(cacheObj: ICacheObject) { + return cacheObj.get('Sdc.Services.DataTypesService'); +} + +export function sharingServiceFactory(cacheObj: ICacheObject) { + return cacheObj.get('Sdc.Services.SharingService'); +} + +export function cookieServiceFactory(cacheObj: ICacheObject) { + return cacheObj.get('Sdc.Services.CookieService'); +} + +export function stateParamsServiceFactory(cacheObj: ICacheObject) { + return cacheObj.get('$stateParams'); +} + +export const DataTypesServiceProvider = { + provide: DataTypesService, + useFactory: dataTypesServiceFactory, + deps: ['$injector'] +}; + + +export const SharingServiceProvider = { + provide: SharingService, + useFactory: sharingServiceFactory, + deps: ['$injector'] +}; + + +export const CookieServiceProvider = { + provide: CookieService, + useFactory: cookieServiceFactory, + deps: ['$injector'] +}; + +export const StateParamsServiceFactory = { + provide: '$stateParams', + useFactory: stateParamsServiceFactory, + deps: ['$injector'] +}; diff --git a/catalog-ui/src/app/services.ts b/catalog-ui/src/app/services.ts new file mode 100644 index 0000000000..5b4358a90c --- /dev/null +++ b/catalog-ui/src/app/services.ts @@ -0,0 +1,32 @@ +/** + * Created by ob0695 on 2/23/2017. + */ +export * from './services/activity-log-service'; +export * from './services/available-icons-service'; +export * from './services/cache-service'; +export * from './services/configuration-ui-service'; +export * from './services/category-resource-service'; +export * from './services/components/component-service'; +export * from './services/components/product-service'; +export * from './services/components/resource-service'; +export * from './services/components/service-service'; +export * from './services/components/resource-service'; +export * from './services/components/utils/composition-left-palette-service'; +export * from './services/components/resource-service'; +export * from './services/components/resource-service'; +export * from './services/category-resource-service'; +export * from './services/cookie-service'; +export * from './services/data-types-service'; +export * from './services/ecomp-service'; +export * from './services/entity-service'; +export * from './services/event-listener-service'; +export * from './services/header-interceptor'; +export * from './services/loader-service'; +export * from './services/onboarding-service'; +export * from './services/progress-service'; +export * from './services/sdc-version-service'; +export * from './services/sharing-service'; +export * from './services/url-tobase64-service'; +export * from './services/user-resource-service'; +export * from './services/angular-js-bridge-service'; + diff --git a/catalog-ui/src/app/services/activity-log-service.ts b/catalog-ui/src/app/services/activity-log-service.ts new file mode 100644 index 0000000000..565dc9a39c --- /dev/null +++ b/catalog-ui/src/app/services/activity-log-service.ts @@ -0,0 +1,28 @@ +'use strict'; +import {Activity} from "../models/activity"; +import {IAppConfigurtaion, IApi} from "../models/app-config"; + +// Define an interface of the object you want to use, providing it's properties +export interface IActivityLogService { + getActivityLogService(type:string, id:string):ng.IPromise<Array<Activity>>; +} + +export class ActivityLogService implements IActivityLogService { + + + static '$inject' = ['$http', '$q', 'sdcConfig']; + private api:IApi; + + constructor(private $http:ng.IHttpService, private $q:ng.IQService, sdcConfig:IAppConfigurtaion) { + this.api = sdcConfig.api; + } + + getActivityLogService = (type:string, id:string):ng.IPromise<Array<Activity>> => { + let defer = this.$q.defer<any>(); + this.$http.get(this.api.root + this.api.GET_activity_log.replace(':type', type).replace(':id', id)) + .then((activityLog:any) => { + defer.resolve(activityLog.data); + }); + return defer.promise; + } +} diff --git a/catalog-ui/src/app/services/angular-js-bridge-service.ts b/catalog-ui/src/app/services/angular-js-bridge-service.ts new file mode 100644 index 0000000000..1eaea878dd --- /dev/null +++ b/catalog-ui/src/app/services/angular-js-bridge-service.ts @@ -0,0 +1,23 @@ +'use strict'; +import {IAppConfigurtaion} from "../models/app-config"; + +export class AngularJSBridge { + private static _$filter:ng.IFilterService; + private static _sdcConfig:IAppConfigurtaion; + + public static getFilter(filterName:string) { + return AngularJSBridge._$filter(filterName); + } + + public static getAngularConfig() { + return AngularJSBridge._sdcConfig; + } + + + constructor($filter:ng.IFilterService, sdcConfig:IAppConfigurtaion) { + AngularJSBridge._$filter = $filter; + AngularJSBridge._sdcConfig = sdcConfig; + } +} + +AngularJSBridge.$inject = ['$filter', 'sdcConfig'] diff --git a/catalog-ui/src/app/services/available-icons-service.ts b/catalog-ui/src/app/services/available-icons-service.ts new file mode 100644 index 0000000000..ad17b069d6 --- /dev/null +++ b/catalog-ui/src/app/services/available-icons-service.ts @@ -0,0 +1,87 @@ +/** + * Created by obarda on 2/23/2016. + */ +'use strict'; +import {ComponentType} from "../utils/constants"; + +interface IAvailableIconsService { + getIcons(componentType:ComponentType):Array<string>; +} + +export class AvailableIconsService implements IAvailableIconsService { + constructor() { + } + + public getIcons = (componentType:string):Array<string> => { + + let icons:Array<string>; + + switch (componentType) { + case ComponentType.SERVICE: + icons = [ + 'call_controll', + 'mobility', + 'network_l_1-3', + 'network_l_4' + ]; + break; + + case ComponentType.RESOURCE: + icons = [ + 'router', + 'database', + 'network', + 'objectStorage', + 'connector', + 'brocade', + 'cisco', + 'ericsson', + 'tropo', + 'fortinet', + 'att', + 'broadsoft', + 'alcatelLucent', + 'metaswitch', + 'aricent', + 'mySql', + 'oracle', + 'nokia_siemens', + 'juniper', + 'call_controll', + 'borderElement', + 'applicationServer', + 'server', + 'port', + 'loadBalancer', + 'compute', + 'gateway', + 'cp', + 'vl', + 'vfw', + 'firewall' + ]; + break; + + case ComponentType.PRODUCT: + icons = [ + 'vfw', + 'network', + 'security', + 'cloud', + 'setting', + 'orphan', + 'wanx', + 'vrouter', + 'ucpe', + 'mobility' + + ]; + break; + + } + return icons; + } +} + + + diff --git a/catalog-ui/src/app/services/cache-service.ts b/catalog-ui/src/app/services/cache-service.ts new file mode 100644 index 0000000000..9ee08c8478 --- /dev/null +++ b/catalog-ui/src/app/services/cache-service.ts @@ -0,0 +1,34 @@ +'use strict'; +import {Dictionary} from "app/utils"; + +interface ICacheService { + get(key:string):any; + set(key:string, value:any):void; +} + +export class CacheService implements ICacheService { + + private storage:Dictionary<string, any>; + + constructor() { + this.storage = new Dictionary<string, any>(); + }; + + public get = (key:string):any => { + return this.storage.getValue(key); + }; + + public set = (key:string, value:any):void => { + this.storage.setValue(key, value); + }; + + public remove = (key:string):void => { + if (this.storage.containsKey(key)) { + this.storage.remove(key); + } + }; + + public contains = (key:string):boolean => { + return this.storage.containsKey(key); + }; +} diff --git a/catalog-ui/src/app/services/category-resource-service.ts b/catalog-ui/src/app/services/category-resource-service.ts new file mode 100644 index 0000000000..a2e3c61e0a --- /dev/null +++ b/catalog-ui/src/app/services/category-resource-service.ts @@ -0,0 +1,61 @@ +'use strict'; +// import 'angular-resource'; +import {IAppConfigurtaion, IMainCategory, IUserProperties} from "../models"; +import {Categories} from "../models/categories"; + +// Define an interface of the object you want to use, providing it's properties +export interface ICategoryResource extends IUserProperties,ng.resource.IResource<ICategoryResource> { + name:string; + uniqueId:string; + subcategories:Array<ICategoryResource>; + + getAllCategories(params?:Object, success?:Function, error?:Function):Categories; + $saveSubCategory(params?:Object, success?:Function, error?:Function):any; + $deleteSubCategory(params?:Object, success?:Function, error?:Function):any; +} + +// Define your resource, adding the signature of the custom actions +export interface ICategoryResourceClass extends ng.resource.IResourceClass<ICategoryResource> { + getAllCategories(params?:Object, success?:Function, error?:Function):Categories; + saveSubCategory(params?:Object, success?:Function, error?:Function):any; + deleteSubCategory(params?:Object, success?:Function, error?:Function):any; +} + +export class CategoryResourceService { + + public static getResource = ($resource:ng.resource.IResourceService, + sdcConfig:IAppConfigurtaion):ICategoryResourceClass => { + + // Define your custom actions here as IActionDescriptor + let getAllCategoriesAction:ng.resource.IActionDescriptor = { + method: 'GET', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.GET_categories + }; + let saveSubCategory:ng.resource.IActionDescriptor = { + method: 'POST', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.POST_subcategory + }; + let deleteSubCategory:ng.resource.IActionDescriptor = { + method: 'DELETE', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.POST_subcategory + }; + + + let url:string = sdcConfig.api.root + sdcConfig.api.POST_category; + let categoryResource:ICategoryResourceClass = <ICategoryResourceClass>$resource( + url, + {types: '@types', categoryId: '@categoryId'}, + { + getAllCategories: getAllCategoriesAction, + saveSubCategory: saveSubCategory, + deleteSubCategory: deleteSubCategory + } + ); + + return categoryResource; + } +} +CategoryResourceService.getResource.$inject = ['$resource', 'sdcConfig']; diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts new file mode 100644 index 0000000000..1a6b9a8a14 --- /dev/null +++ b/catalog-ui/src/app/services/components/component-service.ts @@ -0,0 +1,755 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance, + AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties} from "app/models"; +import {ComponentInstanceFactory, CommonUtils} from "app/utils"; +import {SharingService} from "../sharing-service"; + +export interface IComponentService { + + getComponent(id:string); + updateComponent(component:Component):ng.IPromise<Component>; + changeLifecycleState(component:Component, state:string, userRemarks:any):ng.IPromise<Component> ; + validateName(newName:string, subtype?:string):ng.IPromise<IValidate>; + createComponent(component:Component):ng.IPromise<Component>; + addOrUpdateArtifact(componentId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + deleteArtifact(componentId:string, artifact:string, artifactLabel):ng.IPromise<ArtifactModel>; + addProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>; + updateProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>; + addAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>; + updateAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>; + deleteProperty(componentId:string, propertyId:string):ng.IPromise<PropertyModel>; + deleteAttribute(componentId:string, attributeId:string):ng.IPromise<AttributeModel>; + changeResourceInstanceVersion(componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance>; + updateInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + addInstanceArtifact(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + deleteInstanceArtifact(componentId:string, instanceId:string, artifact:string, artifactLabel):ng.IPromise<ArtifactModel>; + createComponentInstance(componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>; + updateComponentInstance(componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance>; + updateMultipleComponentInstances(componentId:string, instances:Array<ComponentInstance>):ng.IPromise< Array<ComponentInstance>>; + downloadArtifact(componentId:string, artifactId:string):ng.IPromise<IFileDownload>; + uploadInstanceEnvFile(componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel>; + downloadInstanceArtifact(componentId:string, instanceId:string, artifactId:string):ng.IPromise<IFileDownload>; + deleteComponentInstance(componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance>; + createRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>; + deleteRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>; + getRequirementsCapabilities(componentId:string):ng.IPromise<any>; + updateInstanceProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>; + updateInstanceAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>; + getComponentInstancesFilteredByInputsAndProperties(componentId:string, searchText:string):ng.IPromise<Array<ComponentInstance>> + getComponentInstanceInputs(componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<InputModel>>; + getComponentInputs(componentId:string):ng.IPromise<Array<InputModel>>; + getComponentInstanceInputProperties(componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>>; + getComponentInstanceProperties(componentId:string, instanceId:string):ng.IPromise<Array<PropertyModel>>; + getModuleForDisplay(componentId:string, moduleId:string):ng.IPromise<DisplayModule>; + getComponentInstanceModule(componentId:string, componentInstanceId:string, moduleId:string):ng.IPromise<DisplayModule>; + updateGroupMetadata(componentId:string, group:Module):ng.IPromise<Module>; + getComponentInputInputsAndProperties(serviceId:string, input:string):ng.IPromise<InputsAndProperties>; + createInputsFromInstancesInputs(serviceId:string, instancesInputsMap:InstancesInputsPropertiesMap):ng.IPromise<Array<InputModel>>; + createInputsFromInstancesInputsProperties(resourceId:string, instanceInputsPropertiesMap:InstancesInputsPropertiesMap):ng.IPromise<Array<PropertyModel>>; + deleteComponentInput(serviceId:string, inputId:string):ng.IPromise<InputModel>; + getArtifactByGroupType(componentId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel>; + getComponentInstanceArtifactsByGroupType(componentId:string, componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel>; +} + +export class ComponentService implements IComponentService { + + static '$inject' = [ + 'Restangular', + 'sdcConfig', + 'Sdc.Services.SharingService', + '$q', + '$base64' + ]; + + constructor(protected restangular:restangular.IElement, + protected sdcConfig:IAppConfigurtaion, + protected sharingService:SharingService, + protected $q:ng.IQService, + protected $base64:any + ) { + + this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root); + this.restangular.setRequestInterceptor(function (elem, operation) { + if (operation === "remove") { + return null; + } + return elem; + }); + // this.restangular.setDefaultHeaders({'Content-Type': 'application/json; charset=UTF-8'}); + } + + //this function is override by each service, we need to change this method to abstract when updtaing typescript version + protected createComponentObject = (component:Component):Component => { + return component; + }; + + public getComponent = (id:string):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + this.restangular.one(id).get().then((response:Component) => { + let component:Component = this.createComponentObject(response); + //console.log("Component Loaded successfully : ", component); + deferred.resolve(component); + }, (err)=> { + console.log("Failed to load component with ID: " + id); + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateComponent = (component:Component):ng.IPromise<Component> => { + // If this is resource + if (component instanceof Resource) { + let resource:Resource = <Resource>component; + if (resource.importedFile) { + // Update resource with payload data. + return this.updateResourceWithPayload(resource); + } else { + if (component.csarUUID) { + // Update resource without payload data. + return this.updateResource(component); + } else { + // Update resource without payload data (metadata). + return this.updateResourceMetadata(component); + } + } + } else { + return this.updateService(component); + } + }; + + private updateService = (component:Component):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + this.restangular.one(component.uniqueId).one("metadata").customPUT(JSON.stringify(component)).then((response:Component) => { + let component:Component = this.createComponentObject(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + private updateResource = (component:Component):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + this.restangular.one(component.uniqueId).customPUT(JSON.stringify(component)).then((response:Component) => { + let component:Component = this.createComponentObject(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + private updateResourceMetadata = (component:Component):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + this.restangular.one(component.uniqueId).one('metadata').customPUT(JSON.stringify(component)).then((response:Component) => { + let component:Component = this.createComponentObject(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + /** + * Only resource can be updated with payload data + * @param component + * @returns {IPromise<T>} + */ + private updateResourceWithPayload = (resource:Resource):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + + resource.payloadData = resource.importedFile.base64; + resource.payloadName = resource.importedFile.filename; + let headerObj = this.getHeaderMd5(resource); + + this.restangular.one(resource.uniqueId).customPUT(JSON.stringify(resource), '', {}, headerObj).then((response:Component) => { + let componentResult:Component = this.createComponentObject(response); + deferred.resolve(componentResult); + }, (err)=> { + deferred.reject(err); + }); + + return deferred.promise; + }; + + public createComponent = (component:Component):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + let headerObj = this.getHeaderMd5(component); + this.restangular.customPOST(JSON.stringify(component), '', {}, headerObj).then((response:Component) => { + let component:Component = this.createComponentObject(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public validateName = (newName:string, subtype?:string):ng.IPromise<IValidate> => { + let deferred = this.$q.defer(); + this.restangular.one("validate-name").one(newName).get({'subtype': subtype}).then((response:any) => { + deferred.resolve(response.plain()); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public changeLifecycleState = (component:Component, state:string, userRemarks:any):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + this.restangular.one(component.uniqueId).one(state).customPOST(userRemarks).then((response:Component) => { + this.sharingService.addUuidValue(response.uniqueId, response.uuid); + let component:Component = this.createComponentObject(response); + deferred.resolve(component); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + // ------------------------------------------------ Artifacts API --------------------------------------------------// + public addOrUpdateArtifact = (componentId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let headerObj = {}; + if (artifact.payloadData) { + headerObj = this.getHeaderMd5(artifact); + } + this.restangular.one(componentId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { + deferred.resolve(response.plain()); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public downloadArtifact = (componentId:string, artifactId:string):ng.IPromise<IFileDownload> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("artifacts").one(artifactId).get().then((response:any) => { + deferred.resolve(response.plain()); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteArtifact = (componentId:string, artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response:ArtifactModel) => { + deferred.resolve(response); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public getArtifactByGroupType = (componentId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("artifactsByType").one(artifactGroupType).get().then((response:any) => { + var artifacts:ArtifactGroupModel = new ArtifactGroupModel(response.plain()); + deferred.resolve(artifacts); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public getComponentInstanceArtifactsByGroupType = (componentId:string, componentInstanceId:string, artifactGroupType:string):ng.IPromise<ArtifactGroupModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstances").one(componentInstanceId).one("artifactsByType").one(artifactGroupType).get().then((response:any) => { + var artifacts:ArtifactGroupModel = new ArtifactGroupModel(response.plain()); + deferred.resolve(artifacts); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + + // ------------------------------------------------ Properties API --------------------------------------------------// + public addProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("properties").customPOST(property.convertToServerObject()).then((response:any) => { + let property:PropertyModel = new PropertyModel(response[Object.keys(response)[0]]); + deferred.resolve(property); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("properties").one(property.uniqueId).customPUT(property.convertToServerObject()).then((response:any) => { + let property:PropertyModel = new PropertyModel(response[Object.keys(response)[0]]); + deferred.resolve(property); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteProperty = (componentId:string, propertyId:string):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("properties").one(propertyId).remove().then((response:any) => { + deferred.resolve(response); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + // ------------------------------------------------ Attributes API --------------------------------------------------// + public addAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("attributes").customPOST(attribute.convertToServerObject()).then((response:any) => { + let attribute:AttributeModel = new AttributeModel(response); + deferred.resolve(attribute); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("attributes").one(attribute.uniqueId).customPUT(attribute.convertToServerObject()).then((response:any) => { + let attribute:AttributeModel = new AttributeModel(response); + deferred.resolve(attribute); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteAttribute = (componentId:string, attributeId:string):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("attributes").one(attributeId).remove().then((response:any) => { + deferred.resolve(response); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + // ------------------------------------------------ Component Instances API --------------------------------------------------// + + public createComponentInstance = (componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").customPOST(JSON.stringify(componentInstance)).then((response:any) => { + let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response); + console.log("Component Instance created", componentInstance); + deferred.resolve(componentInstance); + }, (err)=> { + console.log("Failed to create componentInstance. With Name: " + componentInstance.name); + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateComponentInstance = (componentId:string, componentInstance:ComponentInstance):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one(componentInstance.uniqueId).customPOST(JSON.stringify(componentInstance)).then((response:any) => { + let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response); + console.log("Component Instance was updated", componentInstance); + deferred.resolve(componentInstance); + }, (err)=> { + console.log("Failed to update componentInstance. With ID: " + componentInstance.uniqueId + "Name: " + componentInstance.name); + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateMultipleComponentInstances = (componentId:string, instances:Array<ComponentInstance>):ng.IPromise<Array<ComponentInstance>> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance/multipleComponentInstance").customPOST(JSON.stringify(instances)).then((response:any) => { + console.log("Multiple Component Instances was updated", response); + let updateInstances:Array<ComponentInstance> = new Array<ComponentInstance>(); + _.forEach(response, (componentInstance:ComponentInstance) => { + let updatedComponentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(componentInstance); + updateInstances.push(updatedComponentInstance); + }); + deferred.resolve(updateInstances); + }, (err)=> { + console.log("Failed to update Multiple componentInstance."); + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteComponentInstance = (componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).remove().then(() => { + console.log("Component Instance was deleted"); + deferred.resolve(); + }, (err)=> { + console.log("Failed to delete componentInstance. With ID: " + componentInstanceId); + deferred.reject(err); + }); + return deferred.promise; + }; + + public changeResourceInstanceVersion = (componentId:string, componentInstanceId:string, componentUid:string):ng.IPromise<ComponentInstance> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("changeVersion").customPOST({'componentUid': componentUid}).then((response:any) => { + let componentInstance:ComponentInstance = ComponentInstanceFactory.createComponentInstance(response); + deferred.resolve(componentInstance); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public downloadInstanceArtifact = (componentId:string, instanceId:string, artifactId:string):ng.IPromise<IFileDownload> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstances").one(instanceId).one("artifacts").one(artifactId).get().then((response:any) => { + deferred.resolve(response.plain()); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateInstanceArtifact = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let headerObj = {}; + if (artifact.payloadData) { + headerObj = this.getHeaderMd5(artifact); + } + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { + let newArtifact = new ArtifactModel(response); + deferred.resolve(newArtifact); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public addInstanceArtifact = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let headerObj = {}; + if (artifact.payloadData) { + headerObj = this.getHeaderMd5(artifact); + } + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { + let artifact:ArtifactModel = new ArtifactModel(response.plain()); + deferred.resolve(artifact); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteInstanceArtifact = (componentId:string, instanceId:string, artifactId:string, artifactLabel:string):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").one(artifactId).remove({'operation': artifactLabel}).then((response:ArtifactModel) => { + deferred.resolve(response); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public uploadInstanceEnvFile = (componentId:string, instanceId:string, artifact:ArtifactModel):ng.IPromise<ArtifactModel> => { + let deferred = this.$q.defer(); + let headerObj = {}; + if (artifact.payloadData) { + headerObj = this.getHeaderMd5(artifact); + } + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("artifacts").customPOST(JSON.stringify(artifact), artifact.uniqueId, {}, headerObj).then((response:any) => { + let newArtifact = new ArtifactModel(response); + deferred.resolve(newArtifact); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateInstanceProperty = (componentId:string, property:PropertyModel):ng.IPromise<PropertyModel> => { + let deferred = this.$q.defer(); + let instanceId = property.resourceInstanceUniqueId; + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("property").customPOST(JSON.stringify(property)).then((response:any) => { + let newProperty = new PropertyModel(response); + newProperty.readonly = true; + newProperty.resourceInstanceUniqueId = instanceId; + deferred.resolve(newProperty); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public updateInstanceAttribute = (componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel> => { + let deferred = this.$q.defer(); + let instanceId = attribute.resourceInstanceUniqueId; + this.restangular.one(componentId).one("resourceInstance").one(instanceId).one("attribute").customPOST(JSON.stringify(attribute)).then((response:any) => { + let newAttribute = new AttributeModel(response); + newAttribute.readonly = true; + newAttribute.resourceInstanceUniqueId = instanceId; + deferred.resolve(newAttribute); + }, (err)=> { + deferred.reject(err); + }); + return deferred.promise; + }; + + public createRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(link)).then((response:any) => { + let relation:RelationshipModel = new RelationshipModel(response.plain()); + console.log("Link created successfully ", relation); + deferred.resolve(relation); + }, (err)=> { + console.log("Failed to create Link From: " + link.fromNode + "To: " + link.toNode); + deferred.reject(err); + }); + return deferred.promise; + }; + + public deleteRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(link)).then((response:any) => { + let relation:RelationshipModel = new RelationshipModel(response); + console.log("Link deleted successfully ", relation); + deferred.resolve(relation); + }, (err)=> { + console.log("Failed to delete Link From: " + link.fromNode + "To: " + link.toNode); + deferred.reject(err); + }); + return deferred.promise; + }; + + public getRequirementsCapabilities = (componentId:string):ng.IPromise<any> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response:any) => { + console.log("Component requirement capabilities recived: ", response); + deferred.resolve(response); + }, (err)=> { + console.log("Failed to get requirements & capabilities"); + deferred.reject(err); + }); + return deferred.promise; + }; + + public getModuleForDisplay = (componentId:string, moduleId:string):ng.IPromise<DisplayModule> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("groups").one(moduleId).get().then((response:any) => { + console.log("module loaded successfully: ", response); + let module:DisplayModule = new DisplayModule(response); + deferred.resolve(module); + }, (err)=> { + console.log("Failed to get module with id: ", moduleId); + deferred.reject(err); + }); + return deferred.promise; + }; + + public getComponentInstanceModule = (componentId:string, componentInstanceId:string, moduleId:string):ng.IPromise<Module> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("resourceInstance").one(componentInstanceId).one("groupInstance").one(moduleId).get().then((response:any) => { + console.log("module loaded successfully: ", response); + let module:DisplayModule = new DisplayModule(response); + deferred.resolve(module); + }, (err)=> { + console.log("Failed to get module with id: ", moduleId); + deferred.reject(err); + }); + return deferred.promise; + }; + + public getComponentInstancesFilteredByInputsAndProperties = (componentId:string, searchText?:string):ng.IPromise<Array<ComponentInstance>> => { + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("componentInstances").get({'searchText': searchText}).then((response:any) => { + console.log("component instances return successfully: ", response); + let componentInstances:Array<ComponentInstance> = CommonUtils.initComponentInstances(response); + deferred.resolve(componentInstances); + }, (err) => { + console.log("Failed to get component instances of component with id: " + componentId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + public getComponentInstanceInputs = (componentId:string, instanceId:string, originComponentUid):ng.IPromise<Array<InputModel>> => { + + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("componentInstances").one(instanceId).one(originComponentUid).one("inputs").get().then((response:any) => { + console.log("component instance input return successfully: ", response); + let inputsArray:Array<InputModel> = new Array<InputModel>(); + _.forEach(response, (inputObj:InputModel) => { + inputsArray.push(new InputModel(inputObj)); + }); + deferred.resolve(inputsArray); + }, (err) => { + console.log("Failed to get component instance input with id: " + instanceId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + public getComponentInputs = (componentId:string):ng.IPromise<Array<InputModel>> => { + + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("inputs").get().then((response:any) => { + console.log("component inputs return successfully: ", response); + let inputsArray:Array<InputModel> = new Array<InputModel>(); + _.forEach(response, (inputObj:InputModel) => { + inputsArray.push(new InputModel(inputObj)); + }); + deferred.resolve(inputsArray); + }, (err) => { + console.log("Failed to get component inputs for component with id: " + componentId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + public getComponentInstanceInputProperties = (componentId:string, instanceId:string, inputId:string):ng.IPromise<Array<PropertyModel>> => { + + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("componentInstances").one(instanceId).one(inputId).one("properties").get().then((response:any) => { + console.log("component instance input properties return successfully: ", response); + let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(response, (propertyObj:PropertyModel) => { + propertiesArray.push(new PropertyModel(propertyObj)); + }); + deferred.resolve(propertiesArray); + }, (err) => { + console.log("Failed to get component instance input properties with instanceId: " + instanceId + "and input id: " + inputId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + + public getComponentInstanceProperties = (componentId:string, instanceId:string):ng.IPromise<Array<PropertyModel>> => { + + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("componentInstances").one(instanceId).one("properties").get().then((response:any) => { + console.log("component instance properties return successfully: ", response); + let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(response, (propertyObj:PropertyModel) => { + propertiesArray.push(new PropertyModel(propertyObj)); + }); + deferred.resolve(propertiesArray); + }, (err) => { + console.log("Failed to get component instance properties with instanceId: " + instanceId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + public updateGroupMetadata = (componentId:string, group:Module):ng.IPromise<Module> => { + + let deferred = this.$q.defer(); + this.restangular.one(componentId).one("groups").one(group.uniqueId).one("metadata").customPUT(JSON.stringify(group)).then((response:Module) => { + console.log("group metadata updated successfully: ", response); + let updatedGroup:Module = new Module(response); + + deferred.resolve(updatedGroup); + }, (err) => { + console.log("Failed to update group metadata for component: " + componentId + " for group with id: " + group.uniqueId); + deferred.reject(err); + }); + + return deferred.promise; + }; + + public getComponentInputInputsAndProperties = (serviceId:string, inputId:string):ng.IPromise<InputsAndProperties> => { + let defer = this.$q.defer<any>(); + this.restangular.one(serviceId).one("inputs").one(inputId).get().then((response:InputsAndProperties) => { + + let inputsArray:Array<InputModel> = new Array<InputModel>(); + _.forEach(response.inputs, (inputObj:InputModel) => { + inputsArray.push(new InputModel(inputObj)); + }); + + let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(response.properties, (property:PropertyModel) => { + propertiesArray.push(new PropertyModel(property)); + }); + + defer.resolve(new InputsAndProperties(inputsArray, propertiesArray)); + }, (err)=> { + console.log("failed to get inputs of input : ", err); + defer.reject(err); + }); + return defer.promise; + }; + + createInputsFromInstancesInputsProperties = (resourceId:string, instancePropertyMap:InstancesInputsPropertiesMap):ng.IPromise<Array<PropertyModel>> => { + let defer = this.$q.defer<any>(); + this.restangular.one(resourceId).one("create/properties").customPOST(instancePropertyMap).then((response:any) => { + let inputsArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(response, (inputObj:PropertyModel) => { + inputsArray.push(new PropertyModel(inputObj)); + }); + defer.resolve(inputsArray); + }, (err)=> { + console.log("failed to create service inputs from VF instances inputs : ", err); + defer.reject(err); + }); + return defer.promise; + }; + + createInputsFromInstancesInputs = (serviceId:string, instancesMap:InstancesInputsPropertiesMap):ng.IPromise<Array<InputModel>> => { + let defer = this.$q.defer<any>(); + this.restangular.one(serviceId).one("create/inputs").customPOST(instancesMap).then((response:any) => { + let inputsArray:Array<InputModel> = new Array<InputModel>(); + _.forEach(response, (inputObj:InputModel) => { + inputsArray.push(new InputModel(inputObj)); + }); + defer.resolve(inputsArray); + }, (err)=> { + console.log("failed to create service inputs from VF instances inputs : ", err); + defer.reject(err); + }); + return defer.promise; + }; + + deleteComponentInput = (serviceId:string, inputId:string):ng.IPromise<InputModel> => { + let defer = this.$q.defer(); + this.restangular.one(serviceId).one("delete").one(inputId).one("input").remove().then((response:any) => { + let inputToDelete = new InputModel(response); + defer.resolve(inputToDelete); + }, (err)=> { + console.log("failed to delete input from service: ", err); + defer.reject(err); + }); + return defer.promise; + }; + + private getHeaderMd5 = (object:any):any => { + let headerObj = {}; + // This is ugly workaround!!! + // The md5 result is not correct if we do not add the line JSON.stringify(resource); twice. + JSON.stringify(object); + let componentString:string = JSON.stringify(object); + let md5Result = md5(componentString).toLowerCase(); + headerObj = {'Content-MD5': this.$base64.encode(md5Result)}; + return headerObj; + }; + +} diff --git a/catalog-ui/src/app/services/components/product-service.ts b/catalog-ui/src/app/services/components/product-service.ts new file mode 100644 index 0000000000..c1a14478d2 --- /dev/null +++ b/catalog-ui/src/app/services/components/product-service.ts @@ -0,0 +1,35 @@ +/** + * Created by obarda on 2/8/2016. + */ +'use strict'; +import {IComponentService, ComponentService} from "./component-service"; +import {SharingService} from "../sharing-service"; +import {Product, Component, IAppConfigurtaion} from "../../models"; + +export interface IProductService extends IComponentService { + +} + +export class ProductService extends ComponentService implements IProductService { + + static '$inject' = [ + 'Restangular', + 'sdcConfig', + 'Sdc.Services.SharingService', + '$q', + '$base64' + ]; + + constructor(protected restangular:restangular.IElement, + protected sdcConfig:IAppConfigurtaion, + protected sharingService:SharingService, + protected $q:ng.IQService, + protected $base64:any) { + super(restangular, sdcConfig, sharingService, $q, $base64); + this.restangular = restangular.one("products"); + } + + createComponentObject = (component:Component):Component => { + return new Product(this, this.$q, <Product>component); + }; +} diff --git a/catalog-ui/src/app/services/components/resource-service.ts b/catalog-ui/src/app/services/components/resource-service.ts new file mode 100644 index 0000000000..470f1e2061 --- /dev/null +++ b/catalog-ui/src/app/services/components/resource-service.ts @@ -0,0 +1,52 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {IComponentService, ComponentService} from "./component-service"; +import {PropertyModel, IAppConfigurtaion, Resource, Component} from "../../models"; +import {SharingService} from "../sharing-service"; + +export interface IResourceService extends IComponentService { + updateResourceGroupProperties(uniqueId:string, groupId:string, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> +} + +export class ResourceService extends ComponentService implements IResourceService { + + static '$inject' = [ + 'Restangular', + 'sdcConfig', + 'Sdc.Services.SharingService', + '$q', + '$base64' + ]; + + constructor(protected restangular:restangular.IElement, + protected sdcConfig:IAppConfigurtaion, + protected sharingService:SharingService, + protected $q:ng.IQService, + protected $base64:any + ) { + super(restangular, sdcConfig, sharingService, $q, $base64); + + this.restangular = restangular.one("resources"); + } + + createComponentObject = (component:Component):Component => { + return new Resource(this, this.$q, <Resource>component); + }; + + + updateResourceGroupProperties = (uniqueId:string, groupId:string, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> => { + let defer = this.$q.defer<Array<PropertyModel>>(); + this.restangular.one(uniqueId).one("groups").one(groupId).one('properties').customPUT(JSON.stringify(properties)).then((updatesProperties:any) => { + let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(updatesProperties, (propertyObj:PropertyModel) => { + propertiesArray.push(new PropertyModel(propertyObj)); + }); + defer.resolve(propertiesArray); + }, (err)=> { + defer.reject(err); + }); + return defer.promise; + }; +} diff --git a/catalog-ui/src/app/services/components/service-service.ts b/catalog-ui/src/app/services/components/service-service.ts new file mode 100644 index 0000000000..f0fe90bf7f --- /dev/null +++ b/catalog-ui/src/app/services/components/service-service.ts @@ -0,0 +1,86 @@ +/** + * Created by obarda on 2/4/2016. + */ +'use strict'; +import {IComponentService, ComponentService} from "./component-service"; +import {Distribution, DistributionComponent, Service, PropertyModel, Component, IAppConfigurtaion} from "app/models"; +import {SharingService} from "../sharing-service"; + +export interface IServiceService extends IComponentService { + getDistributionsList(uuid:string):ng.IPromise<Array<Distribution>>; + getDistributionComponents(distributionId:string):ng.IPromise<Array<DistributionComponent>>; + markAsDeployed(serviceId:string, distributionId:string):ng.IPromise<any>; + updateGroupInstanceProperties(serviceId:string, resourceInstanceId:string, groupInstanceId:string, groupInstanceProperties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>>; +} + +export class ServiceService extends ComponentService implements IServiceService { + + static '$inject' = [ + 'Restangular', + 'sdcConfig', + 'Sdc.Services.SharingService', + '$q', + '$base64' + ]; + + public distribution:string = "distribution"; + + constructor(protected restangular:restangular.IElement, + protected sdcConfig:IAppConfigurtaion, + protected sharingService:SharingService, + protected $q:ng.IQService, + protected $base64:any) { + super(restangular, sdcConfig, sharingService, $q, $base64); + + this.restangular = restangular.one("services"); + } + + getDistributionsList = (uuid:string):ng.IPromise<Array<Distribution>> => { + let defer = this.$q.defer<Array<Distribution>>(); + this.restangular.one(uuid).one("distribution").get().then((distributions:any) => { + defer.resolve(<Array<Distribution>> distributions.distributionStatusOfServiceList); + }, (err)=> { + defer.reject(err); + }); + return defer.promise; + }; + + getDistributionComponents = (distributionId:string):ng.IPromise<Array<DistributionComponent>> => { + let defer = this.$q.defer<Array<DistributionComponent>>(); + this.restangular.one("distribution").one(distributionId).get().then((distributions:any) => { + defer.resolve(<Array<DistributionComponent>> distributions.distributionStatusList); + }, (err)=> { + defer.reject(err); + }); + return defer.promise; + }; + + markAsDeployed = (serviceId:string, distributionId:string):ng.IPromise<any> => { + let defer = this.$q.defer<any>(); + this.restangular.one(serviceId).one("distribution").one(distributionId).one("markDeployed").customPOST().then((result:any) => { + defer.resolve(result); + }, (err)=> { + + defer.reject(err); + }); + return defer.promise; + }; + + createComponentObject = (component:Component):Component => { + return new Service(this, this.$q, <Service>component); + }; + + updateGroupInstanceProperties = (serviceId:string, resourceInstanceId:string, groupInstanceId:string, groupInstanceProperties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> => { + let defer = this.$q.defer<Array<PropertyModel>>(); + this.restangular.one(serviceId).one("resourceInstance").one(resourceInstanceId).one('groupInstance').one(groupInstanceId).customPUT(JSON.stringify(groupInstanceProperties)).then((updatedProperties:any) => { + let propertiesArray:Array<PropertyModel> = new Array<PropertyModel>(); + _.forEach(updatedProperties, (propertyObj:PropertyModel) => { + propertiesArray.push(new PropertyModel(propertyObj)); + }); + defer.resolve(propertiesArray); + }, (err)=> { + defer.reject(err); + }); + return defer.promise; + }; +} diff --git a/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts new file mode 100644 index 0000000000..0abdbcfcb3 --- /dev/null +++ b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts @@ -0,0 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 3/13/2016. + */ +'use strict'; +import {LeftPaletteComponent} from "../../../models/components/displayComponent"; +import {Component} from "../../../models/components/component"; +import {EventListenerService} from "../../event-listener-service"; +import {ComponentFactory} from "../../../utils/component-factory"; +import {IAppConfigurtaion} from "../../../models/app-config"; +import {ResourceType, ComponentType, EVENTS} from "../../../utils/constants"; +import {ComponentMetadata} from "../../../models/component-metadata"; + +export class LeftPaletteDataObject { + displayLeftPanelComponents:Array<LeftPaletteComponent>; + onFinishLoadingEvent:string; + + constructor(onFinishEventListener:string) { + + this.displayLeftPanelComponents = new Array<LeftPaletteComponent>(); + this.onFinishLoadingEvent = onFinishEventListener; + } +} + +export class LeftPaletteLoaderService { + + static '$inject' = [ + 'Restangular', + 'sdcConfig', + '$q', + 'ComponentFactory', + 'EventListenerService' + + ]; + + constructor(protected restangular:restangular.IElement, + protected sdcConfig:IAppConfigurtaion, + protected $q:ng.IQService, + protected ComponentFactory:ComponentFactory, + protected EventListenerService:EventListenerService) { + + this.restangular.setBaseUrl(sdcConfig.api.root + sdcConfig.api.component_api_root); + + } + + private serviceLeftPaletteData:LeftPaletteDataObject; + private resourceLeftPaletteData:LeftPaletteDataObject; + private productLeftPaletteData:LeftPaletteDataObject; + private vlData:LeftPaletteDataObject; + + public loadLeftPanel = (componentType: string):void => { + this.serviceLeftPaletteData = new LeftPaletteDataObject(EVENTS.SERVICE_LEFT_PALETTE_UPDATE_EVENT); + this.resourceLeftPaletteData = new LeftPaletteDataObject(EVENTS.RESOURCE_LEFT_PALETTE_UPDATE_EVENT); + this.updateComponentLeftPalette(componentType); + } + + + private getTypeUrl = (componentType:string):string => { + return ComponentType.PRODUCT === componentType ? "services" : "resources"; + }; + + private onFinishLoading = (componentType:string, leftPaletteData:LeftPaletteDataObject):void => { + this.EventListenerService.notifyObservers(leftPaletteData.onFinishLoadingEvent); + }; + + private updateLeftPalette = (componentType, componentInternalType:string, leftPaletteData:LeftPaletteDataObject):void => { + + this.restangular.one(this.getTypeUrl(componentType)).one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => { + _.forEach(leftPaletteComponentMetadata, (componentMetadata:ComponentMetadata) => { + leftPaletteData.displayLeftPanelComponents.push(new LeftPaletteComponent(componentMetadata)); + }); + this.onFinishLoading(componentType, leftPaletteData); + }); + }; + + public getLeftPanelComponentsForDisplay = (componentType:string):Array<LeftPaletteComponent> => { + switch (componentType) { + case ComponentType.SERVICE: + return this.serviceLeftPaletteData.displayLeftPanelComponents; + case ComponentType.PRODUCT: + return this.productLeftPaletteData.displayLeftPanelComponents; + default: + return this.resourceLeftPaletteData.displayLeftPanelComponents; + } + }; + + public updateComponentLeftPalette = (componentType):void => { + switch (componentType) { + case ResourceType.VL: + this.updateLeftPalette(ComponentType.RESOURCE, ResourceType.VL, this.vlData); + break; + case ComponentType.SERVICE: + this.updateLeftPalette(ComponentType.SERVICE, ComponentType.SERVICE, this.serviceLeftPaletteData); + break; + case ComponentType.PRODUCT: + this.updateLeftPalette(ComponentType.PRODUCT, ComponentType.SERVICE, this.productLeftPaletteData); + break; + default: + this.updateLeftPalette(ComponentType.RESOURCE, ResourceType.VF, this.resourceLeftPaletteData); + } + }; +} diff --git a/catalog-ui/src/app/services/configuration-ui-service.ts b/catalog-ui/src/app/services/configuration-ui-service.ts new file mode 100644 index 0000000000..92da0a50ed --- /dev/null +++ b/catalog-ui/src/app/services/configuration-ui-service.ts @@ -0,0 +1,25 @@ +'use strict' +import {IAppConfigurtaion, IApi} from "../models/app-config"; + +interface IConfigurationUiService { + getConfigurationUi():ng.IPromise<any>; +} + +export class ConfigurationUiService implements IConfigurationUiService { + + static '$inject' = ['$http', '$q', 'sdcConfig']; + private api:IApi; + + constructor(private $http:ng.IHttpService, private $q:ng.IQService, sdcConfig:IAppConfigurtaion) { + this.api = sdcConfig.api; + } + + public getConfigurationUi = ():ng.IPromise<any> => { + let defer = this.$q.defer<any>(); + this.$http.get(this.api.root + this.api.GET_configuration_ui) + .then((result:any) => { + defer.resolve(result.data); + }); + return defer.promise; + } +} diff --git a/catalog-ui/src/app/services/cookie-service.ts b/catalog-ui/src/app/services/cookie-service.ts new file mode 100644 index 0000000000..8f88835c18 --- /dev/null +++ b/catalog-ui/src/app/services/cookie-service.ts @@ -0,0 +1,72 @@ +'use strict'; +import {IAppConfigurtaion, ICookie} from "../models/app-config"; + +interface ICookieService { + getUserId():string; + getFirstName():string; + getLastName():string; + getEmail():string; + getUserIdSuffix():string; +} + +export class CookieService implements ICookieService { + + static '$inject' = ['sdcConfig', '$document']; + private cookie:ICookie; + private cookiePrefix:string; + + + constructor(sdcConfig:IAppConfigurtaion, private $document) { + this.cookie = sdcConfig.cookie; + + this.cookiePrefix = ''; + let junctionName:string = this.getCookieByName(this.cookie.junctionName); + if ((junctionName !== null) && (junctionName !== '')) { + this.cookiePrefix = this.cookie.prefix + junctionName + '!'; + } + } + + private getCookieByName = (cookieName:string):string => { + cookieName += '='; + let cookies:Array<string> = this.$document[0].cookie.split(';'); + let cookieVal:string = ''; + cookies.forEach((cookie:string) => { + while (cookie.charAt(0) === ' ') { + cookie = cookie.substring(1); + } + if (cookie.indexOf(cookieName) === 0) { + cookieVal = cookie.substring(cookieName.length, cookie.length); + return; + } + }); + return cookieVal; + }; + + public getUserIdSuffix = ():string => { + return this.cookie.userIdSuffix; + }; + + public getUserId = ():string => { + let userIdCookieName:string = this.cookiePrefix + this.cookie.userIdSuffix; + let userId:string = this.getCookieByName(userIdCookieName); + return userId; + }; + + public getFirstName = ():string => { + let firstNameCookieName:string = this.cookiePrefix + this.cookie.userFirstName; + let firstName:string = this.getCookieByName(firstNameCookieName); + return firstName; + }; + + public getLastName = ():string => { + let lastNameCookieName:string = this.cookiePrefix + this.cookie.userLastName; + let lastName:string = this.getCookieByName(lastNameCookieName); + return lastName; + }; + + public getEmail = ():string => { + let emailCookieName:string = this.cookiePrefix + this.cookie.userEmail; + let email:string = this.getCookieByName(emailCookieName); + return email; + } +} diff --git a/catalog-ui/src/app/services/data-types-service.ts b/catalog-ui/src/app/services/data-types-service.ts new file mode 100644 index 0000000000..1c6ac07fdc --- /dev/null +++ b/catalog-ui/src/app/services/data-types-service.ts @@ -0,0 +1,125 @@ +'use strict'; +import { DataTypePropertyModel } from "../models/data-type-properties"; +import {ComponentInstance, InputModel, DataTypesMap, PropertyModel, InputPropertyBase, IAppConfigurtaion, SchemaProperty} from "../models"; +import {PROPERTY_DATA} from "../utils/constants"; + +export interface IDataTypesService { + + dataTypes:DataTypesMap; //Data type map + selectedPropertiesName:string; + selectedInput:PropertyModel; + alreadySelectedProperties:Array<InputPropertyBase>; + selectedInstance:ComponentInstance; + selectedComponentInputs:Array<InputModel>; + //declare methods + initDataTypes():void; + getAllDataTypes():DataTypesMap; + getFirsLevelOfDataTypeProperties(dataTypeName:string):Array<DataTypePropertyModel>; + isDataTypeForSchemaType(property:SchemaProperty):boolean; + isDataTypeForPropertyType(property:PropertyModel):boolean; + isDataTypeForDataTypePropertyType(property:DataTypePropertyModel):boolean; +} + +export class DataTypesService implements IDataTypesService { + + static '$inject' = [ + 'sdcConfig', + '$q', + '$http' + ]; + + constructor(private sdcConfig:IAppConfigurtaion, + private $q:ng.IQService, + private $http:ng.IHttpService) { + + } + + dataTypes:DataTypesMap; //Data type map + selectedPropertiesName:string; + selectedInput:PropertyModel; + alreadySelectedProperties:Array<InputPropertyBase>; + selectedInstance:ComponentInstance; + selectedComponentInputs:Array<InputModel>; + + public initDataTypes = ():void => { + this.$http({ + url: this.sdcConfig.api.root + this.sdcConfig.api.component_api_root + "dataTypes", + method: "get" + }).then((response:any) => { + this.dataTypes = response.data; + delete this.dataTypes['tosca.datatypes.Root']; + }); + }; + + public getAllDataTypes = ():DataTypesMap => { + return this.dataTypes; + }; + + //if the dt derived from simple- return the first parent type, else- return null + private getTypeForDataTypeDerivedFromSimple = (dataTypeName:string):string => { + /////////temporary hack for tosca primitives/////////////////////// + if (!this.dataTypes[dataTypeName]) { + return 'string'; + } + /////////////////////////////////////////////////////////////////// + if (this.dataTypes[dataTypeName].derivedFromName == "tosca.datatypes.Root" || this.dataTypes[dataTypeName].properties) { + return null; + } + if (PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.dataTypes[dataTypeName].derivedFromName) > -1) { + return this.dataTypes[dataTypeName].derivedFromName + } + return this.getTypeForDataTypeDerivedFromSimple(this.dataTypes[dataTypeName].derivedFromName); + }; + + + //return list of data type properties and all its parents properties + //(not include the properties of its properties, in case this data type has not primitive properties) + public getFirsLevelOfDataTypeProperties = (dataTypeName:string):Array<DataTypePropertyModel> => { + let properties = this.dataTypes[dataTypeName].properties || []; + if (this.dataTypes[dataTypeName].derivedFromName != "tosca.datatypes.Root") { + properties = this.getFirsLevelOfDataTypeProperties(this.dataTypes[dataTypeName].derivedFromName).concat(properties); + } + return properties; + }; + + //return false when type= data type (=not simple type) that not derived from simple type + public isDataTypeForSchemaType = (property:SchemaProperty):boolean=> { + property.simpleType = ""; + if (property.type && PROPERTY_DATA.TYPES.indexOf(property.type) > -1) { + return false; + } + let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type); + if (simpleType) { + property.simpleType = simpleType; + return false; + } + return true; + }; + + public isDataTypeForPropertyType = (property:PropertyModel):boolean=> { + property.simpleType = ""; + if (property.type && PROPERTY_DATA.TYPES.indexOf(property.type) > -1) { + return false; + } + let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type); + if (simpleType) { + property.simpleType = simpleType; + return false; + } + return true; + }; + + + public isDataTypeForDataTypePropertyType = (property:DataTypePropertyModel):boolean=> { + property.simpleType = ""; + if (property.type && PROPERTY_DATA.TYPES.indexOf(property.type) > -1) { + return false; + } + let simpleType = this.getTypeForDataTypeDerivedFromSimple(property.type); + if (simpleType) { + property.simpleType = simpleType; + return false; + } + return true; + }; +} diff --git a/catalog-ui/src/app/services/ecomp-service.ts b/catalog-ui/src/app/services/ecomp-service.ts new file mode 100644 index 0000000000..2703a50fc3 --- /dev/null +++ b/catalog-ui/src/app/services/ecomp-service.ts @@ -0,0 +1,30 @@ +'use strict'; +import {IAppConfigurtaion, IApi} from "../models/app-config"; + +interface IEcompHeaderService { + getMenuItems(userId):ng.IPromise<Array<any>>; +} + +export class EcompHeaderService implements IEcompHeaderService { + static '$inject' = ['$http', '$q', 'sdcConfig']; + private api:IApi; + + constructor(private $http:ng.IHttpService, + private $q:ng.IQService, + private sdcConfig:IAppConfigurtaion) { + this.api = sdcConfig.api; + } + + getMenuItems = (userId):ng.IPromise<Array<any>> => { + let defer = this.$q.defer<Array<any>>(); + //defer.resolve(this.mockData); + this.$http.get(this.api.root + this.api.GET_ecomp_menu_items.replace(':userId', userId)) + .then((response:any) => { + defer.resolve(response.data); + }, (response) => { + defer.reject(response.data); + }); + + return defer.promise; + }; +} diff --git a/catalog-ui/src/app/services/entity-service.ts b/catalog-ui/src/app/services/entity-service.ts new file mode 100644 index 0000000000..d480bf9104 --- /dev/null +++ b/catalog-ui/src/app/services/entity-service.ts @@ -0,0 +1,94 @@ +'use strict'; +import {Product, Service, IApi, IAppConfigurtaion, Resource, Component} from "../models"; +import {SharingService} from "./sharing-service"; +import {ComponentFactory} from "../utils/component-factory"; +import {CacheService} from "./cache-service"; + +interface IEntityService { + getAllComponents():ng.IPromise<Array<Component>>; +} + +interface IComponentsArray { + services:Array<Service>; + resources:Array<Resource>; + products:Array<Product>; +} + +export class EntityService implements IEntityService { + static '$inject' = ['$http', '$q', 'sdcConfig', 'Sdc.Services.SharingService', 'ComponentFactory', 'Sdc.Services.CacheService']; + private api:IApi; + + constructor(private $http:ng.IHttpService, + private $q:ng.IQService, + private sdcConfig:IAppConfigurtaion, + private sharingService:SharingService, + private ComponentFactory:ComponentFactory, + private cacheService:CacheService) { + this.api = sdcConfig.api; + } + + getCatalog = ():ng.IPromise<Array<Component>> => { + let defer = this.$q.defer<Array<Component>>(); + this.$http.get(this.api.root + this.api.GET_catalog) + .then((response:any) => { + let followedResponse: IComponentsArray = response.data; + let componentsList:Array<Component> = new Array(); + + followedResponse.services.forEach((serviceResponse:Service) => { + let component:Service = this.ComponentFactory.createService(serviceResponse); // new Service(serviceResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + + followedResponse.resources.forEach((resourceResponse:Resource) => { + let component:Resource = this.ComponentFactory.createResource(resourceResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + + followedResponse.products.forEach((productResponse:Product) => { + + let component:Product = this.ComponentFactory.createProduct(productResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + + this.cacheService.set('breadcrumbsComponents', componentsList); + defer.resolve(componentsList); + },(responce) => { + defer.reject(responce); + }); + return defer.promise; + }; + + getAllComponents = ():ng.IPromise<Array<Component>> => { + let defer = this.$q.defer<Array<Component>>(); + this.$http.get(this.api.root + this.api.GET_element) + .then((response:any) => { + let componentResponse:IComponentsArray = response.data; + let componentsList:Array<Component> = []; + + componentResponse.services && componentResponse.services.forEach((serviceResponse:Service) => { + let component:Service = this.ComponentFactory.createService(serviceResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + + componentResponse.resources && componentResponse.resources.forEach((resourceResponse:Resource) => { + let component:Resource = this.ComponentFactory.createResource(resourceResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + + componentResponse.products && componentResponse.products.forEach((productsResponse:Product) => { + let component:Product = this.ComponentFactory.createProduct(productsResponse); + componentsList.push(component); + this.sharingService.addUuidValue(component.uniqueId, component.uuid); + }); + this.cacheService.set('breadcrumbsComponents', componentsList); + defer.resolve(componentsList); + }); + + return defer.promise; + }; +} diff --git a/catalog-ui/src/app/services/event-listener-service.ts b/catalog-ui/src/app/services/event-listener-service.ts new file mode 100644 index 0000000000..51aa857e51 --- /dev/null +++ b/catalog-ui/src/app/services/event-listener-service.ts @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 7/4/2016. + */ +'use strict'; +import {Dictionary} from "../utils/dictionary/dictionary"; + +interface IEventListenerService { + +} + +interface ICallbackData { + callback:Function; + args:any[]; +} + +export class EventListenerService implements IEventListenerService { + + public observerCallbacks:Dictionary<string, ICallbackData[]> = new Dictionary<string, Array<ICallbackData>>(); + + //register an observer + callback + public registerObserverCallback = (eventName:string, callback:Function, ...args) => { + let callbackData = { + callback: callback, + args: args + } + + if (this.observerCallbacks.containsKey(eventName)) { + let callbacks = this.observerCallbacks.getValue(eventName); + + // Only insert the callback if the callback is different from existing callbacks. + for (let i = 0; i < callbacks.length; i++) { + if (callbacks[i].toString() === callback.toString()) { + return; // Do not add this callback. + } + } + + callbacks.push(callbackData); + this.observerCallbacks.setValue(eventName, callbacks); + } else { + this.observerCallbacks.setValue(eventName, [callbackData]); + } + }; + + //unregister an observer + public unRegisterObserver = (eventName:string, callbackFunc?:Function) => { + if (this.observerCallbacks.containsKey(eventName)) { + + let callbacks: ICallbackData[] = this.observerCallbacks.getValue(eventName); + if(callbacks.length === 1) { + this.observerCallbacks.remove(eventName); + } else { + let filterCallbacks = _.filter(callbacks, (callBackObj) => { + return callBackObj.callback != callbackFunc; + }); + this.observerCallbacks.setValue(eventName, filterCallbacks); + } + + } + }; + + public notifyObservers = function (eventName:string, ...args) { + _.forEach(this.observerCallbacks.getValue(eventName), (callbackData:ICallbackData) => { + callbackData.callback(...args); + }); + }; +} diff --git a/catalog-ui/src/app/services/header-interceptor.ts b/catalog-ui/src/app/services/header-interceptor.ts new file mode 100644 index 0000000000..a1e79934d8 --- /dev/null +++ b/catalog-ui/src/app/services/header-interceptor.ts @@ -0,0 +1,69 @@ +'use strict'; +import {IAppConfigurtaion} from "../models/app-config"; +import {Dictionary} from "../utils/dictionary/dictionary"; +import {SharingService} from "./sharing-service"; + +//Method name should be exactly "response" - http://docs.angularjs.org/api/ng/service/$http +export interface IInterceptor { + request:Function; + +} + +export class HeaderInterceptor implements IInterceptor { + public static $inject = [ + '$injector', + '$q', + 'uuid4', + 'Sdc.Services.SharingService', + 'sdcConfig', + '$location' + ]; + + public static Factory($injector:ng.auto.IInjectorService, + $q:ng.IQService, + uuid4:any, + sharingService:SharingService, + sdcConfig:IAppConfigurtaion, + $location:ng.ILocationService) { + return new HeaderInterceptor($injector, $q, uuid4, sharingService, sdcConfig, $location); + } + + constructor(private $injector:ng.auto.IInjectorService, + private $q:ng.IQService, + private uuid4:any, + private sharingService:SharingService, + private sdcConfig:IAppConfigurtaion, + private $location:ng.ILocationService) { + console.debug('header-interceptor: initializing AuthenticationInterceptor'); + } + + public request = (requestSuccess):ng.IPromise<any> => { + requestSuccess.headers['X-ECOMP-RequestID'] = this.uuid4.generate(); + /** + * For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header. + * Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header. + */ + let map:Dictionary<string, string> = this.sharingService.getUuidMap(); + if (map && requestSuccess.url.indexOf(this.sdcConfig.api.root) === 0) { + console.log("header-interceptor: url: " + requestSuccess.url); + map.forEach((key:string) => { + if (requestSuccess.url.indexOf(key) !== -1) { + requestSuccess.headers['X-ECOMP-ServiceID'] = this.sharingService.getUuidValue(key); + } + }); + } + return requestSuccess; + }; + + public response = (responseSuccess):ng.IPromise<any> => { + let responseData = responseSuccess.data; + if (responseData) { + let data = JSON.stringify(responseData); + if (data && (data.indexOf("Global Logon: Login") > 0)) { + this.$location.path('dashboard/welcome'); + window.location.reload(); + } + } + return responseSuccess; + } +} diff --git a/catalog-ui/src/app/services/http-error-interceptor.ts b/catalog-ui/src/app/services/http-error-interceptor.ts new file mode 100644 index 0000000000..b61091c37c --- /dev/null +++ b/catalog-ui/src/app/services/http-error-interceptor.ts @@ -0,0 +1,99 @@ +'use strict'; +import {IServerMessageModalModel} from "../view-models/modals/message-modal/message-server-modal/server-message-modal-view-model"; +import {SEVERITY} from "../utils/constants"; +import 'app/utils/prototypes.ts'; + +export class HttpErrorInterceptor { + public static $inject = ['$injector', '$q']; + + public static Factory($injector:ng.auto.IInjectorService, $q:angular.IQService) { + return new HttpErrorInterceptor($injector, $q); + } + + constructor(private $injector:ng.auto.IInjectorService, private $q:angular.IQService) { + } + + public formatMessageArrays = (message:string, variables:Array<string>)=> { + return message.replace(/\[%(\d+)\]/g, function (_, m) { + let tmp = []; + let list = variables[--m].split(";"); + list.forEach(function (item) { + tmp.push("<li>" + item + "</li>"); + }); + return "<ul>" + tmp.join("") + "</ul>"; + }); + }; + + public responseError = (rejection:any)=> { + + let text:string; + let variables; + let messageId:string = ""; + let isKnownException = false; + + if (rejection.data && rejection.data.serviceException) { + text = rejection.data.serviceException.text; + variables = rejection.data.serviceException.variables; + messageId = rejection.data.serviceException.messageId; + isKnownException = true; + } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.serviceException) { + text = rejection.data.requestError.serviceException.text; + variables = rejection.data.requestError.serviceException.variables; + messageId = rejection.data.requestError.serviceException.messageId; + isKnownException = true; + } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.policyException) { + text = rejection.data.requestError.policyException.text; + variables = rejection.data.requestError.policyException.variables; + messageId = rejection.data.requestError.policyException.messageId; + isKnownException = true; + } else if (rejection.data) { + text = 'Wrong error format from server'; + console.error(text); + isKnownException = false; + } + + let data:IServerMessageModalModel; + if (isKnownException) { + // Remove the "Error: " text at the begining + if (text.trim().indexOf("Error:") === 0) { + text = text.replace("Error:", "").trim(); + } + + //mshitrit DE199895 bug fix + let count:number = 0; + variables.forEach(function (item) { + variables[count] = item ? item.replace('<', '<').replace('>', '>') : ''; + count++; + }); + + // Format the message in case has array to <ul><li> + text = this.formatMessageArrays(text, variables); + + // Format the message %1 %2 + text = text.format(variables); + + // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http). + data = { + title: 'Error', + message: text, + messageId: messageId, + status: rejection.status, + severity: SEVERITY.ERROR + }; + } else { + // Need to inject the MessageService manually to prevent circular dependencies (because MessageService use $templateCache that use $http). + data = { + title: 'Error', + message: rejection.status !== -1 ? rejection.statusText : "Error getting response from server", + messageId: messageId, + status: rejection.status, + severity: SEVERITY.ERROR + }; + } + + let modalsHandler = this.$injector.get('ModalsHandler'); + modalsHandler.openServerMessageModal(data); + + return this.$q.reject(rejection); + } +} diff --git a/catalog-ui/src/app/services/loader-service.ts b/catalog-ui/src/app/services/loader-service.ts new file mode 100644 index 0000000000..4bf8a6afe0 --- /dev/null +++ b/catalog-ui/src/app/services/loader-service.ts @@ -0,0 +1,24 @@ +/** + * Created by obarda on 3/13/2016. + */ +'use strict'; +import {EventListenerService} from "./event-listener-service"; +import {EVENTS} from "../utils/constants"; + +export class LoaderService { + + + constructor(private eventListenerService:EventListenerService) { + + } + + public showLoader(...args) { + this.eventListenerService.notifyObservers(EVENTS.SHOW_LOADER_EVENT, ...args); + } + + public hideLoader(...args) { + this.eventListenerService.notifyObservers(EVENTS.HIDE_LOADER_EVENT, ...args); + } +} + +LoaderService.$inject = ['EventListenerService']; diff --git a/catalog-ui/src/app/services/onboarding-service.ts b/catalog-ui/src/app/services/onboarding-service.ts new file mode 100644 index 0000000000..8b93b18ca9 --- /dev/null +++ b/catalog-ui/src/app/services/onboarding-service.ts @@ -0,0 +1,82 @@ +'use strict'; +import {Component, IComponent} from "../models/components/component"; +import {ICsarComponent} from "../models/csar-component"; +import {IAppConfigurtaion, IApi} from "../models/app-config"; +import {IFileDownload} from "../models/file-download"; +import {Resource} from "../models/components/resource"; +import {ComponentFactory} from "../utils/component-factory"; + +interface IOnboardingService { + getOnboardingComponents():ng.IPromise<Array<IComponent>>; + getComponentFromCsarUuid(csarUuid:string):ng.IPromise<Component>; + downloadOnboardingCsar(packageId:string):ng.IPromise<IFileDownload>; +} + +export class OnboardingService implements IOnboardingService { + + static '$inject' = ['$http', '$q', 'sdcConfig', 'ComponentFactory']; + private api:IApi; + + constructor(private $http:ng.IHttpService, + private $q:ng.IQService, + private sdcConfig:IAppConfigurtaion, + private ComponentFactory:ComponentFactory) { + this.api = sdcConfig.api; + } + + getOnboardingComponents = ():ng.IPromise<Array<IComponent>> => { + let defer = this.$q.defer<Array<IComponent>>(); + this.$http.get(this.api.GET_onboarding) + .then((response:any) => { + let onboardingComponents:Array<ICsarComponent> = response.data.results; + let componentsList:Array<IComponent> = new Array(); + + onboardingComponents.forEach((obc:ICsarComponent) => { + let component:Component = this.ComponentFactory.createFromCsarComponent(obc); + componentsList.push(component); + }); + + defer.resolve(componentsList); + },(response) => { + defer.reject(response); + }); + + return defer.promise; + }; + + downloadOnboardingCsar = (packageId:string):ng.IPromise<IFileDownload> => { + let defer = this.$q.defer(); + this.$http({ + url: this.api.GET_onboarding + "/" + packageId, + method: "get", + responseType: "blob" + }) + .then((response:any) => { + defer.resolve(response.data); + }, (err) => { + defer.reject(err); + }); + + return defer.promise; + }; + + getComponentFromCsarUuid = (csarUuid:string):ng.IPromise<Component> => { + let defer = this.$q.defer<Component>(); + this.$http.get(this.api.root + this.api.GET_component_from_csar_uuid.replace(':csar_uuid', csarUuid)) + .then((response:any) => { + let component:Resource; + // If the status is 400, this means that the component not found. + // I do not want to return error from server, because a popup will appear in client with the error. + // So returning success (200) with status 400. + if (response.data.status !== 400) { + component = new Resource(null, this.$q, <Resource>response.data); + } + defer.resolve(component); + },(response) => { + defer.reject(response.data); + }); + + return defer.promise; + }; + +} diff --git a/catalog-ui/src/app/services/progress-service.ts b/catalog-ui/src/app/services/progress-service.ts new file mode 100644 index 0000000000..59ae16d734 --- /dev/null +++ b/catalog-ui/src/app/services/progress-service.ts @@ -0,0 +1,85 @@ +/** + * Created by obarda on 7/7/2016. + */ + +'use strict'; +import IIntervalService = angular.IIntervalService; + +export class ProgressService { + + public progresses:any = {}; + + static '$inject' = ['$interval']; + + constructor(protected $interval:any) { + } + + private totalProgress:number = 90; + private startProgress:number = 10; + private onePercentIntervalSeconds:number = 5; + private createComponentInterval; + + public setProgressValue(name:string, value:number):void { + if (!this.progresses[name]) { + this.progresses[name] = {}; + } + this.progresses[name].value = value; + } + + public getProgressValue(name:string):number { + if (this.progresses[name]) { + return this.progresses[name].value; + } + return 0; + } + + public deleteProgressValue(name:string):void { + this.stopCreateComponentInterval(); + delete this.progresses[name]; + } + + + private stopCreateComponentInterval = ():void => { + this.$interval.cancel(this.createComponentInterval); + }; + + + public initCreateComponentProgress = (componentId:string):void => { + let progressValue:number = this.startProgress; + if (!this.getProgressValue(componentId)) { + this.stopCreateComponentInterval(); + this.setProgressValue(componentId, this.startProgress); + this.createComponentInterval = this.$interval(():void => { + //TODO replace getProgressMockData to real data after BE provide the API + let progressValue = this.getProgressMockData(componentId); + if (progressValue <= this.totalProgress) { + this.setProgressValue(componentId, progressValue); + } else { + /** + * Currently the progress is not really checking against the BE. + * So the progress can pass 100. So the workaround for now, in case we pass 90 (totalProgress) + * stop the interval, so the progress will be kept at 90 until the promise will return value and set + * the progress to 100. + */ + this.deleteProgressValue(componentId); + } + }, this.onePercentIntervalSeconds * 1000); + } + + }; + + + private getProgressMockData = (id:string):number => { + let progressValue = this.getProgressValue(id); + if (progressValue > 0) { + progressValue = progressValue + 1; + } + //if not finish always stay on 90% + if (progressValue > 90) { + progressValue = 90; + } + + return progressValue; + } + +} diff --git a/catalog-ui/src/app/services/sdc-version-service.ts b/catalog-ui/src/app/services/sdc-version-service.ts new file mode 100644 index 0000000000..47001e9c9c --- /dev/null +++ b/catalog-ui/src/app/services/sdc-version-service.ts @@ -0,0 +1,26 @@ +'use strict'; +import {Distribution} from "../models/distribution"; +import {IAppConfigurtaion, IApi} from "../models/app-config"; + +export interface ISdcVersionService { + getVersion():ng.IPromise<any>; +} +export class SdcVersionService implements ISdcVersionService { + + static '$inject' = ['$http', '$q', 'sdcConfig']; + private api:IApi; + + constructor(private $http:ng.IHttpService, private $q:ng.IQService, sdcConfig:IAppConfigurtaion) { + this.api = sdcConfig.api; + } + + public getVersion():ng.IPromise<any> { + let defer = this.$q.defer<Array<Distribution>>(); + this.$http.get(this.api.root + this.api.GET_SDC_Version) + .then((version:any) => { + defer.resolve(version.data); + }); + return defer.promise; + } +} + diff --git a/catalog-ui/src/app/services/sharing-service.ts b/catalog-ui/src/app/services/sharing-service.ts new file mode 100644 index 0000000000..706f01f16b --- /dev/null +++ b/catalog-ui/src/app/services/sharing-service.ts @@ -0,0 +1,20 @@ +'use strict'; +import {Dictionary} from "app/utils"; + +export class SharingService { + + private uuidMap:Dictionary<string, string> = new Dictionary<string,string>(); + + public getUuidValue = (uniqueId:string):string => { + return this.uuidMap.getValue(uniqueId); + }; + + public addUuidValue = (uniqueId:string, uuid:string):void => { + this.uuidMap.setValue(uniqueId, uuid); + }; + + public getUuidMap = ():Dictionary<string, string> => { + return this.uuidMap; + }; + +} diff --git a/catalog-ui/src/app/services/url-tobase64-service.ts b/catalog-ui/src/app/services/url-tobase64-service.ts new file mode 100644 index 0000000000..4e8dc18c7f --- /dev/null +++ b/catalog-ui/src/app/services/url-tobase64-service.ts @@ -0,0 +1,30 @@ +'use strict'; + +export interface IUrlToBase64Service { + downloadUrl(url:string, callback:Function):void; +} + +export class UrlToBase64Service implements IUrlToBase64Service { + constructor() { + } + + public downloadUrl = (url:string, callback:Function):void => { + let xhr:any = new XMLHttpRequest(); + + xhr.onload = ():void => { + let reader = new FileReader(); + reader.onloadend = ():void => { + if (xhr.status === 200) { + callback(reader.result); + } else { + callback(null); + } + }; + reader.readAsDataURL(xhr.response); + }; + xhr.open('GET', url); + xhr.responseType = 'blob'; + xhr.send(); + } +} + diff --git a/catalog-ui/src/app/services/user-resource-service.ts b/catalog-ui/src/app/services/user-resource-service.ts new file mode 100644 index 0000000000..b881e3a98a --- /dev/null +++ b/catalog-ui/src/app/services/user-resource-service.ts @@ -0,0 +1,103 @@ +'use strict'; +import {IUserProperties} from "../models/user"; +import {ICookie, IAppConfigurtaion} from "../models/app-config"; +import {CookieService} from "./cookie-service"; + +// Define an interface of the object you want to use, providing it's properties +export interface IUserResource extends IUserProperties,ng.resource.IResource<IUserResource> { + +} + +// Define your resource, adding the signature of the custom actions +export interface IUserResourceClass extends ng.resource.IResourceClass<IUserResource> { + authorize():IUserResource; + getLoggedinUser():IUserResource; + setLoggedinUser(user:IUserResource):void; + getAllUsers(success?:Function, error?:Function):Array<IUserResource>; + createUser(IResourceResource, success?:Function, error?:Function):void; + editUserRole(IResourceResource, success?:Function, error?:Function):void; + deleteUser(IResourceResource, success?:Function, error?:Function):void; +} + +export class UserResourceService { + + public static getResource = ($resource:ng.resource.IResourceService, + sdcConfig:IAppConfigurtaion, + cookieService:CookieService):IUserResourceClass => { + + let url:string = sdcConfig.api.root + sdcConfig.api.GET_user; + let authorizeUrl:string = sdcConfig.api.root + sdcConfig.api.GET_user_authorize; + let authorizeActionHeaders:any = {}; + let cookie:ICookie = sdcConfig.cookie; + authorizeActionHeaders[cookie.userFirstName] = cookieService.getFirstName(); + authorizeActionHeaders[cookie.userLastName] = cookieService.getLastName(); + authorizeActionHeaders[cookie.userEmail] = cookieService.getEmail(); + authorizeActionHeaders[cookie.userIdSuffix] = cookieService.getUserId(); + + // Define your custom actions here as IActionDescriptor + let authorizeAction:ng.resource.IActionDescriptor = { + method: 'GET', + isArray: false, + url: authorizeUrl, + headers: authorizeActionHeaders + }; + + let getAllUsers:ng.resource.IActionDescriptor = { + method: 'GET', + isArray: true, + url: sdcConfig.api.root + sdcConfig.api.GET_all_users + }; + + let editUserRole:ng.resource.IActionDescriptor = { + method: 'POST', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.POST_edit_user_role, + transformRequest: (data, headers)=> { + data.payloadData = undefined; + data.payloadName = undefined; + return JSON.stringify(data); + } + }; + + let deleteUser:ng.resource.IActionDescriptor = { + method: 'DELETE', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.DELETE_delete_user + }; + + let createUser:ng.resource.IActionDescriptor = { + method: 'POST', + isArray: false, + url: sdcConfig.api.root + sdcConfig.api.POST_create_user, + transformRequest: (data, headers)=> { + data.payloadData = undefined; + data.payloadName = undefined; + return JSON.stringify(data); + } + }; + let userResource:IUserResourceClass = <IUserResourceClass>$resource( + url, + {id: '@id'}, + { + authorize: authorizeAction, + getAllUsers: getAllUsers, + createUser: createUser, + editUserRole: editUserRole, + deleteUser: deleteUser + } + ); + + let _loggedinUser:IUserResource; + + userResource.getLoggedinUser = () => { + return _loggedinUser; + }; + + userResource.setLoggedinUser = (loggedinUser:IUserResource) => { + _loggedinUser = loggedinUser; + }; + + return userResource; + } +} +UserResourceService.getResource.$inject = ['$resource', 'sdcConfig', 'Sdc.Services.CookieService']; diff --git a/catalog-ui/src/app/utils.ts b/catalog-ui/src/app/utils.ts new file mode 100644 index 0000000000..734c276c56 --- /dev/null +++ b/catalog-ui/src/app/utils.ts @@ -0,0 +1,15 @@ +/** + * Created by ob0695 on 2/23/2017. + */ +export * from './utils/dictionary/dictionary'; +export * from './utils/artifacts-utils'; +export * from'./utils/file-utils' +export * from './utils/validation-utils' +export * from './utils/component-factory'; +export * from './utils/component-instance-factory'; +export * from './utils/change-lifecycle-state-handler'; +export * from './utils/modals-handler'; +export * from './utils/menu-handler'; +export * from './utils/constants'; +export * from './utils/common-utils'; +export * from './utils/functions'; diff --git a/catalog-ui/src/app/utils/artifacts-utils.ts b/catalog-ui/src/app/utils/artifacts-utils.ts new file mode 100644 index 0000000000..b52fe6f03e --- /dev/null +++ b/catalog-ui/src/app/utils/artifacts-utils.ts @@ -0,0 +1,104 @@ +import {ArtifactModel} from "../models/artifacts"; +import {IArtifactResourceFormViewModelScope} from "../view-models/forms/artifact-form/artifact-form-view-model"; +import {Component} from "../models/components/component"; +import {ArtifactGroupType, ArtifactType} from "./constants"; +export class ArtifactsUtils { + + static '$inject' = [ + '$filter' + ]; + + constructor(private $filter:ng.IFilterService) { + + } + + public getArtifactTypeByState(currentState:string):string { + switch (currentState) { + case "workspace.composition.lifecycle": + return "interface"; + case "workspace.composition.api": + return "api"; + case "workspace.deployment_artifacts": + case "workspace.composition.deployment": + return "deployment"; + case "workspace.composition.artifacts": + return "informational"; + default: + return "informational"; + } + } + + public getTitle(artifactType:string, selectedComponent:Component):string { + switch (artifactType) { + case "interface": + return "Lifecycle Management"; + case "api": + return "API Artifacts"; + case "deployment": + return "Deployment Artifacts"; + case "informational": + return "Informational Artifacts"; + default: + if (!selectedComponent) { + return ""; + } else { + return this.$filter("resourceName")(selectedComponent.name) + ' Artifacts'; + } + } + } + + public setArtifactType = (artifact:ArtifactModel, artifactType:string):void => { + switch (artifactType) { + case "api": + artifact.artifactGroupType = ArtifactGroupType.SERVICE_API; + break; + case "deployment": + artifact.artifactGroupType = ArtifactGroupType.DEPLOYMENT; + break; + default: + artifact.artifactGroupType = ArtifactGroupType.INFORMATION; + break; + } + }; + + public isLicenseType = (artifactType:string):boolean => { + let isLicense:boolean = false; + + if (ArtifactType.VENDOR_LICENSE === artifactType || ArtifactType.VF_LICENSE === artifactType) { + isLicense = true; + } + + return isLicense; + }; + + public removeArtifact = (artifact:ArtifactModel, artifactsArr:Array<ArtifactModel>):void => { + + if (!artifact.mandatory && (ArtifactGroupType.INFORMATION == artifact.artifactGroupType || + ArtifactGroupType.DEPLOYMENT == artifact.artifactGroupType)) { + _.remove(artifactsArr, {uniqueId: artifact.uniqueId}); + } + else { + let artifactToDelete = _.find(artifactsArr, {uniqueId: artifact.uniqueId}); + + delete artifactToDelete.esId; + delete artifactToDelete.description; + delete artifactToDelete.artifactName; + delete artifactToDelete.apiUrl; + } + }; + + public addAnotherAfterSave(scope:IArtifactResourceFormViewModelScope) { + let newArtifact = new ArtifactModel(); + this.setArtifactType(newArtifact, scope.artifactType); + scope.editArtifactResourceModel.artifactResource = newArtifact; + + scope.forms.editForm['description'].$setPristine(); + if (scope.forms.editForm['artifactLabel']) { + scope.forms.editForm['artifactLabel'].$setPristine(); + } + if (scope.forms.editForm['type']) { + scope.forms.editForm['type'].$setPristine(); + } + + } +} diff --git a/catalog-ui/src/app/utils/change-lifecycle-state-handler.ts b/catalog-ui/src/app/utils/change-lifecycle-state-handler.ts new file mode 100644 index 0000000000..dc59e3bb98 --- /dev/null +++ b/catalog-ui/src/app/utils/change-lifecycle-state-handler.ts @@ -0,0 +1,163 @@ +import {ComponentFactory} from "./component-factory"; +import {Component, Service,IAppMenu, IAppConfigurtaion} from "../models"; +import {IEmailModalModel, IEmailModalModel_Email, IEmailModalModel_Data} from "../view-models/modals/email-modal/email-modal-view-model"; +import {AsdcComment} from "../models/comments"; +import {ModalsHandler} from "./modals-handler"; +import {ServiceServiceNg2} from "../ng2/services/component-services/service.service"; + +/** + * Created by obarda on 2/11/2016. + */ + +export class ChangeLifecycleStateHandler { + + static '$inject' = [ + 'sdcConfig', + 'sdcMenu', + 'ComponentFactory', + '$filter', + 'ModalsHandler', + 'ServiceServiceNg2' + ]; + + constructor(private sdcConfig:IAppConfigurtaion, + private sdcMenu:IAppMenu, + private ComponentFactory:ComponentFactory, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private ServiceServiceNg2:ServiceServiceNg2) { + + } + + private actualChangeLifecycleState = (component:Component, data:any, scope:any, onSuccessCallback?:Function, onErrorCallback?:Function):void => { + + let self = this; + + let getContacts = (component:Component):string => { + let testers = this.sdcConfig.testers; + let result:string = testers[component.componentType][component.categories[0].name] ? + testers[component.componentType][component.categories[0].name] : + testers[component.componentType]['default']; + return result; + }; + + let onSuccess = (newComponent:Component):void => { + //scope.isLoading = false; + console.info(component.componentType.toLowerCase + ' change state ', newComponent); + if (onSuccessCallback) { + onSuccessCallback(self.ComponentFactory.createComponent(newComponent), data.url); + } + }; + + let onError = (error):void => { + scope.isLoading = false; + console.info('Failed to changeLifecycleState to ', data.url); + if (onErrorCallback) { + onErrorCallback(error); + } + }; + + let comment:AsdcComment = new AsdcComment(); + if (data.alertModal) { + // Show alert dialog if defined in menu.json + //------------------------------------------------- + let onOk = (confirmationText):void => { + comment.userRemarks = confirmationText; + scope.isLoading = true; + component.changeLifecycleState(data.url, comment).then(onSuccess, onError); + }; + + let onCancel = ():void => { + console.info('Cancel pressed'); + scope.isLoading = false; + }; + + let modalTitle = this.sdcMenu.alertMessages[data.alertModal].title; + let modalMessage = this.sdcMenu.alertMessages[data.alertModal].message.format([component.componentType.toLowerCase()]); + this.ModalsHandler.openAlertModal(modalTitle, modalMessage).then(onOk, onCancel); + } else if (data.confirmationModal) { + // Show confirmation dialog if defined in menu.json + //------------------------------------------------- + let onOk = (confirmationText):void => { + comment.userRemarks = confirmationText; + scope.isLoading = true; + component.changeLifecycleState(data.url, comment).then(onSuccess, onError); + }; + + let onCancel = ():void => { + console.info('Cancel pressed'); + scope.isLoading = false; + }; + + let modalTitle = this.sdcMenu.confirmationMessages[data.confirmationModal].title; + let modalMessage = this.sdcMenu.confirmationMessages[data.confirmationModal].message.format([component.componentType.toLowerCase()]); + let modalShowComment = this.sdcMenu.confirmationMessages[data.confirmationModal].showComment; + this.ModalsHandler.openConfirmationModal(modalTitle, modalMessage, modalShowComment).then(onOk, onCancel); + + } else if (data.emailModal) { + // Show email dialog if defined in menu.json + //------------------------------------------------- + let onOk = (resource):void => { + if (resource) { + onSuccess(resource); + } else { + onError("Error changing life cycle state"); + } + }; + + let onCancel = ():void => { + scope.isLoading = false; + }; + + let emailModel:IEmailModalModel = <IEmailModalModel>{}; + emailModel.email = <IEmailModalModel_Email>{}; + emailModel.data = <IEmailModalModel_Data>{}; + emailModel.title = this.$filter('translate')("EMAIL_MODAL_TITLE"); + emailModel.email.to = getContacts(component); + emailModel.email.subject = this.$filter('translate')("EMAIL_MODAL_SUBJECT", "{'entityName': '" + this.$filter('resourceName')(component.name) + "','entityVersion': '" + component.version + "'}"); + emailModel.email.message = ''; + emailModel.data.component = component; + emailModel.data.stateUrl = data.url; + + this.ModalsHandler.openEmailModal(emailModel).then(onOk, onCancel); + + } else { + // Submit to server only (no modal is shown). + scope.isLoading = true; + component.changeLifecycleState(data.url, comment).then(onSuccess, onError); + } + + } + + public changeLifecycleState = (component:Component, data:any, scope:any, onSuccessCallback?:Function, onErrorCallback?:Function):void => { + + if (data.conformanceLevelModal) { + this.validateConformanceLevel(component, data, scope, onSuccessCallback, onErrorCallback); + } else { + this.actualChangeLifecycleState(component, data, scope, onSuccessCallback, onErrorCallback); + } + } + + private validateConformanceLevel = (component:Component, data:any, scope:any, onSuccessCallback?:Function, onErrorCallback?:Function):void => { + // Validate conformance level if defined in menu.json + //------------------------------------------------- + this.ServiceServiceNg2.validateConformanceLevel(<Service>component).subscribe((res:boolean) => { + if (res === true) { + //conformance level is ok - continue + this.actualChangeLifecycleState(component, data, scope, onSuccessCallback, onErrorCallback); + + } else { + //show warning modal + this.ModalsHandler.openConformanceLevelModal() + .then(() => { + //continue distribute + this.actualChangeLifecycleState(component, data, scope, onSuccessCallback, onErrorCallback); + + }).catch(() => { + //reject distribution + this.actualChangeLifecycleState(component, data.conformanceLevelModal, scope, onSuccessCallback, onErrorCallback); + }); + } + }); + } +} diff --git a/catalog-ui/src/app/utils/common-utils.ts b/catalog-ui/src/app/utils/common-utils.ts new file mode 100644 index 0000000000..d8019d2f96 --- /dev/null +++ b/catalog-ui/src/app/utils/common-utils.ts @@ -0,0 +1,96 @@ +import {Module, AttributeModel, ResourceInstance, PropertyModel, InputFEModel} from "../models"; +import {ComponentInstanceFactory} from "./component-instance-factory"; +import {PropertyBEModel, RelationshipModel} from "app/models"; + +export class CommonUtils { + + static initProperties(propertiesObj:Array<PropertyModel>, uniqueId?:string):Array<PropertyModel> { + + let properties = new Array<PropertyModel>(); + if (propertiesObj) { + _.forEach(propertiesObj, (property:PropertyModel):void => { + if (uniqueId) { + property.readonly = property.parentUniqueId != uniqueId; + } + properties.push(new PropertyModel(property)); + }); + } + return properties; + }; + + static initAttributes(attributesObj:Array<AttributeModel>, uniqueId?:string):Array<AttributeModel> { + + let attributes = new Array<AttributeModel>(); + if (attributesObj) { + _.forEach(attributesObj, (attribute:AttributeModel):void => { + if (uniqueId) { + attribute.readonly = attribute.parentUniqueId != uniqueId; + } + attributes.push(new AttributeModel(attribute)); + }); + } + return attributes; + }; + + static initComponentInstances(componentInstanceObj:Array<ResourceInstance>):Array<ResourceInstance> { + + let componentInstances = new Array<ResourceInstance>(); + if (componentInstanceObj) { + _.forEach(componentInstanceObj, (instance:ResourceInstance):void => { + componentInstances.push(ComponentInstanceFactory.createComponentInstance(instance)); + }); + } + return componentInstances; + }; + + static initModules(moduleArrayObj:Array<Module>):Array<Module> { + + let modules = new Array<Module>(); + + if (moduleArrayObj) { + _.forEach(moduleArrayObj, (module:Module):void => { + if (module.type === "org.openecomp.groups.VfModule") { + modules.push(new Module(module)); + } + }); + } + return modules; + }; + + static initInputs(inputsObj:Array<PropertyBEModel>):Array<PropertyBEModel> { + + let inputs = new Array<PropertyBEModel>(); + + if(inputsObj) { + _.forEach(inputsObj, (input:PropertyBEModel):void => { + inputs.push(new PropertyBEModel(input)); + }) + } + + return inputs; + } + + static initBeProperties(propertiesObj: Array<PropertyBEModel>): Array<PropertyBEModel> { + + let properties = new Array<PropertyBEModel>(); + + if (propertiesObj) { + _.forEach(propertiesObj, (property: PropertyBEModel): void => { + properties.push(new PropertyBEModel(property)); + }) + } + + return properties; + } + + static initComponentInstanceRelations = (componentInstanceRelationsObj:Array<RelationshipModel>):Array<RelationshipModel> => { + if (componentInstanceRelationsObj) { + let componentInstancesRelations: Array<RelationshipModel> = []; + _.forEach(componentInstanceRelationsObj, (instanceRelation:RelationshipModel):void => { + componentInstancesRelations.push(new RelationshipModel(instanceRelation)); + }); + return componentInstancesRelations; + } + }; +} + diff --git a/catalog-ui/src/app/utils/component-factory.ts b/catalog-ui/src/app/utils/component-factory.ts new file mode 100644 index 0000000000..18edbfb02c --- /dev/null +++ b/catalog-ui/src/app/utils/component-factory.ts @@ -0,0 +1,161 @@ +'use strict'; +import {DEFAULT_ICON, ResourceType, ComponentType} from "./constants"; +import {ServiceService, CacheService, ResourceService, ProductService} from "app/services"; +import {IMainCategory, ISubCategory, ICsarComponent, Component, Resource, Service, Product} from "app/models"; +import {ComponentMetadata} from "../models/component-metadata"; +import {ComponentServiceNg2} from "../ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "../ng2/services/responses/component-generic-response"; + + +export class ComponentFactory { + + static '$inject' = [ + 'Sdc.Services.Components.ResourceService', + 'Sdc.Services.Components.ServiceService', + 'Sdc.Services.Components.ProductService', + 'Sdc.Services.CacheService', + '$q', + 'ComponentServiceNg2' + ]; + + constructor(private ResourceService:ResourceService, + private ServiceService:ServiceService, + private ProductService:ProductService, + private cacheService:CacheService, + private $q:ng.IQService, + private ComponentServiceNg2: ComponentServiceNg2) { + } + + public createComponent = (component:Component):Component => { + let newComponent:Component; + switch (component.componentType) { + + case 'SERVICE': + newComponent = new Service(this.ServiceService, this.$q, <Service> component); + break; + + case 'RESOURCE': + newComponent = new Resource(this.ResourceService, this.$q, <Resource> component); + break; + + case 'PRODUCT': + newComponent = new Product(this.ProductService, this.$q, <Product> component); + break; + } + return newComponent; + }; + + public createProduct = (product:Product):Product => { + let newProduct:Product = new Product(this.ProductService, this.$q, <Product> product); + return newProduct; + }; + + public createService = (service:Service):Service => { + let newService:Service = new Service(this.ServiceService, this.$q, <Service> service); + return newService; + }; + + public createResource = (resource:Resource):Resource => { + let newResource:Resource = new Resource(this.ResourceService, this.$q, <Resource> resource); + return newResource; + }; + + public createFromCsarComponent = (csar:ICsarComponent):Component => { + let newResource:Resource = <Resource>this.createEmptyComponent(ComponentType.RESOURCE); + newResource.name = csar.vspName; + + /** + * Onboarding CSAR contains category and sub category that are uniqueId. + * Need to find the category and sub category and extract the name from them. + * First concat all sub categories to one array. + * Then find the selected sub category and category. + * @type {any} + */ + let availableCategories = angular.copy(this.cacheService.get('resourceCategories')); + let allSubs = []; + _.each(availableCategories, (main:IMainCategory)=> { + if (main.subcategories) { + allSubs = allSubs.concat(main.subcategories); + } + }); + + let selectedCategory:IMainCategory = _.find(availableCategories, function (main:IMainCategory) { + return main.uniqueId === csar.category; + }); + + let selectedSubCategory:ISubCategory = _.find(allSubs, (sub:ISubCategory)=> { + return sub.uniqueId === csar.subCategory; + }); + + // Build the categories and sub categories array (same format as component category) + let categories:Array<IMainCategory> = new Array(); + let subcategories:Array<ISubCategory> = new Array(); + if (selectedCategory && selectedSubCategory) { + subcategories.push(selectedSubCategory); + selectedCategory.subcategories = subcategories; + categories.push(selectedCategory); + } + + // Fill the component with details from CSAR + newResource.selectedCategory = selectedCategory && selectedSubCategory ? selectedCategory.name + "_#_" + selectedSubCategory.name : ''; + newResource.categories = categories; + newResource.vendorName = csar.vendorName; + newResource.vendorRelease = csar.vendorRelease; + newResource.csarUUID = csar.packageId; + newResource.csarPackageType = csar.packageType; + newResource.csarVersion = csar.version; + newResource.packageId = csar.packageId; + newResource.description = csar.description; + return newResource; + }; + + public createEmptyComponent = (componentType:string):Component => { + let newComponent:Component; + + switch (componentType) { + + case ComponentType.SERVICE: + newComponent = new Service(this.ServiceService, this.$q); + break; + + case ComponentType.RESOURCE: + case ResourceType.VF: + case ResourceType.VL: + case ResourceType.VFC: + case ResourceType.CP: + newComponent = new Resource(this.ResourceService, this.$q); + break; + + case ComponentType.PRODUCT: + newComponent = new Product(this.ProductService, this.$q); + break; + } + newComponent.componentType = componentType; + newComponent.tags = []; + newComponent.icon = DEFAULT_ICON; + return newComponent; + }; + + public getComponentFromServer = (componentType:string, componentId:string):ng.IPromise<Component> => { + let newComponent:Component = this.createEmptyComponent(componentType); + newComponent.setUniqueId(componentId); + return newComponent.getComponent(); + }; + + public createComponentOnServer = (componentObject:Component):ng.IPromise<Component> => { + let component:Component = this.createComponent(componentObject); + return component.createComponentOnServer(); + + }; + + public getComponentWithMetadataFromServer = (componentType:string, componentId:string):ng.IPromise<Component> => { + let deferred = this.$q.defer(); + let component = this.createEmptyComponent(componentType); + component.setUniqueId(componentId); + this.ComponentServiceNg2.getComponentMetadata(component).subscribe((response:ComponentGenericResponse) => { + component.setComponentMetadata(response.metadata); + deferred.resolve(component); + }); + return deferred.promise; + } +} diff --git a/catalog-ui/src/app/utils/component-instance-factory.ts b/catalog-ui/src/app/utils/component-instance-factory.ts new file mode 100644 index 0000000000..df92f20c90 --- /dev/null +++ b/catalog-ui/src/app/utils/component-instance-factory.ts @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +/** + * Created by obarda on 3/7/2016. + */ +'use strict'; +import {ComponentInstance, ServiceInstance, ProductInstance, ResourceInstance, Component} from "../models"; +import {LeftPaletteComponent} from "../models/components/displayComponent"; + +export class ComponentInstanceFactory { + + static createComponentInstance(componentInstance:ComponentInstance):ComponentInstance { + let newComponentInstance:ComponentInstance; + switch (componentInstance.originType) { + case 'SERVICE': + newComponentInstance = new ServiceInstance(componentInstance); + break; + + case 'PRODUCT': + newComponentInstance = new ProductInstance(componentInstance); + break; + + default : + newComponentInstance = new ResourceInstance(componentInstance); + break; + } + return newComponentInstance; + }; + + public createEmptyComponentInstance = (componentInstanceType?:string):ComponentInstance => { + let newComponentInstance:ComponentInstance; + switch (componentInstanceType) { + case 'SERVICE': + newComponentInstance = new ServiceInstance(); + break; + + case 'PRODUCT': + newComponentInstance = new ProductInstance(); + break; + + default : + newComponentInstance = new ResourceInstance(); + break; + } + return newComponentInstance; + }; + + public createComponentInstanceFromComponent = (component:LeftPaletteComponent):ComponentInstance => { + let newComponentInstance:ComponentInstance = this.createEmptyComponentInstance(component.componentType); + newComponentInstance.uniqueId = component.uniqueId + (new Date()).getTime(); + newComponentInstance.posX = 0; + newComponentInstance.posY = 0; + newComponentInstance.name = component.name; + newComponentInstance.componentVersion = component.version; + newComponentInstance.originType = component.getComponentSubType(); + //new component instance -> req. & cap. are added on successful instance creation + newComponentInstance.requirements = component.requirements; + newComponentInstance.capabilities = component.capabilities; + newComponentInstance.icon = component.icon; + newComponentInstance.componentUid = component.uniqueId; + return newComponentInstance; + }; + +} diff --git a/catalog-ui/src/app/utils/constants.ts b/catalog-ui/src/app/utils/constants.ts new file mode 100644 index 0000000000..d55079d662 --- /dev/null +++ b/catalog-ui/src/app/utils/constants.ts @@ -0,0 +1,277 @@ +/** + * Created by obarda on 2/18/2016. + */ + +export let DEFAULT_ICON = 'defaulticon'; +export let CP_END_POINT = 'CpEndPoint'; +export let CHANGE_COMPONENT_CSAR_VERSION_FLAG = 'changeComponentCsarVersion'; + +export class ComponentType { + static SERVICE = 'SERVICE'; + static RESOURCE = 'RESOURCE'; + static PRODUCT = 'PRODUCT'; +} + +export class ServerTypeUrl { + static RESOURCES = 'resources/'; + static SERVICES = 'services/'; + static PRODUCTS = 'product/'; +} + +export class ResourceType { + static VF = 'VF'; + static VL = 'VL'; + static CP = 'CP'; + static VFC = 'VFC'; + static VFCMT = 'VFCMT'; +} + +export class ComponentState { + static CERTIFICATION_IN_PROGRESS = 'CERTIFICATION_IN_PROGRESS'; + static CERTIFIED = 'CERTIFIED'; + static NOT_CERTIFIED_CHECKOUT = 'NOT_CERTIFIED_CHECKOUT'; + static NOT_CERTIFIED_CHECKIN = 'NOT_CERTIFIED_CHECKIN'; + static READY_FOR_CERTIFICATION = 'READY_FOR_CERTIFICATION'; +} + +export class DistributionStatus { + DISTRIBUTION_NOT_APPROVED = 'DISTRIBUTION_NOT_APPROVED'; + DISTRIBUTION_APPROVED = 'DISTRIBUTION_APPROVED'; + DISTRIBUTED = 'DISTRIBUTED'; + DISTRIBUTION_REJECTED = 'DISTRIBUTION_REJECTED'; +} + +export class ArtifactGroupType { + static DEPLOYMENT = "DEPLOYMENT"; + static INFORMATION = "INFORMATIONAL"; + static SERVICE_API = "SERVICE_API"; +} + +export class ArtifactType { + static HEAT = "HEAT"; + static HEAT_VOL = "HEAT_VOL"; + static HEAT_NET = "HEAT_NET"; + static VF_LICENSE = "VF_LICENSE"; + static VENDOR_LICENSE = "VENDOR_LICENSE"; + static THIRD_PARTY_RESERVED_TYPES = { + WORKFLOW: "WORKFLOW", + NETWORK_CALL_FLOW: "NETWORK_CALL_FLOW", + AAI_SERVICE_MODEL: "AAI_SERVICE_MODEL", + AAI_VF_MODEL: "AAI_VF_MODEL", + AAI_VF_MODULE_MODEL: "AAI_VF_MODULE_MODEL", + AAI_VF_INSTANCE_MODEL: "AAI_VF_INSTANCE_MODEL" + }; + static TOSCA = {TOSCA_TEMPLATE: "TOSCA_TEMPLATE", TOSCA_CSAR: "TOSCA_CSAR"}; +} + +export class SEVERITY { + public static DEBUG = 'DEBUG'; + public static INFO = 'INFO'; + public static WARNING = 'WARNING'; + public static ERROR = 'ERROR'; +} + +export class PROPERTY_TYPES { + public static STRING = 'string'; + public static INTEGER = 'integer'; + public static FLOAT = 'float'; + public static BOOLEAN = 'boolean'; + public static JSON = 'json'; + public static MAP = 'map'; + public static LIST = 'list'; +} + +export class SOURCES { + public static A_AND_AI = 'A&AI'; + public static ORDER = 'Order'; + public static RUNTIME = 'Runtime'; +} + +export class PROPERTY_DATA { + public static TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON, PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP]; + public static SIMPLE_TYPES = [PROPERTY_TYPES.STRING, PROPERTY_TYPES.INTEGER, PROPERTY_TYPES.FLOAT, PROPERTY_TYPES.BOOLEAN, PROPERTY_TYPES.JSON]; + public static ROOT_DATA_TYPE = "tosca.datatypes.Root"; + public static SOURCES = [SOURCES.A_AND_AI, SOURCES.ORDER, SOURCES.RUNTIME]; +} + +export class PROPERTY_VALUE_CONSTRAINTS { + public static MAX_LENGTH = 100; + public static JSON_MAX_LENGTH = 4096; +} + +export class Role { + public static ADMIN = 'ADMIN'; + public static DESIGNER = 'DESIGNER'; + public static PRODUCT_STRATEGIST = 'PRODUCT_STRATEGIST'; + public static PRODUCT_MANAGER = 'PRODUCT_MANAGER'; + public static TESTER = 'TESTER'; + public static OPS = 'OPS'; + public static GOVERNOR = 'GOVERNOR'; +} + +export enum FormState{ + CREATE, + UPDATE, + IMPORT, + VIEW +} + +export class WorkspaceMode { + public static CREATE = 'create'; + public static EDIT = 'edit'; + public static IMPORT = 'import'; + public static VIEW = 'view'; +} + +export class ImagesUrl { + public static RESOURCE_ICONS = '/assets/styles/images/resource-icons/'; + public static SERVICE_ICONS = '/assets/styles/images/service-icons/'; + public static SELECTED_UCPE_INSTANCE = '/assets/styles/images/resource-icons/selectedUcpeInstance.png'; + public static SELECTED_CP_INSTANCE = '/assets/styles/images/resource-icons/selectedCPInstance.png'; + public static SELECTED_VL_INSTANCE = '/assets/styles/images/resource-icons/selectedVLInstance.png'; + public static CANVAS_PLUS_ICON = '/assets/styles/images/resource-icons/canvasPlusIcon.png'; + public static MODULE_ICON = '/assets/styles/images/resource-icons/module.png'; + public static OPEN_MODULE_ICON = '/assets/styles/images/resource-icons/openModule.png'; + public static OPEN_MODULE_HOVER_ICON = '/assets/styles/images/resource-icons/openModuleHover.png'; + public static CLOSE_MODULE_ICON = '/assets/styles/images/resource-icons/closeModule.png'; + public static CLOSE_MODULE_HOVER_ICON = '/assets/styles/images/resource-icons/closeModuleHover.png'; +} + +export class ModalType { + static STANDARD = 'standard'; + static ERROR = 'error'; + static ALERT = 'alert'; +} + +export class GraphColors { + public static NOT_CERTIFIED_LINK = 'rgb(218,31,61)'; + public static VL_LINK = 'rgb(216,216,216)'; + public static ACTIVE_LINK = '#30bdf2'; + public static BASE_LINK = 'rgb(55,55,55)'; + public static NODE_BACKGROUND_COLOR = 'rgba(46, 162, 157, 0.24)'; + public static NODE_SHADOW_COLOR = 'rgba(198, 230, 228, 0.7)'; + public static NODE_OVERLAPPING_BACKGROUND_COLOR = 'rgba(179, 10, 60, 0.24)'; + public static NODE_OVERLAPPING_SHADOW_COLOR = 'rgba(236, 194, 206, 0.7)'; + public static NODE_UCPE_CP = '#9063cd'; + public static NODE_UCPE = '#fbfbfb'; + public static NODE_SELECTED_BORDER_COLOR = '#30bdf2'; +} +export class GraphTransactionLogText { + public static REMOVE_TEMP_LINK = "remove tempLink"; + public static DELETE_LINK = "delete link"; + public static ADD_LINK = "delete link"; + public static ADD_NODE = "adding node"; +} + +export class GraphUIObjects { + public static LINK_MENU_HEIGHT = 420; + public static TOP_HEADER_HEIGHT = 200; + public static TOOLTIP_OFFSET_X = 50; + public static TOOLTIP_OFFSET_Y = 145; + public static TOOLTIP_LINK_OFFSET_X = 35; + public static TOOLTIP_LINK_OFFSET_Y = 75; + public static MENU_LINK_VL_HEIGHT_OFFSET = 250; + public static MENU_LINK_VL_WIDTH_OFFSET = 200; + public static MENU_LINK_SIMPLE_HEIGHT_OFFSET = 180; + public static MENU_LINK_SIMPLE_WIDTH_OFFSET = 130; + public static DIAGRAM_RIGHT_WIDTH_OFFSET = 248; + public static DIAGRAM_HEADER_OFFSET = 103; + public static DIAGRAM_PALETTE_WIDTH_OFFSET = 247; + // public static COMPOSITION_HEADER_OFFSET = 50; + // public static COMPOSITION_NODE_MENU_WIDTH = 230; + // public static COMPOSITION_NODE_MENU_HEIGHT = 200; + // public static COMPOSITION_RIGHT_PANEL_OFFSET = 300; +} + + +export class States { + public static WORKSPACE_GENERAL = 'workspace.general'; + public static WORKSPACE_ICONS = 'workspace.icons'; + public static WORKSPACE_ACTIVITY_LOG = 'workspace.activity_log'; + public static WORKSPACE_DEPLOYMENT_ARTIFACTS = 'workspace.deployment_artifacts'; + public static WORKSPACE_PROPERTIES = 'workspace.properties'; + public static WORKSPACE_SERVICE_INPUTS = 'workspace.service_inputs'; + public static WORKSPACE_RESOURCE_INPUTS = 'workspace.resource_inputs'; + public static WORKSPACE_ATTRIBUTES = 'workspace.attributes'; + public static WORKSPACE_HIERARCHY = 'workspace.hierarchy'; + public static WORKSPACE_INFORMATION_ARTIFACTS = 'workspace.information_artifacts'; + public static WORKSPACE_TOSCA_ARTIFACTS = 'workspace.tosca_artifacts'; + public static WORKSPACE_COMPOSITION = 'workspace.composition'; + public static WORKSPACE_NETWORK_CALL_FLOW = 'workspace.network_call_flow'; + public static WORKSPACE_MANAGEMENT_WORKFLOW = 'workspace.management_workflow'; + public static WORKSPACE_DEPLOYMENT = 'workspace.deployment'; + public static WORKSPACE_DISTRIBUTION = 'workspace.distribution'; + public static WORKSPACE_PROPERTIES_ASSIGNMENT = 'workspace.properties_assignment'; + public static WORKSPACE_REQUIREMENTS_AND_CAPABILITIES = 'workspace.reqAndCap'; + public static WORKSPACE_NG2 = 'workspace.ng2'; +} + +export class EVENTS { + static RESOURCE_LEFT_PALETTE_UPDATE_EVENT = "resourceLeftPanelUpdateEvent"; + static SERVICE_LEFT_PALETTE_UPDATE_EVENT = "serviceLeftPanelUpdateEvent"; + static PRODUCT_LEFT_PALETTE_UPDATE_EVENT = "productLeftPanelUdateEvent"; + static VL_LEFT_PALETTE_UPDATE_EVENT = "vlLeftPanelUdateEvent"; + static ON_CSAR_LOADING = "onCsarLoading"; + static DOWNLOAD_ARTIFACT_FINISH_EVENT = "downloadArtifactFinishEvent"; + static ON_WORKSPACE_SAVE_BUTTON_CLICK = "onWorkspaceSaveButtonClick"; + static ON_WORKSPACE_SAVE_BUTTON_SUCCESS = "onWorkspaceSaveButtonSuccess"; + static ON_WORKSPACE_SAVE_BUTTON_ERROR = "onWorkspaceSaveButtonError"; + + //Loader events + static SHOW_LOADER_EVENT = "showLoaderEvent"; + static HIDE_LOADER_EVENT = "hideLoaderEvent"; +} + + +export class UNIQUE_GROUP_PROPERTIES_NAME { + public static MIN_VF_MODULE_INSTANCES = 'min_vf_module_instances'; + public static MAX_VF_MODULE_INSTANCES = 'max_vf_module_instances'; + public static INITIAL_COUNT = 'initial_count'; + public static IS_BASE = 'isBase'; + public static VF_MODULE_TYPE = 'vf_module_type'; + public static VF_MODULE_LABEL = 'vf_module_label'; + public static VF_MODULE_DESCRIPTION = 'vf_module_description'; + public static VOLUME_GROUP = 'volume_group'; +} + + +export class GRAPH_EVENTS { + static ON_COMPOSITION_GRAPH_DATA_LOADED = 'onCompositionGraphDataLoaded'; + static ON_DEPLOYMENT_GRAPH_DATA_LOADED = 'onDeploymentGraphDataLoaded'; + static ON_NODE_SELECTED = "onNodeSelected"; + static ON_GRAPH_BACKGROUND_CLICKED = "onGraphBackgroundClicked"; + static ON_PALETTE_COMPONENT_HOVER_IN = 'onPaletteComponentHoverIn'; + static ON_PALETTE_COMPONENT_HOVER_OUT = 'onPaletteComponentHoverOut'; + static ON_PALETTE_COMPONENT_DRAG_START = 'onPaletteComponentDragStart'; + static ON_PALETTE_COMPONENT_DRAG_ACTION = 'onPaletteComponentDragAction'; + static ON_COMPONENT_INSTANCE_NAME_CHANGED = 'onComponentInstanceNameChanged'; + static ON_DELETE_COMPONENT_INSTANCE = 'onDeleteComponentInstance'; + static ON_DELETE_MULTIPLE_COMPONENTS = 'onDeleteMultipleComponents'; + static ON_DELETE_EDGE = 'onDeleteEdge'; + static ON_INSERT_NODE_TO_UCPE = 'onInsertNodeToUCPE'; + static ON_REMOVE_NODE_FROM_UCPE = 'onRemoveNodeFromUCPE'; + static ON_VERSION_CHANGED = 'onVersionChanged'; + static ON_CREATE_COMPONENT_INSTANCE = 'onCreateComponentInstance'; +} + + +export class COMPONENT_FIELDS { + static COMPONENT_INSTANCES_PROPERTIES = "componentInstancesProperties"; + static COMPONENT_INSTANCES_ATTRIBUTES = "componentInstancesAttributes"; + static COMPONENT_ATTRIBUTES = "attributes"; + static COMPONENT_INSTANCES = "componentInstances"; + static COMPONENT_INSTANCES_RELATION = "componentInstancesRelations"; + static COMPONENT_INPUTS = "inputs"; + static COMPONENT_METADATA = "metadata"; + static COMPONENT_DEPLOYMENT_ARTIFACTS = "deploymentArtifacts"; + static COMPONENT_INFORMATIONAL_ARTIFACTS = "artifacts"; + static COMPONENT_PROPERTIES = "properties"; + static COMPONENT_CAPABILITIES = "capabilities"; + static COMPONENT_REQUIREMENTS = "requirements"; + static COMPONENT_TOSCA_ARTIFACTS = "toscaArtifacts"; + static COMPONENT_GROUPS = "groups"; + +} +export class API_QUERY_PARAMS { + static INCLUDE = "include"; +} diff --git a/catalog-ui/src/app/utils/dictionary/dictionary.ts b/catalog-ui/src/app/utils/dictionary/dictionary.ts new file mode 100644 index 0000000000..fd2a028c34 --- /dev/null +++ b/catalog-ui/src/app/utils/dictionary/dictionary.ts @@ -0,0 +1,235 @@ +/** + + This code was copy from collections.ts lib + https://github.com/basarat/typescript-collections + **/ +'use strict'; + +// Used internally by dictionary +interface IDictionaryPair<K, V> { + key:K; + value:V; +} + +export class Dictionary<K, V> { + + /** + * Object holding the key-value pairs. + * @type {Object} + * @private + */ + private table:{ [key:string]:IDictionaryPair<K, V> }; + //: [key: K] will not work since indices can only by strings in javascript and typescript enforces this. + + /** + * Number of elements in the list. + * @type {number} + * @private + */ + private nElements:number; + + /** + * Function used to convert keys to strings. + * @type {function(Object):string} + * @private + */ + private toStr:(key:K) => string; + + + /** + * Creates an empty dictionary. + * @class <p>Dictionaries map keys to values; each key can map to at most one value. + * This implementation accepts any kind of objects as keys.</p> + * + * <p>If the keys are custom objects a function which converts keys to unique + * strings must be provided. Example:</p> + * <pre> + * function petToString(pet) { + * return pet.name; + * } + * </pre> + * @constructor + * @param {function(Object):string=} toStrFunction optional function used + * to convert keys to strings. If the keys aren"t strings or if toString() + * is not appropriate, a custom function which receives a key and returns a + * unique string must be provided. + */ + constructor(toStrFunction?:(key:K) => string) { + this.table = {}; + this.nElements = 0; + this.toStr = toStrFunction || this.defaultToString; + } + + + /** + copy from angular.js isUndefined + */ + private isUndefined = (value:any):boolean => { + return typeof value === 'undefined'; + } + + defaultToString = (item:any):string => { + return item.toString(); + } + + /** + * Returns the value to which this dictionary maps the specified key. + * Returns undefined if this dictionary contains no mapping for this key. + * @param {Object} key key whose associated value is to be returned. + * @return {*} the value to which this dictionary maps the specified key or + * undefined if the map contains no mapping for this key. + */ + getValue = (key:K):V => { + let pair:IDictionaryPair<K, V> = this.table[this.toStr(key)]; + if (this.isUndefined(pair)) { + return undefined; + } + return pair.value; + } + + + /** + * Associates the specified value with the specified key in this dictionary. + * If the dictionary previously contained a mapping for this key, the old + * value is replaced by the specified value. + * @param {Object} key key with which the specified value is to be + * associated. + * @param {Object} value value to be associated with the specified key. + * @return {*} previous value associated with the specified key, or undefined if + * there was no mapping for the key or if the key/value are undefined. + */ + setValue = (key:K, value:V):V => { + + if (this.isUndefined(key) || this.isUndefined(value)) { + return undefined; + } + + let ret:V; + let k = this.toStr(key); + let previousElement:IDictionaryPair<K, V> = this.table[k]; + if (this.isUndefined(previousElement)) { + this.nElements++; + ret = undefined; + } else { + ret = previousElement.value; + } + this.table[k] = { + key: key, + value: value + }; + return ret; + } + + /** + * Removes the mapping for this key from this dictionary if it is present. + * @param {Object} key key whose mapping is to be removed from the + * dictionary. + * @return {*} previous value associated with specified key, or undefined if + * there was no mapping for key. + */ + remove = (key:K):V => { + let k = this.toStr(key); + let previousElement:IDictionaryPair<K, V> = this.table[k]; + if (!this.isUndefined(previousElement)) { + delete this.table[k]; + this.nElements--; + return previousElement.value; + } + return undefined; + } + + /** + * Returns an array containing all of the keys in this dictionary. + * @return {Array} an array containing all of the keys in this dictionary. + */ + keys = ():K[] => { + let array:K[] = []; + for (let name in this.table) { + if (this.table.hasOwnProperty(name)) { + let pair:IDictionaryPair<K, V> = this.table[name]; + array.push(pair.key); + } + } + return array; + } + + /** + * Returns an array containing all of the values in this dictionary. + * @return {Array} an array containing all of the values in this dictionary. + */ + values = ():V[] => { + let array:V[] = []; + for (let name in this.table) { + if (this.table.hasOwnProperty(name)) { + let pair:IDictionaryPair<K, V> = this.table[name]; + array.push(pair.value); + } + } + return array; + } + + /** + * Executes the provided function once for each key-value pair + * present in this dictionary. + * @param {function(Object,Object):*} callback function to execute, it is + * invoked with two arguments: key and value. To break the iteration you can + * optionally return false. + */ + forEach = (callback:(key:K, value:V) => any):void => { + for (let name in this.table) { + if (this.table.hasOwnProperty(name)) { + let pair:IDictionaryPair<K, V> = this.table[name]; + let ret = callback(pair.key, pair.value); + if (ret === false) { + return; + } + } + } + } + + /** + * Returns true if this dictionary contains a mapping for the specified key. + * @param {Object} key key whose presence in this dictionary is to be + * tested. + * @return {boolean} true if this dictionary contains a mapping for the + * specified key. + */ + containsKey = (key:K):boolean => { + return !this.isUndefined(this.getValue(key)); + } + + /** + * Removes all mappings from this dictionary. + * @this {Dictionary} + */ + clear = () => { + + this.table = {}; + this.nElements = 0; + } + + /** + * Returns the number of keys in this dictionary. + * @return {number} the number of key-value mappings in this dictionary. + */ + size = ():number => { + return this.nElements; + } + + /** + * Returns true if this dictionary contains no mappings. + * @return {boolean} true if this dictionary contains no mappings. + */ + isEmpty = ():boolean => { + return this.nElements <= 0; + } + + toString = ():string => { + let toret = "{"; + this.forEach((k, v) => { + toret = toret + "\n\t" + k.toString() + " : " + v.toString(); + }); + return toret + "\n}"; + } +} // End of dictionary + diff --git a/catalog-ui/src/app/utils/file-utils.ts b/catalog-ui/src/app/utils/file-utils.ts new file mode 100644 index 0000000000..d8c18229c3 --- /dev/null +++ b/catalog-ui/src/app/utils/file-utils.ts @@ -0,0 +1,51 @@ +export class FileUtils { + + static '$inject' = [ + '$window' + ]; + + constructor(private $window:any) { + } + + public byteCharactersToBlob = (byteCharacters, contentType):any => { + contentType = contentType || ''; + let sliceSize = 1024; + let bytesLength = byteCharacters.length; + let slicesCount = Math.ceil(bytesLength / sliceSize); + let byteArrays = new Array(slicesCount); + + for (let sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) { + let begin = sliceIndex * sliceSize; + let end = Math.min(begin + sliceSize, bytesLength); + + let bytes = new Array(end - begin); + for (let offset = begin, i = 0; offset < end; ++i, ++offset) { + bytes[i] = byteCharacters[offset].charCodeAt(0); + } + byteArrays[sliceIndex] = new Uint8Array(bytes); + } + return new Blob(byteArrays, {type: contentType}); + }; + + public base64toBlob = (base64Data, contentType):any => { + let byteCharacters = atob(base64Data); + return this.byteCharactersToBlob(byteCharacters, contentType); + }; + + public downloadFile = (blob, fileName):void=> { + let url = this.$window.URL.createObjectURL(blob); + let downloadLink = document.createElement("a"); + + downloadLink.setAttribute('href', url); + downloadLink.setAttribute('download', fileName); + document.body.appendChild(downloadLink); + + var clickEvent = new MouseEvent("click", { + "view": window, + "bubbles": true, + "cancelable": true + }); + downloadLink.dispatchEvent(clickEvent); + + } +} diff --git a/catalog-ui/src/app/utils/functions.ts b/catalog-ui/src/app/utils/functions.ts new file mode 100644 index 0000000000..24f8008393 --- /dev/null +++ b/catalog-ui/src/app/utils/functions.ts @@ -0,0 +1,35 @@ +export class QueueUtils { + + private executionQueue:any; + + constructor(private $q:ng.IQService) { + this.executionQueue = this.getDummyPromise(); + } + + + private getDummyPromise = ():ng.IPromise<boolean> => { + let deferred:ng.IDeferred<boolean> = this.$q.defer(); + deferred.resolve(true); + return deferred.promise; + }; + + + private addMethodToQueue = (runMe:Function):void => { + this.executionQueue = this.executionQueue.then(runMe, runMe); + }; + + addNonBlockingUIAction = (update:Function, releaseUIcallBack:Function):void => { + releaseUIcallBack(); + this.addMethodToQueue(update); + }; + + // The Method call is responsible for releasing the UI + addBlockingUIAction = (blockingServerRequest:Function):void => { + this.addMethodToQueue(blockingServerRequest); + }; + + addBlockingUIActionWithReleaseCallback = (blockingServerRequest:Function, releaseUIcallBack:Function):void=> { + this.addMethodToQueue(blockingServerRequest); + this.addMethodToQueue(releaseUIcallBack); + }; +} diff --git a/catalog-ui/src/app/utils/menu-handler.ts b/catalog-ui/src/app/utils/menu-handler.ts new file mode 100644 index 0000000000..1dc5a203e2 --- /dev/null +++ b/catalog-ui/src/app/utils/menu-handler.ts @@ -0,0 +1,125 @@ +'use strict'; +import {WorkspaceMode, ComponentState} from "./constants"; +import {IAppConfigurtaion, IAppMenu, Component} from "../models"; +import {ComponentFactory} from "./component-factory"; +import {ModalsHandler} from "./modals-handler"; + +export class MenuItem { + text:string; + callback:(...args:Array<any>) => ng.IPromise<boolean>; + state:string; + action:string; + params:Array<any>; + isDisabled:boolean; + disabledRoles:Array<string>; + blockedForTypes:Array<string>; // This item will not be shown for specific components types. + + //TODO check if needed + alertModal:string; + conformanceLevelModal: boolean; // Call validateConformanceLevel API and shows conformanceLevelModal if necessary, then continue with action or invokes another action + confirmationModal:string; // Open confirmation modal (user should select "OK" or "Cancel"), and continue with the action. + emailModal:string; // Open email modal (user should fill email details), and continue with the action. + url:string; // Data added to menu item, in case the function need to use it, example: for function "changeLifecycleState", I need to pass also the state "CHECKOUT" that I want the state to change to. + + + constructor(text:string, callback:(...args:Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?:Array<any>, blockedForTypes?:Array<string>) { + this.text = text; + this.callback = callback; + this.state = state; + this.action = action; + this.params = params; + this.blockedForTypes = blockedForTypes; + } +} + +export class MenuItemGroup { + selectedIndex:number; + menuItems:Array<MenuItem>; + itemClick:boolean; + + constructor(selectedIndex?:number, menuItems?:Array<MenuItem>, itemClick?:boolean) { + this.selectedIndex = selectedIndex; + this.menuItems = menuItems; + this.itemClick = itemClick; + } + + public updateSelectedMenuItemText(newText:string) { + this.menuItems[this.selectedIndex].text = newText; + } +} + + +export class MenuHandler { + + static '$inject' = [ + 'sdcConfig', + 'sdcMenu', + 'ComponentFactory', + '$filter', + 'ModalsHandler', + '$state', + '$q' + ]; + + constructor(private sdcConfig:IAppConfigurtaion, + private sdcMenu:IAppMenu, + private ComponentFactory:ComponentFactory, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private $state:ng.ui.IStateService, + private $q:ng.IQService) { + + } + + + generateBreadcrumbsModelFromComponents = (components:Array<Component>, selected:Component):MenuItemGroup => { + let result = new MenuItemGroup(0, [], false); + if (components) { + + // Search the component in all components by uuid (and not uniqueid, gives access to an assets's minor versions). + let selectedItem = _.find(components, (item:Component) => { + return item.uuid === selected.uuid; + }); + + // If not found search by invariantUUID + if (undefined == selectedItem) { + selectedItem = _.find(components, (item:Component) => { + //invariantUUID && Certified State matches between major versions + return item.invariantUUID === selected.invariantUUID && item.lifecycleState === ComponentState.CERTIFIED; + }); + } + + // If not found search by name (name is unique). + if (undefined == selectedItem) { + selectedItem = _.find(components, (item:Component) => { + return item.name === selected.name; + }); + } + + result.selectedIndex = components.indexOf(selectedItem); + components[result.selectedIndex] = selected; + let clickItemCallback = (component:Component):ng.IPromise<boolean> => { + this.$state.go('workspace.general', { + id: component.uniqueId, + type: component.componentType.toLowerCase(), + mode: WorkspaceMode.VIEW + }); + return this.$q.when(true); + }; + + components.forEach((component:Component) => { + let menuItem = new MenuItem( + // component.name, + component.getComponentSubType() + ': ' + this.$filter('resourceName')(component.name), + clickItemCallback, + null, + null, + [component] + ); + // menuItem.text = component.name; + result.menuItems.push(menuItem); + }); + } + return result; + }; +} diff --git a/catalog-ui/src/app/utils/modals-handler.ts b/catalog-ui/src/app/utils/modals-handler.ts new file mode 100644 index 0000000000..fe864cb658 --- /dev/null +++ b/catalog-ui/src/app/utils/modals-handler.ts @@ -0,0 +1,389 @@ +import {PropertyModel, Component, ArtifactModel, Distribution, InputModel, DisplayModule, InputPropertyBase} from "../models"; +import {IEmailModalModel} from "../view-models/modals/email-modal/email-modal-view-model"; +import {IClientMessageModalModel} from "../view-models/modals/message-modal/message-client-modal/client-message-modal-view-model"; +import {IServerMessageModalModel} from "../view-models/modals/message-modal/message-server-modal/server-message-modal-view-model"; +import {IConfirmationModalModel} from "../view-models/modals/confirmation-modal/confirmation-modal-view-model"; +import {ModalType} from "./constants"; +import {AttributeModel} from "../models/attributes"; + +export interface IModalsHandler { + + + openDistributionStatusModal (distribution:Distribution, status:string, component:Component):ng.IPromise<any>; + openConfirmationModal (title:string, message:string, showComment:boolean, size?:string):ng.IPromise<any>; + openAlertModal (title:string, message:string, size?:string):ng.IPromise<any>; + openEmailModal(emailModel:IEmailModalModel):ng.IPromise<any>; + openServerMessageModal(data:IServerMessageModalModel):ng.IPromise<any>; + openClientMessageModal(data:IClientMessageModalModel):ng.IPromise<ng.ui.bootstrap.IModalServiceInstance>; + openArtifactModal(artifact:ArtifactModel, component:Component):ng.IPromise<any>; + openEditPropertyModal(property:PropertyModel, component:Component, filteredProperties:Array<PropertyModel>, isPropertyOwnValue:boolean):ng.IPromise<any>; +} + +export class ModalsHandler implements IModalsHandler { + + static '$inject' = [ + '$uibModal', + '$q' + ]; + + constructor(private $uibModal:ng.ui.bootstrap.IModalService, + private $q:ng.IQService) { + } + + + + + openDistributionStatusModal = (distribution:Distribution, status:string, component:Component):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html', + controller: 'Sdc.ViewModels.DistributionStatusModalViewModel', + size: 'sdc-xl', + backdrop: 'static', + resolve: { + data: ():any => { + return { + 'distribution': distribution, + 'status': status, + 'component': component + }; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + + openAlertModal = (title:string, message:string, size?:string):ng.IPromise<any> => { + return this.openConfirmationModalBase(title, message, false, ModalType.ALERT, size); + }; + + openConfirmationModal = (title:string, message:string, showComment:boolean, size?:string):ng.IPromise<any> => { + return this.openConfirmationModalBase(title, message, showComment, ModalType.STANDARD, size); + }; + + private openConfirmationModalBase = (title:string, message:string, showComment:boolean, type:ModalType, size?:string):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/modals/confirmation-modal/confirmation-modal-view.html', + controller: 'Sdc.ViewModels.ConfirmationModalViewModel', + size: size ? size : 'sdc-sm', + backdrop: 'static', + resolve: { + confirmationModalModel: ():IConfirmationModalModel => { + let model:IConfirmationModalModel = { + title: title, + message: message, + showComment: showComment, + type: type + }; + return model; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openEmailModal = (emailModel:IEmailModalModel):ng.IPromise<any> => { + + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/modals/email-modal/email-modal-view.html', + controller: 'Sdc.ViewModels.EmailModalViewModel', + size: 'sdc-sm', + backdrop: 'static', + resolve: { + emailModalModel: ():IEmailModalModel => { + return emailModel; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + + }; + + openServerMessageModal = (data:IServerMessageModalModel):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/modals/message-modal/message-server-modal/server-message-modal-view.html', + controller: 'Sdc.ViewModels.ServerMessageModalViewModel', + size: 'sdc-sm', + backdrop: 'static', + resolve: { + serverMessageModalModel: ():IServerMessageModalModel => { + return data; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openClientMessageModal = (data:IClientMessageModalModel):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/modals/message-modal/message-client-modal/client-message-modal-view.html', + controller: 'Sdc.ViewModels.ClientMessageModalViewModel', + size: 'sdc-sm', + backdrop: 'static', + resolve: { + clientMessageModalModel: ():IClientMessageModalModel => { + return data; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance); + return deferred.promise; + }; + + openOnboadrdingModal = (okButtonText:string, currentCsarUUID?:string):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/modals/onboarding-modal/onboarding-modal-view.html', + controller: 'Sdc.ViewModels.OnboardingModalViewModel', + size: 'sdc-xl', + backdrop: 'static', + resolve: { + okButtonText: ():string=> { + return okButtonText; + }, + currentCsarUUID: ():string=> { + return currentCsarUUID || null; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openEditEnvParametersModal = (artifactResource:ArtifactModel, component?:Component):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/env-parameters-form/env-parameters-form.html', + controller: 'Sdc.ViewModels.EnvParametersFormViewModel', + size: 'sdc-xl', + backdrop: 'static', + resolve: { + artifact: ():ArtifactModel => { + return artifactResource; + }, + component: ():Component => { + return component; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openEditInputValueModal = (input:InputModel):ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/input-form/input-form-view.html', + controller: 'Sdc.ViewModels.InputFormViewModel', + size: 'sdc-md', + backdrop: 'static', + resolve: { + input: ():InputModel => { + return input; + } + } + }; + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openArtifactModal = (artifact:ArtifactModel, component:Component):ng.IPromise<any> => { + let deferred = this.$q.defer(); + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/artifact-form/artifact-form-view.html', + controller: 'Sdc.ViewModels.ArtifactResourceFormViewModel', + size: 'sdc-md', + backdrop: 'static', + keyboard: false, + resolve: { + artifact: ():ArtifactModel => { + return artifact; + }, + component: ():Component => { + return component; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + + /** + * + * This function openes up the edit property modal + * + * @param property - the property to edit + * @param component - the component who is the owner of the property + * @param filteredProperties - the filtered properties list to scroll between in the edit modal + * @param isPropertyValueOwner - boolean telling if the component is eligible of editing the property + * @returns {IPromise<T>} - Promise telling if the modal has opened or not + */ + openEditPropertyModal = (property:PropertyModel, component:Component, filteredProperties:Array<PropertyModel>, isPropertyValueOwner:boolean):ng.IPromise<any> => { + let deferred = this.$q.defer(); + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/property-forms/component-property-form/property-form-view.html', + controller: 'Sdc.ViewModels.PropertyFormViewModel', + size: 'sdc-l', + backdrop: 'static', + keyboard: false, + resolve: { + property: ():PropertyModel => { + return property; + }, + component: ():Component => { + return <Component> component; + }, + filteredProperties: ():Array<PropertyModel> => { + return filteredProperties; + }, + isPropertyValueOwner: ():boolean => { + return isPropertyValueOwner; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + + openEditModulePropertyModal = (property:PropertyModel, component:Component, selectedModule:DisplayModule):ng.IPromise<any> => { + let deferred = this.$q.defer(); + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/property-forms/base-property-form/property-form-base-view.html', + controller: 'Sdc.ViewModels.ModulePropertyView', + size: 'sdc-l', + backdrop: 'static', + keyboard: false, + resolve: { + originalProperty: ():PropertyModel => { + return property; + }, + component: ():Component => { + return <Component> component; + }, + selectedModule: ():DisplayModule => { + return selectedModule; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + openSelectDataTypeModal = (property:PropertyModel, component:Component, filteredProperties:Array<PropertyModel>, propertiesMap:Array<InputPropertyBase>):ng.IPromise<any> => { + let deferred = this.$q.defer(); + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/property-forms/base-property-form/property-form-base-view.html', + controller: 'Sdc.ViewModels.SelectDataTypeViewModel', + size: 'sdc-l', + backdrop: 'static', + keyboard: false, + resolve: { + originalProperty: ():PropertyModel => { + return property; + }, + component: ():Component => { + return <Component> component; + }, + filteredProperties: ():Array<PropertyModel> => { + return filteredProperties; + }, + propertiesMap: ():Array<InputPropertyBase>=> { + return propertiesMap; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + public openEditAttributeModal = (attribute:AttributeModel, component: Component):void => { + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/attribute-form/attribute-form-view.html', + controller: 'Sdc.ViewModels.AttributeFormViewModel', + size: 'sdc-md', + backdrop: 'static', + keyboard: false, + resolve: { + attribute: ():AttributeModel => { + return attribute; + }, + component: ():Component => { + return component; + } + } + }; + this.$uibModal.open(modalOptions); + }; + + public openUpdateComponentInstanceNameModal = (currentComponent: Component):ng.IPromise<any> => { + let deferred = this.$q.defer(); + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/forms/resource-instance-name-form/resource-instance-name-view.html', + controller: 'Sdc.ViewModels.ResourceInstanceNameViewModel', + size: 'sdc-sm', + backdrop: 'static', + resolve: { + component: ():Component => { + return currentComponent; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + + public openConformanceLevelModal = ():ng.IPromise<any> => { + let deferred = this.$q.defer(); + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../view-models/workspace/conformance-level-modal/conformance-level-modal-view.html', + controller: 'Sdc.ViewModels.ConformanceLevelModalViewModel', + size: 'sdc-sm', + backdrop: 'static', + resolve: { + + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + deferred.resolve(modalInstance.result); + return deferred.promise; + }; + +} diff --git a/catalog-ui/src/app/utils/prototypes.ts b/catalog-ui/src/app/utils/prototypes.ts new file mode 100644 index 0000000000..2aa718a06c --- /dev/null +++ b/catalog-ui/src/app/utils/prototypes.ts @@ -0,0 +1,64 @@ +interface String { + format(variables:Array<string>):string +} + +interface Array<T> { + clean(o:T):Array<T>; +} + + +/** + * This function will replace the %<number> with strings (from array). + * Example: "Requested '%1' resource was not found.".format(["MyResource"]); + * Note: in case the array contains empty string the function will also remove the '' or the "". + */ +if (!String.hasOwnProperty("format")) { + String.prototype["format"] = function (variables:Array<string>):string { + + if (variables === null || variables === undefined || variables.length === 0) { + variables = ['']; + } + + for (let i = 0; i < variables.length; i++) { + if (variables[i] === '' || variables[i] === null) { + variables[i] = '--DELETE--'; + } + } + + let res = this.replace(/%(\d+)/g, function (_, m) { + return variables[--m]; + }); + + res = res.replace(" '--DELETE--' ", " "); + res = res.replace(" \"--DELETE--\" ", " "); + res = res.replace("'--DELETE--'", ""); + res = res.replace("\"--DELETE--\"", ""); + res = res.replace("--DELETE--", ""); + + return res; + }; +} + +if (!String.hasOwnProperty("capitalizeFirstLetter")) { + String.prototype["capitalizeFirstLetter"] = function () { + return this.charAt(0).toUpperCase() + this.slice(1); + }; +} + +if (!String.hasOwnProperty("replaceAll")) { + String.prototype["replaceAll"] = function (find:string, replace:string):string { + return this.replace(new RegExp(find, 'g'), replace); + }; +} + +if (!Array.hasOwnProperty("clean")) { + Array.prototype.clean = function (deleteValue) { + for (let i = 0; i < this.length; i++) { + if (this[i] == deleteValue) { + this.splice(i, 1); + i--; + } + } + return this; + }; +} diff --git a/catalog-ui/src/app/utils/validation-utils.ts b/catalog-ui/src/app/utils/validation-utils.ts new file mode 100644 index 0000000000..9246d3350d --- /dev/null +++ b/catalog-ui/src/app/utils/validation-utils.ts @@ -0,0 +1,153 @@ +class basePattern { + pattern:RegExp; + base:number; + + constructor(pattern:RegExp, base:number) { + this.pattern = pattern; + this.base = base; + } +} + +export interface IMapRegex { + integer:RegExp; + boolean:RegExp; + float:RegExp; + string:RegExp; +} + +export class ValidationUtils { + + static '$inject' = [ + 'IntegerNoLeadingZeroValidationPattern', + 'FloatValidationPattern', + 'CommentValidationPattern', + 'BooleanValidationPattern', + 'NumberValidationPattern', + 'LabelValidationPattern', + ]; + private trueRegex:string = '[t][r][u][e]|[t]|[o][n]|[y]|[y][e][s]|[1]'; + private falseRegex:string = '[f][a][l][s][e]|[f]|[o][f][f]|[n]|[n][o]|[0]'; + private heatBooleanValidationPattern:RegExp = new RegExp('^(' + this.trueRegex + '|' + this.falseRegex + ')$'); + + + constructor(private IntegerNoLeadingZeroValidationPattern:RegExp, + private FloatValidationPattern:RegExp, + private CommentValidationPattern:RegExp, + private BooleanValidationPattern:RegExp, + private NumberValidationPattern:RegExp, + private LabelValidationPattern:RegExp) { + } + + public stripAndSanitize(text:string):string { + if (!text) { + return null; + } + return text.replace(/\s+/g, ' ').replace(/%[A-Fa-f0-9]{2}/g, '').trim(); + } + + public getValidationPattern = (validationType:string, parameterType?:string):RegExp => { + switch (validationType) { + case 'integer': + return this.IntegerNoLeadingZeroValidationPattern; + case 'float': + return this.FloatValidationPattern; + case 'number': + return this.NumberValidationPattern; + case 'string': + return this.CommentValidationPattern; + case 'boolean': + { + //Bug Fix DE197437 [Patch]Mismatch between BE to FE regarding supported characters in Boolean filed + if (parameterType && parameterType === 'heat') { + return this.heatBooleanValidationPattern; + } + else { + return this.BooleanValidationPattern; + } + } + + case 'label': + return this.LabelValidationPattern; + case 'category': + return this.LabelValidationPattern; + default : + return null; + } + }; + + public getPropertyListPatterns():IMapRegex { + return { + integer: /^(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)(,?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+))*$/, + string: /^"[\u0000-\u0021\u0023-\u00BF]+"(\s*,?\s*"[\u0000-\u0021\u0023-\u00BF]+")*$/, + boolean: /^([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])(,?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]))*$/, + float: /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?(,?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?)*$/ + }; + } + + public getPropertyMapPatterns():IMapRegex { + return { + integer: /^"\w+"\s*:\s?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)+(\s*,?\s*"\w+"\s?:\s?(0|[-+]?[1-9][0-9]*|[-+]?0x[0-9a-fA-F]+|[-+]?0o[0-7]+)+)*$/, + string: /^"\w+"\s?:\s?"[\u0000-\u0021\u0023-\u00BF]*"(\s*,?\s*"\w+"\s?:\s?"[\u0000-\u0021\u0023-\u00BF]*")*$/, + boolean: /^"\w+"\s?:\s?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee])(\s*,?\s*"\w+"\s?:\s?([Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]))*$/, + float: /^"\w+"\s?:\s?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?(\s*,?\s*"\w+"\s?:\s?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?f?)*$/ + }; + } + + public validateUniqueKeys(viewValue:string):boolean { + if (!viewValue) { + return true; //allow empty value + } + + let json:string = "{" + viewValue.replace(/\s\s+/g, ' ') + "}"; + try { + let obj:any = JSON.parse(json); + /* + //Method #1 : check json string length before & after parsing + let newJson:string = JSON.stringify(obj); + if (newJson.length < json.length) { + return false; + }*/ + + //Method #2 : check how many times we can find "KEY": in json string + let result:boolean = true; + Object.keys(obj).forEach((key:string) => { + result = result && json.split('"' + key + '":').length === 2; + }); + return result; + + } catch (e) { + return false; //not a valid JSON + } + + //return true; + } + + public validateJson = (json:string):boolean => { + try { + JSON.parse(json); + return true; + } catch (err) { + console.log('invalid json'); + return false; + } + }; + + public validateIntRange = (value:string):boolean => { + + let base8 = new basePattern(/^([-+]?0o[0-7]+)$/, 8); + let base10 = new basePattern(/^(0|[-+]?[1-9][0-9]*)$/, 10); + let base16 = new basePattern(/^([-+]?0x[0-9a-fA-F]+)$/, 16); + + let min:number = -0x80000000; + let max:number = 0x7fffffff; + let intPatterns:Array<basePattern> = [base8, base10, base16]; + let matchedBase = _.find(intPatterns, (item)=> { + return item.pattern.test(value); + }); + + let parsed:number = parseInt(value.replace('o', ''), matchedBase.base); + if (parsed) { + return min <= parsed && max >= parsed; + } + } +} diff --git a/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts new file mode 100644 index 0000000000..c421e632da --- /dev/null +++ b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view-model.ts @@ -0,0 +1,72 @@ +'use strict'; +import {ICategoryResourceClass, ICategoryResource} from "../../../services/category-resource-service"; + +interface IAddCategoryModalViewModelScope extends ng.IScope { + category:ICategoryResource; + modelType:string; + footerButtons:Array<any>; + forms:any; + + save():void; + close():void; +} + +export class AddCategoryModalViewModel { + + static '$inject' = [ + '$scope', + 'Sdc.Services.CategoryResourceService', + '$uibModalInstance', + 'parentCategory', + 'type' + ]; + + constructor(private $scope:IAddCategoryModalViewModelScope, + private categoryResourceService:ICategoryResourceClass, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private parentCategory:ICategoryResource, + private type:string) { + this.initScope(); + } + + private initScope = ():void => { + this.$scope.forms = {}; + this.$scope.modelType = this.parentCategory ? 'sub category' : 'category'; + this.$scope.category = new this.categoryResourceService(); + + this.$scope.close = ():void => { + this.$uibModalInstance.dismiss(); + }; + + this.$scope.save = ():void => { + + let onOk = (newCategory:ICategoryResource):void => { + this.$uibModalInstance.close(newCategory); + }; + + let onCancel = ():void => { + //error + }; + + if (!this.parentCategory) { + this.$scope.category.$save({types: this.type + "s"}, onOk, onCancel); + } else { + this.$scope.category.$saveSubCategory({ + types: this.type + "s", + categoryId: this.parentCategory.uniqueId + }, onOk, onCancel); + } + + }; + + this.$scope.footerButtons = [ + {'name': 'OK', 'css': 'blue', 'callback': this.$scope.save, 'disabled': true}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + } +} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html index 5718982661..a9df3e6009 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html @@ -26,10 +26,10 @@ maxlength="25" autofocus /> - <div class="input-error" data-ng-show="editForm.categoryName.$dirty && editForm.categoryName.$invalid"> - <span ng-show="editForm.categoryName.$error.required" translate="CREATE_CATEGORY_MODAL_REQUIRED" translate-values="{'modelType': '{{modelType}}' }"></span> - <span ng-show="editForm.categoryName.$error.minlength" translate="CREATE_CATEGORY_MODAL_MINLENGTH" translate-values="{'minlength': '4', 'modelType': '{{modelType}}' }"></span> - <span ng-show="editForm.categoryName.$error.pattern" translate="CREATE_CATEGORY_MODAL_PATTERN" translate-values="{'modelType': '{{modelType}}' }"></span> + <div class="input-error" data-ng-show="forms.editForm.categoryName.$dirty && forms.editForm.categoryName.$invalid"> + <span ng-show="forms.editForm.categoryName.$error.required" translate="CREATE_CATEGORY_MODAL_REQUIRED" translate-values="{'modelType': '{{modelType}}' }"></span> + <span ng-show="forms.editForm.categoryName.$error.minlength" translate="CREATE_CATEGORY_MODAL_MINLENGTH" translate-values="{'minlength': '4', 'modelType': '{{modelType}}' }"></span> + <span ng-show="forms.editForm.categoryName.$error.pattern" translate="CREATE_CATEGORY_MODAL_PATTERN" translate-values="{'modelType': '{{modelType}}' }"></span> </div> </div> diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less index 39d84aab23..39d84aab23 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less +++ b/catalog-ui/src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less diff --git a/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view-model.ts b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view-model.ts new file mode 100644 index 0000000000..c8503bce42 --- /dev/null +++ b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view-model.ts @@ -0,0 +1,61 @@ +'use strict'; +import {CacheService} from "app/services"; +import {IAppConfigurtaion} from "app/models"; + +interface IAdminDashboardViewModelScope extends ng.IScope { + version:string; + sdcConfig:IAppConfigurtaion; + isLoading:boolean; + currentTab:string; + templateUrl:string; + monitorUrl:string; + moveToTab(tab:string):void; + isSelected(tab:string):boolean; +} + + +export class AdminDashboardViewModel { + static '$inject' = [ + '$scope', + '$templateCache', + 'Sdc.Services.CacheService', + 'sdcConfig' + ]; + + constructor(private $scope:IAdminDashboardViewModelScope, + private $templateCache:ng.ITemplateCacheService, + private cacheService:CacheService, + private sdcConfig:IAppConfigurtaion) { + + this.initScope(); + } + + private initScope = ():void => { + + this.$scope.version = this.cacheService.get('version'); + this.$scope.sdcConfig = this.sdcConfig; + this.$scope.monitorUrl = this.$scope.sdcConfig.api.kibana; + this.$scope.isSelected = (tab:string):boolean => { + return tab === this.$scope.currentTab; + } + + this.$scope.moveToTab = (tab:string):void => { + if (tab === this.$scope.currentTab) { + return; + } + else if (tab === 'USER_MANAGEMENT') { + this.$scope.templateUrl="user-management-view.html"; + this.$templateCache.put("user-management-view.html", require('app/view-models/admin-dashboard/user-management/user-management-view.html')); + } + else if (tab === 'CATEGORY_MANAGEMENT') { + this.$scope.templateUrl="category-management-view.html"; + this.$templateCache.put("category-management-view.html", require('app/view-models/admin-dashboard/category-management/category-management-view.html')); + } + this.$scope.currentTab = tab; + }; + + this.$scope.moveToTab('USER_MANAGEMENT'); + + + } +} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard-view.html b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html index 063525a4bf..150f7c2554 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard-view.html @@ -21,4 +21,6 @@ <div class="sdc-admin-body"> <ng-include src="templateUrl" ng-if="true"></ng-include> </div> + + <ecomp-footer></ecomp-footer> </div> diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard.less b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard.less index 874a02c431..874a02c431 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/admin-dashboard.less +++ b/catalog-ui/src/app/view-models/admin-dashboard/admin-dashboard.less diff --git a/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management-view-model.ts b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management-view-model.ts new file mode 100644 index 0000000000..ba390c4bee --- /dev/null +++ b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management-view-model.ts @@ -0,0 +1,176 @@ +'use strict'; +import {ModalsHandler, ValidationUtils} from "app/utils"; +import {CacheService, ICategoryResource} from "app/services"; +import {IAppConfigurtaion} from "app/models"; +import {ComponentType} from "../../../utils/constants"; + +interface ICategoryManagementViewModelScope extends ng.IScope { + SERVICE:string; + RESOURCE:string; + categoriesToShow:Array<ICategoryResource>; + serviceCategories:Array<ICategoryResource>; + resourceCategories:Array<ICategoryResource>; + selectedCategory:ICategoryResource; + selectedSubCategory:ICategoryResource; + modalInstance:ng.ui.bootstrap.IModalServiceInstance; + isLoading:boolean; + type:string; + namePattern:RegExp; + + selectCategory(category:ICategoryResource):void; + selectSubCategory(subcategory:ICategoryResource):void; + selectType(type:string):void; + deleteCategory(category:ICategoryResource, subCategory:ICategoryResource):void; + createCategoryModal(parentCategory:ICategoryResource):void; +} + +export class CategoryManagementViewModel { + static '$inject' = [ + '$scope', + 'sdcConfig', + 'Sdc.Services.CacheService', + '$uibModal', + '$filter', + 'ValidationUtils', + 'ModalsHandler' + ]; + + constructor(private $scope:ICategoryManagementViewModelScope, + private sdcConfig:IAppConfigurtaion, + private cacheService:CacheService, + private $uibModal:ng.ui.bootstrap.IModalService, + private $filter:ng.IFilterService, + private ValidationUtils:ValidationUtils, + private ModalsHandler:ModalsHandler) { + + this.initScope(); + this.$scope.selectType(ComponentType.SERVICE.toLocaleLowerCase()); + + } + + private initScope = ():void => { + let scope:ICategoryManagementViewModelScope = this.$scope; + scope.SERVICE = ComponentType.SERVICE.toLocaleLowerCase(); + scope.RESOURCE = ComponentType.RESOURCE.toLocaleLowerCase(); + + scope.namePattern = this.ValidationUtils.getValidationPattern('category'); + + scope.selectCategory = (category:ICategoryResource) => { + if (scope.selectedCategory !== category) { + scope.selectedSubCategory = null; + } + scope.selectedCategory = category; + }; + scope.selectSubCategory = (subcategory:ICategoryResource) => { + scope.selectedSubCategory = subcategory; + }; + scope.selectType = (type:string):void => { + if (scope.type !== type) { + scope.selectedCategory = null; + scope.selectedSubCategory = null; + } + + scope.type = type; + scope.categoriesToShow = scope[type + 'Categories']; + }; + + scope.createCategoryModal = (parentCategory:ICategoryResource):void => { + //can't create a sub category for service + if (parentCategory && scope.type === ComponentType.SERVICE.toLowerCase()) { + return; + } + + let type:string = scope.type; + + let onOk = (newCategory:ICategoryResource):void => { + if (!parentCategory) { + scope[type + 'Categories'].push(newCategory); + } else { + if (!parentCategory.subcategories) { + parentCategory.subcategories = []; + } + parentCategory.subcategories.push(newCategory); + } + }; + + let onCancel = ():void => { + + }; + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + template: 'src/app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.html', + controller: 'Sdc.ViewModels.AddCategoryModalViewModel', + size: 'sdc-xsm', + backdrop: 'static', + scope: scope, + resolve: { + parentCategory: function () { + return parentCategory; + }, + type: function () { + return type; + } + } + }; + + scope.modalInstance = this.$uibModal.open(modalOptions); + scope.modalInstance.result.then(onOk, onCancel); + + }; + + scope.deleteCategory = (category:ICategoryResource, subCategory:ICategoryResource):void => { + + let onOk = ():void => { + + scope.isLoading = true; + let type:string = scope.type; + + let onError = (response):void => { + scope.isLoading = false; + console.info('onFaild', response); + }; + + let onSuccess = (response:any):void => { + let arr:Array<ICategoryResource>; + + if (!subCategory) { + arr = this.$scope[type + 'Categories']; + arr.splice(arr.indexOf(category), 1); + if (category === scope.selectedCategory) { + scope.selectedCategory = null; + scope.selectedSubCategory = null; + } + } else { + arr = category.subcategories; + arr.splice(arr.indexOf(subCategory), 1); + } + + scope.isLoading = false; + }; + + if (!subCategory) { + category.$delete({ + types: type + "s", + categoryId: category.uniqueId + } + , onSuccess, onError); + } else { + category.$deleteSubCategory({ + types: type + "s", + categoryId: category.uniqueId, + subCategoryId: subCategory.uniqueId, + } + , onSuccess, onError); + } + }; + let modelType:string = subCategory ? 'sub category' : 'category'; + let title:string = this.$filter('translate')("DELETE_CATEGORY_MODAL_HEADER", "{'modelType': '" + modelType + "' }"); + let message:string = this.$filter('translate')("DELETE_CATEGORY_MODAL_CATEGORY_NAME", "{'modelType': '" + modelType + "' }"); + + this.ModalsHandler.openConfirmationModal(title, message, false, 'sdc-xsm').then(onOk); + }; + + this.$scope.serviceCategories = this.cacheService.get('serviceCategories'); + this.$scope.resourceCategories = this.cacheService.get('resourceCategories'); + } +} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management-view.html b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management-view.html index 95a002d3d7..95a002d3d7 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management-view.html diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management.less b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management.less index 011122c9e8..011122c9e8 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/category-management/category-management.less +++ b/catalog-ui/src/app/view-models/admin-dashboard/category-management/category-management.less diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/ecomp/ecomp-view.html b/catalog-ui/src/app/view-models/admin-dashboard/ecomp/ecomp-view.html index 7c89b545c5..7c89b545c5 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/ecomp/ecomp-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/ecomp/ecomp-view.html diff --git a/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts new file mode 100644 index 0000000000..82cc3a74da --- /dev/null +++ b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view-model.ts @@ -0,0 +1,202 @@ +'use strict'; +import {ModalsHandler} from "app/utils"; +import {IUserResource, IUserResourceClass} from "app/services"; +import {User, IUserProperties, IUser, IAppConfigurtaion} from "app/models"; + +interface IUserManagementViewModelScope extends ng.IScope { + sdcConfig:IAppConfigurtaion; + usersList:Array<IUserProperties>; + isLoading:boolean; + isNewUser:boolean; + sortBy:string; + reverse:boolean; + tableHeadersList:any; + roles:Array<string>; + newUser:IUser; + currentUser:IUserResource; + userIdValidationPattern:RegExp; + editForm:ng.IFormController; + getAllUsers():void; + editUserRole(user:IUserProperties); + sort(sortBy:string):void; + createUser():void; + deleteUser(userId:string):void; + onEditUserPressed(user:IUserProperties):void; + saveUserChanges(user:IUserProperties):void; + getTitle(role:string):string; + clearForm():void; + +} + + +export class UserManagementViewModel { + static '$inject' = [ + '$scope', + 'sdcConfig', + 'Sdc.Services.UserResourceService', + 'UserIdValidationPattern', + '$filter', + 'ModalsHandler' + ]; + + constructor(private $scope:IUserManagementViewModelScope, + private sdcConfig:IAppConfigurtaion, + private userResourceService:IUserResourceClass, + private UserIdValidationPattern:RegExp, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler) { + + this.initScope(); + + } + + + private getAllUsers = ():void => { + this.$scope.isLoading = true; + + let onError = (response) => { + this.$scope.isLoading = false; + console.info('onFaild', response); + }; + let onSuccess = (response:Array<IUserProperties>) => { + this.$scope.usersList = response; + _.forEach(this.$scope.usersList, (user:any, i:number)=> { + user.index = i; + }); + this.$scope.isLoading = false; + }; + this.userResourceService.getAllUsers(onSuccess, onError); + }; + + private updateUserFilterTerm = (user:IUserProperties):void => { + user.filterTerm = user.firstName + ' ' + user.lastName + ' ' + user.userId + ' ' + user.email + ' ' + user.role + ' ' + this.$filter('date')(user.lastLoginTime, "MM/dd/yyyy"); + }; + + private initScope = ():void => { + let self = this; + + this.$scope.tableHeadersList = [{title: "First Name", property: 'firstName'}, { + title: "Last Name", + property: 'lastName' + }, + { + title: this.$filter('translate')("USER_MANAGEMENT_TABLE_HEADER_USER_ID"), + property: 'userId' + }, {title: "Email", property: 'email'}, {title: "Role", property: 'role'}, { + title: "Last Active", + property: 'lastLoginTime' + }]; + this.$scope.userIdValidationPattern = this.UserIdValidationPattern; + this.$scope.sortBy = 'lastLoginTime'; + this.$scope.reverse = false; + this.$scope.roles = this.sdcConfig.roles; + this.$scope.isNewUser = false; + this.$scope.currentUser = this.userResourceService.getLoggedinUser(); + this.getAllUsers(); + + let resource:IUserResource = <IUserResource>{}; + this.$scope.newUser = new User(resource); + + this.$scope.sort = (sortBy:string):void => {//default sort by descending last update. default for alphabetical = ascending + this.$scope.isNewUser = false; + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? ( !this.$scope.reverse) : this.$scope.reverse = false; + this.$scope.sortBy = sortBy; + }; + + this.$scope.createUser = ():void => { + + let onError = (response) => { + this.$scope.isLoading = false; + console.info('onFaild', response); + }; + + let onSuccess = (response:IUserProperties) => { + this.$scope.newUser.resource['index'] = this.$scope.usersList.length; + this.$scope.newUser.resource.lastLoginTime = "0"; + this.$scope.newUser.resource.status = response.status; + this.updateUserFilterTerm(this.$scope.newUser.resource); + this.$scope.usersList.unshift(this.$scope.newUser.resource); + this.$scope.isNewUser = true; + this.$scope.sortBy = 'index'; + this.$scope.reverse = true; + this.$scope.isLoading = false; + this.$scope.newUser = new User(null); + this.$scope.editForm.$setPristine(); + let _self = this; + setTimeout(function () { + _self.$scope.isNewUser = false; + }, 7000); + }; + this.userResourceService.createUser({ + userId: this.$scope.newUser.resource.userId, + role: this.$scope.newUser.resource.role + }, onSuccess, onError); + }; + + + this.$scope.onEditUserPressed = (user:IUserProperties):void => { + user.isInEditMode = true; + user.tempRole = user.role; + }; + + this.$scope.editUserRole = (user:IUserProperties):void => { + let roleBeforeUpdate:string = user.role; + user.role = user.tempRole; + + let onError = (response) => { + this.$scope.isLoading = false; + user.role = roleBeforeUpdate; + console.info('onFaild', response); + }; + let onSuccess = (response:any) => { + this.$scope.isLoading = false; + user.tempRole = user.role; + this.updateUserFilterTerm(user); + }; + + this.userResourceService.editUserRole({id: user.userId, role: user.role}, onSuccess, onError); + }; + + this.$scope.saveUserChanges = (user:IUserProperties):void => { + if (user.tempRole != user.role) { + this.$scope.editUserRole(user) + } + user.isInEditMode = false; + }; + + this.$scope.deleteUser = (userId:string):void => { + + let onOk = ():void => { + this.$scope.isLoading = true; + + let onError = (response):void => { + this.$scope.isLoading = false; + console.info('onFaild', response); + }; + + let onSuccess = (response:any):void => { + _.remove(this.$scope.usersList, {userId: userId}); + this.$scope.isLoading = false; + }; + this.userResourceService.deleteUser({id: userId}, onSuccess, onError); + }; + + let title:string = this.$filter('translate')("USER_MANAGEMENT_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("USER_MANAGEMENT_VIEW_DELETE_MODAL_TEXT"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + + this.$scope.getTitle = (role:string):string => { + return role.toLowerCase().replace('governor', 'governance_Rep').replace('_', ' '); + }; + + this.$scope.clearForm = ():void => { + if (!this.$scope.editForm['contactId'].$viewValue && !this.$scope.editForm['role'].$viewValue) { + this.$scope.editForm.$setPristine(); + } + //if(this.$scope.editForm['contactId'].$viewValue === '' && this.$scope.editForm['role'].$viewValue){ + // this.$scope.editForm.$setPristine(); + //} + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management-view.html b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html index 26e720b044..d2983873cc 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management-view.html +++ b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management-view.html @@ -3,7 +3,7 @@ <div class="sdc-user-management-top-bar"> <div class="sdc-user-management-top-bar-search-container"> <label class="sdc-user-management-top-bar-search-text">Search User</label> - <input type="text" class="sdc-user-management-top-bar-form-input" placeholder="{{ USER_MANAGEMENT_SEARCH_LABEL | translate }}" data-ng-model="search.filterTerm" ng-model-options="{ debounce: 500 }" data-tests-id="searchbox" /> + <input type="text" class="sdc-user-management-top-bar-form-input" placeholder="Search user by name, userId, email or role" data-ng-model="search.filterTerm" ng-model-options="{ debounce: 500 }" data-tests-id="searchbox" /> <span class="w-sdc-search-icon" data-ng-class="{'cancel':search.filterTerm, 'magnification':!search.filterTerm}" data-ng-click="search.filterTerm=''" ></span> </div> <div class="vertical-border-container"> @@ -23,7 +23,7 @@ data-ng-change="clearForm()" data-ng-blur="clearForm()" data-required - data-tests-id="newuserid" /> + data-tests-id="newuserId" /> <div class="input-error" data-ng-show="editForm.contactId.$dirty && editForm.contactId.$invalid"> <span ng-show="editForm.contactId.$error.required" translate="NEW_USER_ERROR_USER_ID_REQUIRED"></span> @@ -67,30 +67,31 @@ <div ng-init="user.filterTerm = user.firstName + ' ' + user.lastName + ' ' + user.userId + ' ' + user.email + ' ' + user.role + ' ' + (user.lastLoginTime | date: 'MM/dd/yyyy')" ng-repeat="user in usersList | filter: search | orderBy:sortBy:reverse" data-ng-class="{'sdc-user-management-table-new-user-row': (isNewUser && $first), 'sdc-user-management-table-row-edit-mode': user.isInEditMode}" - class="sdc-user-management-flex-container data-row" data-tests-id="tdRow"> + class="sdc-user-management-flex-container data-row" data-tests-id="row_{{$index}}"> - <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[0].title}}">{{user.firstName || '---'}}</div> - <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[1].title}}">{{user.lastName || '---' }}</div> - <div class="sdc-user-management-table-col-userid sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[2].title}}">{{user.userId || '---'}}</div> - <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[3].title}}">{{user.email || '---'}}</div> - <div class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[4].title}}"> + <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="firstName_{{$index}}">{{user.firstName || '---'}}</div> + <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="lastName__{{$index}}">{{user.lastName || '---' }}</div> + <div class="sdc-user-management-flex-item" data-tests-id="userId_{{$index}}">{{user.userId || '---'}}</div> + <div sdc-smart-tooltip class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="email_{{$index}}">{{user.email || '---'}}</div> + <div class="sdc-user-management-table-col-general sdc-user-management-flex-item"> <div class="sdc-user-management-table-role-select capitalize sdc-user-management-table-role-label" data-ng-if="!user.isInEditMode" + data-tests-id="role_{{$index}}" data-ng-bind="getTitle(user.role)"></div> <select class="sdc-user-management-table-role-select capitalize" - data-tests-id="tdselectrole" + data-tests-id="selectRole_{{$index}}" data-ng-if="user.isInEditMode" data-ng-model="user.tempRole" data-ng-options="role as (getTitle(role)) for role in roles | orderBy:'role'"> </select> </div> - <div class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="td{{tableHeadersList[5].title}}">{{user.lastLoginTime == 0 ? 'Waiting' : (user.lastLoginTime | date:'MM/dd/yyyy')}}</div> + <div class="sdc-user-management-table-col-general sdc-user-management-flex-item" data-tests-id="lastActive_{{$index}}">{{user.lastLoginTime == 0 ? 'Waiting' : (user.lastLoginTime | date:'MM/dd/yyyy')}}</div> <div class="sdc-user-management-table-btn-col sdc-user-management-flex-item"> - <button data-ng-disabled="user.isInEditMode" data-ng-hide="user.isInEditMode || currentUser.userId === user.userId" class="sdc-user-management-table-edit-btn" ng-click="onEditUserPressed(user)" data-tests-id="updateuser{{user.userId}}"> </button> - <button data-ng-show="user.isInEditMode" class="sdc-user-management-table-save-btn" ng-click="saveUserChanges(user)" data-tests-id="tdsave"> </button> + <button data-ng-disabled="user.isInEditMode" data-ng-hide="user.isInEditMode || currentUser.userId === user.userId" class="sdc-user-management-table-edit-btn" ng-click="onEditUserPressed(user)" data-tests-id="updateUser_{{$index}}"> </button> + <button data-ng-show="user.isInEditMode" class="sdc-user-management-table-save-btn" ng-click="saveUserChanges(user)" data-tests-id="save_{{$index}}"> </button> </div> <div class="sdc-user-management-table-btn-col sdc-user-management-flex-item"> - <button data-ng-hide="currentUser.userId === user.userId" class="sdc-user-management-table-delete-btn" ng-click="deleteUser(user.userId)" data-tests-id="delete{{user.userId}}"> </button> + <button data-ng-hide="currentUser.userId === user.userId" class="sdc-user-management-table-delete-btn" ng-click="deleteUser(user.userId)" data-tests-id="delete_{{$index}}"> </button> </div> </div> diff --git a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management.less b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management.less index 934faab9e7..934faab9e7 100644 --- a/catalog-ui/app/scripts/view-models/admin-dashboard/user-management/user-management.less +++ b/catalog-ui/src/app/view-models/admin-dashboard/user-management/user-management.less diff --git a/catalog-ui/src/app/view-models/catalog/catalog-view-model.ts b/catalog-ui/src/app/view-models/catalog/catalog-view-model.ts new file mode 100644 index 0000000000..0e7e4aaeae --- /dev/null +++ b/catalog-ui/src/app/view-models/catalog/catalog-view-model.ts @@ -0,0 +1,303 @@ +'use strict'; +import {Component, IMainCategory, IGroup, IConfigStatuses, IAppMenu, IAppConfigurtaion, IUserProperties, ISubCategory} from "app/models"; +import {EntityService, IUserResourceClass, CacheService} from "app/services"; +import {ComponentFactory, ResourceType, MenuHandler, ChangeLifecycleStateHandler} from "app/utils"; + + +interface Checkboxes { + componentTypes:Array<string>; + resourceSubTypes:Array<string>; +} + +interface CheckboxesFilter { + // Types + selectedComponentTypes:Array<string>; + selectedResourceSubTypes:Array<string>; + // Categories + selectedCategoriesModel:Array<string>; + // Statuses + selectedStatuses:Array<string>; +} + +interface Gui { + isLoading:boolean; + onResourceSubTypesClick:Function; + onComponentTypeClick:Function; + onCategoryClick:Function; + onSubcategoryClick:Function; + onGroupClick:Function; +} + +export interface ICatalogViewModelScope extends ng.IScope { + checkboxes:Checkboxes; + checkboxesFilter:CheckboxesFilter; + gui:Gui; + + categories:Array<IMainCategory>; + confStatus:IConfigStatuses; + sdcMenu:IAppMenu; + catalogFilterdItems:Array<Component>; + expandedSection:Array<string>; + actionStrategy:any; + user:IUserProperties; + catalogMenuItem:any; + version:string; + sortBy:string; + reverse:boolean; + vfcmtType:string; + + //this is for UI paging + numberOfItemToDisplay:number; + isAllItemDisplay:boolean; + + changeLifecycleState(entity:any, state:string):void; + sectionClick (section:string):void; + order(sortBy:string):void; + getNumOfElements(num:number):string; + goToComponent(component:Component):void; + raiseNumberOfElementToDisplay():void; +} + +export class CatalogViewModel { + static '$inject' = [ + '$scope', + '$filter', + 'Sdc.Services.EntityService', + 'sdcConfig', + 'sdcMenu', + '$state', + '$q', + 'Sdc.Services.UserResourceService', + 'Sdc.Services.CacheService', + 'ComponentFactory', + 'ChangeLifecycleStateHandler', + 'MenuHandler' + ]; + + constructor(private $scope:ICatalogViewModelScope, + private $filter:ng.IFilterService, + private EntityService:EntityService, + private sdcConfig:IAppConfigurtaion, + private sdcMenu:IAppMenu, + private $state:ng.ui.IStateService, + private $q:ng.IQService, + private userResourceService:IUserResourceClass, + private cacheService:CacheService, + private ComponentFactory:ComponentFactory, + private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler, + private MenuHandler:MenuHandler) { + + + this.initScopeMembers(); + this.initCatalogData(); // Async task to get catalog from server. + this.initScopeMethods(); + } + + private initCatalogData = ():void => { + let onSuccess = (followedResponse:Array<Component>):void => { + this.$scope.catalogFilterdItems = followedResponse; + this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; + this.$scope.categories = this.cacheService.get('serviceCategories').concat(this.cacheService.get('resourceCategories')).concat(this.cacheService.get('productCategories')); + this.$scope.gui.isLoading = false; + }; + + let onError = ():void => { + console.info('Failed to load catalog CatalogViewModel::initCatalog'); + this.$scope.gui.isLoading = false; + }; + this.EntityService.getCatalog().then(onSuccess, onError); + }; + + + private initScopeMembers = ():void => { + // Gui init + this.$scope.gui = <Gui>{}; + this.$scope.gui.isLoading = true; + this.$scope.numberOfItemToDisplay = 0; + //this.$scope.categories = this.cacheService.get('categoriesMap'); + this.$scope.sdcMenu = this.sdcMenu; + this.$scope.confStatus = this.sdcMenu.statuses; + this.$scope.expandedSection = ["type", "category", "product-category", "status"]; + this.$scope.user = this.userResourceService.getLoggedinUser(); + this.$scope.catalogMenuItem = this.sdcMenu.catalogMenuItem; + this.$scope.version = this.cacheService.get('version'); + this.$scope.sortBy = 'lastUpdateDate'; + this.$scope.reverse = true; + + + // Checklist init + this.$scope.checkboxes = <Checkboxes>{}; + this.$scope.checkboxes.componentTypes = ['Resource', 'Service', 'Product']; + this.$scope.checkboxes.resourceSubTypes = ['VF', 'VFC', 'CP', 'VL']; + + // Checkboxes filter init + this.$scope.checkboxesFilter = <CheckboxesFilter>{}; + this.$scope.checkboxesFilter.selectedComponentTypes = []; + this.$scope.checkboxesFilter.selectedResourceSubTypes = []; + this.$scope.checkboxesFilter.selectedCategoriesModel = []; + this.$scope.checkboxesFilter.selectedStatuses = []; + + // this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; + + this.$scope.vfcmtType = ResourceType.VFCMT; + }; + + private initScopeMethods = ():void => { + this.$scope.sectionClick = (section:string):void => { + let index:number = this.$scope.expandedSection.indexOf(section); + if (index !== -1) { + this.$scope.expandedSection.splice(index, 1); + } else { + this.$scope.expandedSection.push(section); + } + }; + + + this.$scope.order = (sortBy:string):void => {//default sort by descending last update. default for alphabetical = ascending + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : (sortBy === 'lastUpdateDate') ? true : false; + this.$scope.sortBy = sortBy; + }; + + + this.$scope.goToComponent = (component:Component):void => { + this.$scope.gui.isLoading = true; + this.$state.go('workspace.general', {id: component.uniqueId, type: component.componentType.toLowerCase()}); + }; + + + // Will print the number of elements found in catalog + this.$scope.getNumOfElements = (num:number):string => { + if (!num || num === 0) { + return "No Elements found"; + } else if (num === 1) { + return "1 Element found"; + } else { + return num + " Elements found"; + } + }; + + /** + * Select | unselect sub resource when resource is clicked | unclicked. + * @param type + */ + this.$scope.gui.onComponentTypeClick = (type:string):void => { + if (type === 'Resource') { + if (this.$scope.checkboxesFilter.selectedComponentTypes.indexOf('Resource') === -1) { + // If the resource was not selected, unselect all childs. + this.$scope.checkboxesFilter.selectedResourceSubTypes = []; + } else { + // If the resource was selected, select all childs + this.$scope.checkboxesFilter.selectedResourceSubTypes = angular.copy(this.$scope.checkboxes.resourceSubTypes); + } + } + }; + + /** + * Selecting | unselect resources when sub resource is clicked | unclicked. + */ + this.$scope.gui.onResourceSubTypesClick = ():void => { + if (this.$scope.checkboxesFilter.selectedResourceSubTypes && this.$scope.checkboxesFilter.selectedResourceSubTypes.length === this.$scope.checkboxes.resourceSubTypes.length) { + this.$scope.checkboxesFilter.selectedComponentTypes.push('Resource'); + } else { + this.$scope.checkboxesFilter.selectedComponentTypes = _.without(this.$scope.checkboxesFilter.selectedComponentTypes, 'Resource'); + } + }; + + this.$scope.gui.onCategoryClick = (category:IMainCategory):void => { + // Select | Unselect all childs + if (this.isCategorySelected(category.uniqueId)) { + this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(category.subcategories, (item) => { + return item.uniqueId; + }))); + if (category.subcategories) { + category.subcategories.forEach((sub:ISubCategory)=> { // Loop on all selected subcategories and mark the childrens + this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(sub.groupings, (item) => { + return item.uniqueId; + }))); + }); + } + } else { + this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(category.subcategories, (item) => { + return item.uniqueId; + })); + if (category.subcategories) { + category.subcategories.forEach((sub:ISubCategory)=> { // Loop on all selected subcategories and un mark the childrens + this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(sub.groupings, (item) => { + return item.uniqueId; + })); + }); + } + } + }; + + this.$scope.gui.onSubcategoryClick = (category:IMainCategory, subCategory:ISubCategory):void => { + // Select | Unselect all childs + if (this.isCategorySelected(subCategory.uniqueId)) { + this.$scope.checkboxesFilter.selectedCategoriesModel = this.$scope.checkboxesFilter.selectedCategoriesModel.concat(angular.copy(_.map(subCategory.groupings, (item) => { + return item.uniqueId; + }))); + } else { + this.$scope.checkboxesFilter.selectedCategoriesModel = _.difference(this.$scope.checkboxesFilter.selectedCategoriesModel, _.map(subCategory.groupings, (item) => { + return item.uniqueId; + })); + } + + // Mark | Un mark the parent when all childs selected. + if (this.areAllCategoryChildsSelected(category)) { + // Add the category to checkboxesFilter.selectedCategoriesModel + this.$scope.checkboxesFilter.selectedCategoriesModel.push(category.uniqueId); + } else { + this.$scope.checkboxesFilter.selectedCategoriesModel = _.without(this.$scope.checkboxesFilter.selectedCategoriesModel, category.uniqueId); + } + + }; + + this.$scope.raiseNumberOfElementToDisplay = ():void => { + this.$scope.numberOfItemToDisplay = this.$scope.numberOfItemToDisplay + 35; + if (this.$scope.catalogFilterdItems) { + this.$scope.isAllItemDisplay = this.$scope.numberOfItemToDisplay >= this.$scope.catalogFilterdItems.length; + } + }; + + this.$scope.gui.onGroupClick = (subCategory:ISubCategory):void => { + // Mark | Un mark the parent when all childs selected. + if (this.areAllSubCategoryChildsSelected(subCategory)) { + // Add the category to checkboxesFilter.selectedCategoriesModel + this.$scope.checkboxesFilter.selectedCategoriesModel.push(subCategory.uniqueId); + } else { + this.$scope.checkboxesFilter.selectedCategoriesModel = _.without(this.$scope.checkboxesFilter.selectedCategoriesModel, subCategory.uniqueId); + } + }; + + + }; + + private areAllCategoryChildsSelected = (category:IMainCategory):boolean => { + if (!category.subcategories) { + return false; + } + let allIds = _.map(category.subcategories, (sub:ISubCategory)=> { + return sub.uniqueId; + }); + let total = _.intersection(this.$scope.checkboxesFilter.selectedCategoriesModel, allIds); + return total.length === category.subcategories.length ? true : false; + }; + + private areAllSubCategoryChildsSelected = (subCategory:ISubCategory):boolean => { + if (!subCategory.groupings) { + return false; + } + let allIds = _.map(subCategory.groupings, (group:IGroup)=> { + return group.uniqueId; + }); + let total = _.intersection(this.$scope.checkboxesFilter.selectedCategoriesModel, allIds); + return total.length === subCategory.groupings.length ? true : false; + }; + + private isCategorySelected = (uniqueId:string):boolean => { + if (this.$scope.checkboxesFilter.selectedCategoriesModel.indexOf(uniqueId) !== -1) { + return true; + } + return false; + }; +} diff --git a/catalog-ui/app/scripts/view-models/catalog/catalog-view.html b/catalog-ui/src/app/view-models/catalog/catalog-view.html index 0d46dc2a24..03ca4cb81f 100644 --- a/catalog-ui/app/scripts/view-models/catalog/catalog-view.html +++ b/catalog-ui/src/app/view-models/catalog/catalog-view.html @@ -54,11 +54,10 @@ <span class="i-sdc-designer-leftbar-section-title-text" data-tests-id="categoriesFilterTitle">Categories</span> </div> <div class="i-sdc-designer-leftbar-section-content"> - <!-- CATEGORY CHECKBOX --> <ul class="list-unstyled i-sdc-designer-leftbar-section-content-ul"> <li class="i-sdc-designer-leftbar-section-content-ul-li" - data-ng-repeat="category in categories track by category.uniqueId | categoryTypeFilter:checkboxesFilter.selectedComponentTypes | orderBy: category"> + data-ng-repeat="category in categories | categoryTypeFilter:checkboxesFilter.selectedComponentTypes:checkboxesFilter.selectedResourceSubTypes | orderBy: category"> <sdc-checkbox elem-id="checkbox-{{category.uniqueId | lowercase | clearWhiteSpaces}}" sdc-checklist-model="checkboxesFilter.selectedCategoriesModel" @@ -136,7 +135,7 @@ <!-- HEADER --> <div> <div class="w-sdc-dashboard-catalog-header"> - {{getNumOfElements((catalogFilterdItems | entityFilter:checkboxesFilter | filter:search).length)}} + {{getNumOfElements((catalogFilterdItems| filter:{resourceType:('!'+vfcmtType)} | entityFilter:checkboxesFilter | filter:search).length)}} </div> <div class="w-sdc-dashboard-catalog-header-right"> <span class="w-sdc-dashboard-catalog-header-order" translate="SORT_CAPTION"></span> @@ -151,35 +150,43 @@ </div> <div infinite-scroll-disabled='isAllItemDisplay' infinite-scroll="raiseNumberOfElementToDisplay()" infinite-scroll-container="'#catalog-main-scroll'" infinite-scroll-parent> - <!-- CARDS --> - <div data-ng-class="{'sdc-hide-popover': hidePopover}" - data-ng-init="component.filterTerm = component.name + ' ' + component.description + ' ' + component.tags.toString() + ' ' + component.version" - class="w-sdc-dashboard-card" - data-ng-repeat="component in catalogFilterdItems | entityFilter:checkboxesFilter | filter:search | orderBy:sortBy:reverse | limitTo:numberOfItemToDisplay" - data-ng-class="{'resource' : component.isResource(), 'service' : component.isService(), 'product' : component.isProduct()}"> - - <div class="w-sdc-dashboard-card-body" data-ng-click="gui.isLoading || goToComponent(component)"> - <div class="w-sdc-dashboard-card-avatar"><span data-tests-id="asset-type" class="{{component.getComponentSubType()}}"></span></div> - <!--<div class="w-sdc-dashboard-card-edit " data-ng-class="component.lifecycleState" data-tests-id="assetlifecycleState {{getStatus()}}"></div>--> - <div class="w-sdc-dashboard-card-schema-image {{component.icon}}" data-tests-id="{{component.categories[0].subcategories[0].uniqueId}}" data-ng-class="{'sprite-resource-icons':component.isResource(), 'sprite-services-icons':component.isService(), 'sprite-product-icons':component.isProduct()}"></div> - <!--<div class="w-sdc-dashboard-card-description">{{component.description}}</div>--> - <div class="w-sdc-dashboard-card-info-name-container"> - <span class="w-sdc-dashboard-card-info-name" tooltips - tooltip-content="{{component.name | resourceName}}"> {{component.name | resourceName}}</span> - </div> - </div> - <div class="w-sdc-dashboard-card-footer"> - <div class="w-sdc-dashboard-card-info"> - <div class="w-sdc-dashboard-card-info-lifecycleState"> - <span class="w-sdc-dashboard-card-info-lifecycleState" tooltips - tooltip-content="{{component.getStatus(sdcMenu)}}"> {{component.getStatus(sdcMenu)}}</span> + <div class='w-sdc-row-flex-items'> + + <!-- Tile new --> + <div data-ng-init="component.filterTerm = component.name + ' ' + component.description + ' ' + component.tags.toString() + ' ' + component.version" + class="sdc-tile-catalog sdc-tile-fix-width" + data-ng-repeat="component in catalogFilterdItems| filter:{resourceType:('!'+vfcmtType)} | entityFilter:checkboxesFilter | filter:search | orderBy:sortBy:reverse | limitTo:numberOfItemToDisplay" + > + + <div class="sdc-tile-header"> + <div class='sdc-tile-header-type' data-ng-class="{'purple': component.isResource(), 'blue': !component.isResource()}"> + <div data-ng-if="component.isResource()" data-tests-id="asset-type">{{component.getComponentSubType()}}</div> + <div data-ng-if="component.isService()">S</div> + </div> + </div> + <div class='sdc-tile-content' data-ng-click="gui.isLoading || goToComponent(component)"> + <div class='sdc-tile-content-icon'> + <div class="{{component.iconSprite}} {{component.icon}}" + data-ng-class="{'sprite-resource-icons': component.isResource(), 'sprite-services-icons': component.isService()}" + data-tests-id="{{component.name}}"></div> + </div> + <div class='sdc-tile-content-info'> + <div class="sdc-tile-content-info-item-name" data-tests-id="{{component.name | resourceName}}" sdc-smart-tooltip>{{component.name | resourceName}}</div> + <div class="sdc-tile-content-info-version-info"> + <div class="sdc-tile-content-info-version-info-text" data-tests-id="{{component.name}}Version">V {{component.version}}</div> + </div> </div> - <div class="w-sdc-dashboard-card-info-user">V {{component.version}}</div> </div> - <!--<div class="w-sdc-dashboard-card-info-lifecycleState-icon sprite-new {{sdcMenu.LifeCycleStatuses[component.lifecycleState].icon}}"></div>--> + <div class='sdc-tile-footer'> + <div class='sdc-tile-footer-text'>{{component.getStatus(sdcMenu)}}</div> + </div> + </div> + <!-- Tile new --> + </div> + </div> </perfect-scrollbar> @@ -187,4 +194,6 @@ <top-nav top-lvl-selected-index="1" search-bind="search.filterTerm" version="{{version}}"></top-nav> + <ecomp-footer></ecomp-footer> + </div> diff --git a/catalog-ui/app/scripts/view-models/catalog/catalog.less b/catalog-ui/src/app/view-models/catalog/catalog.less index 8be90a6a59..9db9192167 100644 --- a/catalog-ui/app/scripts/view-models/catalog/catalog.less +++ b/catalog-ui/src/app/view-models/catalog/catalog.less @@ -83,7 +83,7 @@ &.NOT_CERTIFIED_CHECKOUT, &.NOT_CERTIFIED_CHECKIN { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2889px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2889px; width: 14px; height: 14px; @@ -92,7 +92,7 @@ &.CERTIFIED { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -3034px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -3034px; width: 14px; height: 16px; } @@ -100,7 +100,7 @@ &.READY_FOR_CERTIFICATION { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2985px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2985px; width: 14px; height: 16px; } @@ -108,7 +108,7 @@ &.CERTIFICATION_IN_PROGRESS { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2934px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2934px; width: 14px; height: 16px; } @@ -117,7 +117,7 @@ &.DISTRIBUTED, &.TBD { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -43px -3087px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -43px -3087px; width: 24px; height: 14px; diff --git a/catalog-ui/src/app/view-models/dashboard/dashboard-view-model.ts b/catalog-ui/src/app/view-models/dashboard/dashboard-view-model.ts new file mode 100644 index 0000000000..d0b74a9062 --- /dev/null +++ b/catalog-ui/src/app/view-models/dashboard/dashboard-view-model.ts @@ -0,0 +1,387 @@ +'use strict'; +import {IConfigRoles, IAppConfigurtaion, IAppMenu, IUserProperties, Component} from "app/models"; +import {EntityService, IUserResourceClass, SharingService, CacheService} from "app/services"; +import {ComponentType, ResourceType, MenuHandler, ModalsHandler, ChangeLifecycleStateHandler, SEVERITY, ComponentFactory} from "app/utils"; +import {IClientMessageModalModel} from "../modals/message-modal/message-client-modal/client-message-modal-view-model"; + +export interface IDashboardViewModelScope extends ng.IScope { + + isLoading:boolean; + components:Array<Component>; + folders:FoldersMenu; + roles:IConfigRoles; + user:IUserProperties; + sdcConfig:IAppConfigurtaion; + sdcMenu:IAppMenu; + sharingService:SharingService; + showTutorial:boolean; + isFirstTime:boolean; + version:string; + checkboxesFilter:CheckboxesFilter; + vfcmtType:string; + + + onImportVfc(file:any):void; + onImportVf(file:any):void; + openCreateModal(componentType:ComponentType, importedFile:any):void; + openWhatsNewModal(version:string):void; + openDesignerModal(isResource:boolean, uniqueId:string):void; + setSelectedFolder(folderItem:FoldersItemsMenu):void; + entitiesCount(folderItem:FoldersItemsMenu):number; + getCurrentFolderDistributed():Array<Component>; + changeLifecycleState(entity:any, data:any):void; + goToComponent(component:Component):void; + wizardDebugEdit:Function; + notificationIconCallback:Function; +} + +interface CheckboxesFilter { + // Statuses + selectedStatuses:Array<string>; + // distributed + distributed:Array<string>; +} + +export interface IItemMenu { + +} + +export interface IMenuItemProperties { + text:string; + group:string; + state:string; + dist:string; + groupname:string; + states:Array<any>; +} + +export class FoldersMenu { + + private _folders:Array<FoldersItemsMenu> = []; + + constructor(folders:Array<IMenuItemProperties>) { + let self = this; + folders.forEach(function (folder:IMenuItemProperties) { + if (folder.groupname) { + self._folders.push(new FoldersItemsMenuGroup(folder)); + } else { + self._folders.push(new FoldersItemsMenu(folder)); + } + }); + self._folders[0].setSelected(true); + } + + public getFolders = ():Array<FoldersItemsMenu> => { + return this._folders; + }; + + public getCurrentFolder = ():FoldersItemsMenu => { + let menuItem:FoldersItemsMenu = undefined; + this.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { + if (tmpFolder.isSelected()) { + menuItem = tmpFolder; + } + }); + return menuItem; + }; + + public setSelected = (folder:FoldersItemsMenu):void => { + this.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { + tmpFolder.setSelected(false); + }); + folder.setSelected(true); + } + +} + +export class FoldersItemsMenu implements IItemMenu { + + public text:string; + public group:string; + public state:string; + public dist:string; + public states:Array<any>; + + private selected:boolean = false; + + constructor(menuProperties:IMenuItemProperties) { + this.text = menuProperties.text; + this.group = menuProperties.group; + this.state = menuProperties.state; + this.states = menuProperties.states; + this.dist = menuProperties.dist; + } + + public isSelected = ():boolean => { + return this.selected; + }; + + public setSelected = (value:boolean):void => { + this.selected = value; + }; + + public isGroup = ():boolean => { + return false; + } + +} + +export class FoldersItemsMenuGroup extends FoldersItemsMenu { + + public groupname:string; + + constructor(menuProperties:IMenuItemProperties) { + super(menuProperties); + this.groupname = menuProperties.groupname; + } + + public isGroup = ():boolean => { + return true; + } + +} + +export class DashboardViewModel { + static '$inject' = [ + '$scope', + '$filter', + 'Sdc.Services.EntityService', + '$http', + 'sdcConfig', + 'sdcMenu', + '$state', + '$stateParams', + 'Sdc.Services.UserResourceService', + 'Sdc.Services.SharingService', + 'Sdc.Services.CacheService', + '$q', + 'ComponentFactory', + 'ChangeLifecycleStateHandler', + 'ModalsHandler', + 'MenuHandler' + ]; + + private components:Array<Component>; + + constructor(private $scope:IDashboardViewModelScope, + private $filter:ng.IFilterService, + private entityService:EntityService, + private $http:ng.IHttpService, + private sdcConfig:IAppConfigurtaion, + private sdcMenu:IAppMenu, + private $state:any, + private $stateParams:any, + private userResourceService:IUserResourceClass, + private sharingService:SharingService, + private cacheService:CacheService, + private $q:ng.IQService, + private ComponentFactory:ComponentFactory, + private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler, + private ModalsHandler:ModalsHandler, + private MenuHandler:MenuHandler) { + this.initScope(); + this.initFolders(); + this.initEntities(true); + + if (this.$stateParams) { + + if (this.$state.params.folder) { + let self = this; + let folderName = this.$state.params.folder.replaceAll("_", " "); + + this.$scope.folders.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { + if (tmpFolder.text === folderName) { + self.$scope.setSelectedFolder(tmpFolder); + } + }); + } + + // Show the tutorial if needed when the dashboard page is opened.<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script> + // This is called from the welcome page. + else if (this.$stateParams.show === 'tutorial') { + this.$scope.showTutorial = true; + this.$scope.isFirstTime = true; + } + } + } + + private initFolders = ():void => { + if (this.$scope.user) { + this.$scope.folders = new FoldersMenu(this.$scope.roles[this.$scope.user.role].folder); + } + }; + + private initScope = ():void => { + let self = this; + + this.$scope.version = this.cacheService.get('version'); + this.$scope.sharingService = this.sharingService; + this.$scope.isLoading = false; + this.$scope.sdcConfig = this.sdcConfig; + this.$scope.sdcMenu = this.sdcMenu; + this.$scope.user = this.userResourceService.getLoggedinUser(); + this.$scope.roles = this.sdcMenu.roles; + this.$scope.showTutorial = false; + this.$scope.isFirstTime = false; + this.$scope.vfcmtType = ResourceType.VFCMT; + + // Open onboarding modal + this.$scope.notificationIconCallback = ():void => { + this.ModalsHandler.openOnboadrdingModal('Import').then(()=> { + // OK + }, ()=> { + // ERROR + }); + }; + + // Checkboxes filter init + this.$scope.checkboxesFilter = <CheckboxesFilter>{}; + this.$scope.checkboxesFilter.selectedStatuses = []; + this.$scope.checkboxesFilter.distributed = []; + + this.$scope.onImportVf = (file:any):void => { + if (file && file.filename) { + // Check that the file has valid extension. + let fileExtension:string = file.filename.split(".").pop(); + if (this.sdcConfig.csarFileExtension.indexOf(fileExtension.toLowerCase()) !== -1) { + this.$state.go('workspace.general', { + type: ComponentType.RESOURCE.toLowerCase(), + importedFile: file, + resourceType: ResourceType.VF + }); + } else { + let data:IClientMessageModalModel = { + title: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_CSAR_EXTENSIONS_TITLE"), + message: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_CSAR_EXTENSIONS", "{'extensions': '" + this.sdcConfig.csarFileExtension + "'}"), + severity: SEVERITY.ERROR + }; + this.ModalsHandler.openClientMessageModal(data); + } + } + }; + + this.$scope.onImportVfc = (file:any):void => { + if (file && file.filename) { + // Check that the file has valid extension. + let fileExtension:string = file.filename.split(".").pop(); + if (this.sdcConfig.toscaFileExtension.indexOf(fileExtension.toLowerCase()) !== -1) { + this.$state.go('workspace.general', { + type: ComponentType.RESOURCE.toLowerCase(), + importedFile: file, + resourceType: ResourceType.VFC + }); + } else { + let data:IClientMessageModalModel = { + title: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_TOSCA_EXTENSIONS_TITLE"), + message: self.$filter('translate')("NEW_SERVICE_RESOURCE_ERROR_VALID_TOSCA_EXTENSIONS", "{'extensions': '" + this.sdcConfig.toscaFileExtension + "'}"), + severity: SEVERITY.ERROR + }; + this.ModalsHandler.openClientMessageModal(data); + } + } + }; + + this.$scope.openCreateModal = (componentType:string, importedFile:any):void => { + if (importedFile) { + this.initEntities(true); // Return from import + } else { + this.$state.go('workspace.general', {type: componentType.toLowerCase()}); + } + + }; + + this.$scope.entitiesCount = (folderItem:FoldersItemsMenu):any => { + let self = this; + let total:number = 0; + if (folderItem.isGroup()) { + this.$scope.folders.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { + if (tmpFolder.group && tmpFolder.group === (<FoldersItemsMenuGroup>folderItem).groupname) { + total = total + self._getTotalCounts(tmpFolder, self); + } + }); + } else { + total = total + self._getTotalCounts(folderItem, self); + } + return total; + }; + + this.$scope.getCurrentFolderDistributed = ():Array<any> => { + let self = this; + let states = []; + if (this.$scope.folders) { + let folderItem:FoldersItemsMenu = this.$scope.folders.getCurrentFolder(); + if (folderItem.isGroup()) { + this.$scope.folders.getFolders().forEach(function (tmpFolder:FoldersItemsMenu) { + if (tmpFolder.group && tmpFolder.group === (<FoldersItemsMenuGroup>folderItem).groupname) { + self._setStates(tmpFolder, states); + } + }); + } else { + self._setStates(folderItem, states); + } + } + return states; + }; + + this.$scope.setSelectedFolder = (folderItem:FoldersItemsMenu):void => { + this.$scope.folders.setSelected(folderItem); + }; + + this.$scope.goToComponent = (component:Component):void => { + this.$scope.isLoading = true; + this.$state.go('workspace.general', {id: component.uniqueId, type: component.componentType.toLowerCase()}); + }; + + }; + + private _getTotalCounts(tmpFolder, self):number { + let total:number = 0; + if (tmpFolder.dist !== undefined) { + let distributions = tmpFolder.dist.split(','); + distributions.forEach((item:any) => { + total = total + self.getEntitiesByStateDist(tmpFolder.state, item).length; + }); + } + else { + total = total + self.getEntitiesByStateDist(tmpFolder.state, tmpFolder.dist).length; + } + return total; + } + + private _setStates(tmpFolder, states) { + if (tmpFolder.states !== undefined) { + tmpFolder.states.forEach(function (item:any) { + states.push({"state": item.state, "dist": item.dist}); + }); + } else { + states.push({"state": tmpFolder.state, "dist": tmpFolder.dist}); + } + } + + private initEntities = (reload:boolean):void => { + this.$scope.isLoading = reload; + this.entityService.getAllComponents().then( + (components:Array<Component>) => { + this.components = components; + this.$scope.components = components; + this.$scope.isLoading = false; + }); + }; + + private getEntitiesByStateDist = (state:string, dist:string):Array<Component> => { + let gObj:Array<Component>; + if (this.components && (state || dist)) { + gObj = this.components.filter(function (obj:Component) { + if (dist !== undefined && obj.distributionStatus === dist && obj.lifecycleState === state) { + return true; + } else if (dist === undefined && obj.lifecycleState === state) { + return true; + } + return false; + }); + } else { + gObj = []; + } + return gObj; + } +} diff --git a/catalog-ui/src/app/view-models/dashboard/dashboard-view.html b/catalog-ui/src/app/view-models/dashboard/dashboard-view.html new file mode 100644 index 0000000000..806bb8138d --- /dev/null +++ b/catalog-ui/src/app/view-models/dashboard/dashboard-view.html @@ -0,0 +1,112 @@ + +<div class="sdc-catalog-container"> + <loader data-display="isLoading"></loader> + <!-- HEADER --> +<!-- + <ecomp-header menu-data="menuItems" version="{{version}}"></ecomp-header> +--> + + <div class="w-sdc-main-container"> + + <perfect-scrollbar include-padding="true" class="w-sdc-main-right-container"> + + <div class='w-sdc-row-flex-items'> + + <!-- ADD Component --> + <div ng-if="user.role === 'DESIGNER' || user.role === 'PRODUCT_MANAGER'" class="w-sdc-dashboard-card-new" + data-ng-mouseleave="displayActions = false" + data-ng-mouseover="displayActions = true" + data-ng-init="displayActions = false"> + <div class="w-sdc-dashboard-card-new-content" data-tests-id="AddButtonsArea"> + <div class="w-sdc-dashboard-card-new-content-plus" data-ng-show="!displayActions"></div> + <div class="sdc-dashboard-create-element-container" data-ng-show="displayActions"> + <button data-ng-if="roles[user.role].dashboard.showCreateNewProduct" data-tests-id="createProductButton" class="tlv-btn outline blue" data-ng-click="openCreateModal('PRODUCT')">Create Product</button> + <button data-ng-if="roles[user.role].dashboard.showCreateNew" data-tests-id="createResourceButton" class="tlv-btn outline blue" data-ng-click="openCreateModal('RESOURCE')">Add VF</button> + <button data-ng-if="roles[user.role].dashboard.showCreateNew" data-tests-id="createServiceButton" class="tlv-btn outline blue" data-ng-click="openCreateModal('SERVICE')">Add Service</button> + </div> + </div> + </div> + + <!-- Import Component --> + <div ng-if="user.role === 'DESIGNER'" class="w-sdc-dashboard-card-new" + data-ng-mouseleave="displayActions = false" + data-ng-mouseover="displayActions = true" + data-ng-init="displayActions = false"> + <div class="w-sdc-dashboard-card-new-content" data-tests-id="importButtonsArea" > + <div class="w-sdc-dashboard-card-import-content-plus" data-ng-show="!displayActions"></div> + <div class="sdc-dashboard-import-element-container" data-ng-show="displayActions"> + <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue">Import VFC + <file-opener on-file-upload="onImportVfc(file)" data-tests-id="importVFCbutton" extensions="{{sdcConfig.toscaFileExtension}}" data-ng-click="displayActions=false"></file-opener> + </div> + <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue" data-ng-click="notificationIconCallback()">Import VSP</div> + <div data-ng-if="roles[user.role].dashboard.showCreateNew" class="tlv-btn outline blue import-dcae">Import DCAE asset + <file-opener on-file-upload="onImportVf(file)" data-tests-id="importVFbutton" extensions="{{sdcConfig.csarFileExtension}}" data-ng-click="displayActions=false"></file-opener> + </div> + </div> + </div> + </div> + + <!-- Tile new --> + <div class="sdc-tile-catalog sdc-tile-fix-width" data-ng-repeat="component in components | filter:{resourceType:('!'+vfcmtType)} | entityFilter:checkboxesFilter | filter:search"> + + <div class="sdc-tile-header"> + <div class='sdc-tile-header-type' data-ng-class="{'purple': component.isResource(), 'blue': !component.isResource()}"> + <div data-ng-if="component.isResource()" data-tests-id="asset-type">{{component.getComponentSubType()}}</div> + <div data-ng-if="component.isService()">S</div> + </div> + </div> + <div class='sdc-tile-content' data-tests-id="dashboard-Elements" data-ng-click="goToComponent(component)"> + <div class='sdc-tile-content-icon'> + <div class="{{component.iconSprite}} {{component.icon}}" + data-ng-class="{'sprite-resource-icons': component.isResource(), 'sprite-services-icons': component.isService()}" + data-tests-id="{{component.name}}"></div> + </div> + <div class='sdc-tile-content-info'> + <div class="sdc-tile-content-info-item-name" data-tests-id="{{component.name | resourceName}}" sdc-smart-tooltip>{{component.name | resourceName}}</div> + <div class="sdc-tile-content-info-version-info"> + <div class="sdc-tile-content-info-version-info-text" data-tests-id="{{component.name}}Version">V {{component.version}}</div> + </div> + </div> + </div> + <div class='sdc-tile-footer'> + <div class='sdc-tile-footer-text'>{{component.getStatus(sdcMenu)}}</div> + </div> + + </div> + <!-- Tile new --> + + </div> + + </perfect-scrollbar> + + <div class="w-sdc-left-sidebar"> + <div class="i-sdc-left-sidebar-item " + data-ng-repeat="folder in folders.getFolders()" + data-ng-class="{'category-title': folder.isGroup(), 'selectedLink': folder.isSelected()}" + > + <span data-ng-if="folder.isGroup()">{{folder.text}}</span> + + <sdc-checkbox data-ng-if="!folder.isGroup() && !folder.dist" + elem-id="checkbox-{{folder.text | lowercase | clearWhiteSpaces}}" + sdc-checklist-model="checkboxesFilter.selectedStatuses" + sdc-checklist-value="folder.state" + text="{{folder.text}}"></sdc-checkbox> + + <sdc-checkbox data-ng-if="!folder.isGroup() && folder.dist" + elem-id="checkbox-{{folder.text | lowercase | clearWhiteSpaces}}" + sdc-checklist-model="checkboxesFilter.distributed" + sdc-checklist-value="folder.dist" + text="{{folder.text}}"></sdc-checkbox> + <span class="i-sdc-left-sidebar-item-state-count">{{entitiesCount(folder)}}</span> + </div> + </div> + + </div> + + <top-nav top-lvl-selected-index="0" version="{{version}}" search-bind="search.filterTerm" notification-icon-callback="notificationIconCallback" version="{{version}}"></top-nav> + +</div> +<div data-ui-view=""></div> + + +<ecomp-footer></ecomp-footer> diff --git a/catalog-ui/app/scripts/view-models/dashboard/dashboard.less b/catalog-ui/src/app/view-models/dashboard/dashboard.less index 7b2522113b..7993390769 100644 --- a/catalog-ui/app/scripts/view-models/dashboard/dashboard.less +++ b/catalog-ui/src/app/view-models/dashboard/dashboard.less @@ -42,11 +42,11 @@ .border-radius(2px); cursor: pointer; display: inline-block; - height: 200px; - margin: 9px; + height: 198px; + margin: 11px; position: relative; vertical-align: middle; - width: 204px; + width: 202px; } .w-sdc-dashboard-card-new-content { diff --git a/catalog-ui/src/app/view-models/dcae-app/dcae-app-view-model.ts b/catalog-ui/src/app/view-models/dcae-app/dcae-app-view-model.ts new file mode 100644 index 0000000000..9be7786f4d --- /dev/null +++ b/catalog-ui/src/app/view-models/dcae-app/dcae-app-view-model.ts @@ -0,0 +1,112 @@ +'use strict'; +import {MenuItemGroup, MenuItem} from "app/utils"; +import {BreadcrumbsPath, BreadcrumbsMenu} from "../onboard-vendor/onboard-vendor-view-model"; +import {CacheService} from "app/services"; +import {IUserProperties} from "app/models"; + +export class TestData { + breadcrumbs:BreadcrumbsPath; +} + +export interface IDcaeAppViewModelScope extends ng.IScope { + testData:TestData; + onTestEvent:Function; + topNavMenuModel:Array<MenuItemGroup>; + topNavRootMenu:MenuItemGroup; + user:IUserProperties; + version:string; +} + +export class DcaeAppViewModel { + static '$inject' = [ + '$scope', + '$q', + 'Sdc.Services.CacheService' + ]; + + private firstControlledTopNavMenu:MenuItemGroup; + + constructor(private $scope:IDcaeAppViewModelScope, + private $q:ng.IQService, + private cacheService:CacheService) { + + this.$scope.testData = { + breadcrumbs: { + selectedKeys: [] + } + }; + + this.$scope.version = this.cacheService.get('version'); + + this.$scope.onTestEvent = (eventName:string, data:any):void => { + switch (eventName) { + case 'breadcrumbsupdated': + this.handleBreadcrumbsUpdate(data); + break; + } + }; + + this.$scope.topNavMenuModel = []; + + this.$scope.user = this.cacheService.get('user'); + } + + updateBreadcrumbsPath = (selectedKeys:Array<string>):ng.IPromise<boolean> => { + let topNavMenuModel = this.$scope.topNavMenuModel; + let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); + if (startIndex === -1) { + startIndex = topNavMenuModel.length; + } + topNavMenuModel.splice(startIndex + selectedKeys.length); + this.$scope.testData = { + breadcrumbs: {selectedKeys: selectedKeys} + }; + + return this.$q.when(true); + }; + + handleBreadcrumbsUpdate(breadcrumbsMenus:Array<BreadcrumbsMenu>):void { + let selectedKeys = []; + let topNavMenus = breadcrumbsMenus.map((breadcrumbMenu, breadcrumbIndex) => { + let topNavMenu = new MenuItemGroup(); + topNavMenu.menuItems = breadcrumbMenu.menuItems.map(menuItem => + new MenuItem( + menuItem.displayText, + this.updateBreadcrumbsPath, + null, + null, + [selectedKeys.concat([menuItem.key])] + ) + ); + topNavMenu.selectedIndex = _.findIndex( + breadcrumbMenu.menuItems, + menuItem => menuItem.key === breadcrumbMenu.selectedKey + ); + selectedKeys.push(breadcrumbMenu.selectedKey); + return topNavMenu; + }); + + let topNavMenuModel = this.$scope.topNavMenuModel; + let len = topNavMenuModel.length; + let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); + if (startIndex === -1) { + startIndex = len; + } + topNavMenuModel.splice(startIndex, len - startIndex); + topNavMenuModel.push.apply(topNavMenuModel, topNavMenus); + this.firstControlledTopNavMenu = topNavMenus[0]; + + if (startIndex === 1 && this.$scope.topNavRootMenu == null) { + let topNavRootMenu = topNavMenuModel[0]; + let onboardItem = topNavRootMenu.menuItems[topNavRootMenu.selectedIndex]; + let originalCallback = onboardItem.callback; + onboardItem.callback = (...args) => { + let ret = this.updateBreadcrumbsPath([]); + return originalCallback && originalCallback.apply(undefined, args) || ret; + }; + this.$scope.topNavRootMenu = topNavRootMenu; + } + + this.updateBreadcrumbsPath(selectedKeys); + } +} diff --git a/catalog-ui/src/app/view-models/dcae-app/dcae-app-view.html b/catalog-ui/src/app/view-models/dcae-app/dcae-app-view.html new file mode 100644 index 0000000000..af0d06787a --- /dev/null +++ b/catalog-ui/src/app/view-models/dcae-app/dcae-app-view.html @@ -0,0 +1,17 @@ +<div class="sdc-catalog-container"> + + <loader data-display="gui.isLoading"></loader> +<!-- + <ecomp-header menu-data="menuItems" version="{{version}}"></ecomp-header> +--> + + <div class="w-sdc-main-container"> + <!--<div ng-include="'/dcaeapp/index.html'"/>--> + <!--<div id="dcaeAppContainer"></div>--> + <!--<punch-out name="'dcaeApp'" data="vendorData" user="user" on-event="onTestEvent"></punch-out>--> + <div id="main" ui-view="main"></div> + </div> + + <top-nav top-lvl-selected-index="3" search-bind="search.filterTerm" menu-model="topNavMenuModel" version="{{version}}"></top-nav> + +</div> diff --git a/catalog-ui/src/app/view-models/dcae-app/dcae-app.less b/catalog-ui/src/app/view-models/dcae-app/dcae-app.less new file mode 100644 index 0000000000..4a16ca2b5b --- /dev/null +++ b/catalog-ui/src/app/view-models/dcae-app/dcae-app.less @@ -0,0 +1,303 @@ +.sdc-catalog-container { + + .i-sdc-categories-list-item { + font-weight: normal; + } + + // Checkboxes + .i-sdc-designer-leftbar-section-content-ul { + padding: 0; + margin: 0; + + .i-sdc-catalog-subcategories-checkbox { + padding: 0 0 0 20px; + margin: 0; + + .i-sdc-catalog-grouping-checkbox { + padding: 0 0 0 20px; + margin: 0; + } + + } + + } + + .i-sdc-designer-leftbar-section-content-li { + &:last-child { + .i-sdc-categories-list-item { + margin: 0; + } + } + } + + .i-sdc-categories-list-item { + display: block; + //margin-bottom: 5px; + //padding-left: 15px; + //text-indent: -24px; + vertical-align: top; + font-weight: bold; + } + + .i-sdc-subcategories-list-item { + display: block; + //padding-left: 20px; + vertical-align: top; + font-weight: normal; + margin: 0; + //text-indent: -10px; + } + + /*Added by - Ikram */ + .i-sdc-product-input, + .i-sdc-product-select { + border: 1px solid @border_color_f; + min-height: 30px; + padding: 0; + width: 100%; + margin: 1px 0; + background-color: #F2F2F2; + outline: none; + + &:disabled { + .disabled; + } + optgroup{ + color: @color_u; + option{ + color: @color_b; + } + } + } + + .i-sdc-categories-list-item-icon { + display: inline-block; + float: right; + position: relative; + right: -8px; + top: 6px; + } + + .i-sdc-categories-list-item { + margin-top: 7px; + &.NOT_CERTIFIED_CHECKOUT, + &.NOT_CERTIFIED_CHECKIN { + .i-sdc-categories-list-item-icon { + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2889px; + width: 14px; + height: 14px; + + } + } + + &.CERTIFIED { + .i-sdc-categories-list-item-icon { + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -3034px; + width: 14px; + height: 16px; + } + } + + &.READY_FOR_CERTIFICATION { + .i-sdc-categories-list-item-icon { + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2985px; + width: 14px; + height: 16px; + } + } + + &.CERTIFICATION_IN_PROGRESS { + .i-sdc-categories-list-item-icon { + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2934px; + width: 14px; + height: 16px; + } + } + + &.DISTRIBUTED, + &.TBD { + .i-sdc-categories-list-item-icon { + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -43px -3087px; + width: 24px; + height: 14px; + + } + } + } + + .i-sdc-categories-list-input { + margin: 8px; + + } + + .i-sdc-subcategories-list-input { + + margin: 8px; + } + .i-sdc-subcategories-list-input-container { + margin: 0px 0px 0px 20px; + padding: 2px; + } + + .w-sdc-header-catalog-search-container { + display: table; + padding: 21px 0; + position: relative; + + .w-sdc-designer-leftbar-search-input { + color: #000; + width: 300px; + } + + // .magnification { + // .sprite; + // .sprite.magnification-glass; + // .hand; + // position: absolute; + // top: 40px; + // right: 42px; + // } + } + + .w-sdc-catalog-main { + padding: 10px 12px; + } + .w-sdc-dashboard-catalog-header { + .b_9; + display: inline-block; + font-style: italic; + font-weight: bold; + padding-left: 10px; + } + + .w-sdc-dashboard-catalog-header-order { + .b_9; + font-weight: 800; + } + + .w-sdc-dashboard-catalog-sort { + .b_9; + font-weight: bold; + white-space:pre; + &:hover{ + .hand; + text-decoration: none; + .a_9; + } + &.blue { + .a_9; + } + } + + .w-sdc-catalog-sort-arrow{ + display: inline-block; + &.up{ + .b_9; + width: 0; + height: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-bottom: 5px solid ; + } + &.down{ + .b_9; + width: 0; + height: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-top: 5px solid; + } + } + + + + + .w-sdc-dashboard-catalog-header-right{ + float: right; + display: inline-block; + padding-right:34px; + } + + .w-sdc-header-catalog-search-input { + width: 420px; + display: table-cell; + padding: 0 25px 1px 10px; + border: 1px solid #bcbcbc; + .border-radius(10px); + height: 30px; + margin: 10px 30px; + outline: none; + } + + .sdc-catalog-type-filter-container { + margin-top: -1px; + } + + .i-sdc-designer-leftbar-section-title { + text-transform: uppercase; + .l_14_m; + line-height: 30px; + } + + .i-sdc-designer-leftbar-section-title-icon { + .hand; + .tlv-sprite; + .footer-close; + transition: .3s all; + margin-top: -4px; + } + + .i-sdc-designer-leftbar-section-title-text { + margin-left: 20px; + } + + .seperator-left, + .seperator-right { + border-right: solid 1px @color_m; + display: table-cell; + width: 2px; + } + + // Rotate catalog left side arrows + .i-sdc-designer-leftbar-section-title.expanded .i-sdc-designer-leftbar-section-title-icon { + transform: rotate(180deg); + } + + // Transform catalog left side sections + .i-sdc-designer-leftbar-section-title + .i-sdc-designer-leftbar-section-content { + max-height: 0px; + margin: 0 auto; + transition: all .3s; + overflow: hidden; + padding: 0 10px 0 18px; + } + + .i-sdc-designer-leftbar-section-title.expanded + .i-sdc-designer-leftbar-section-content { + max-height: 9999px; + margin: 0 auto 1px; + transition: all .3s; + padding: 10px 18px 10px 18px; + overflow: hidden; + } + +} + +.w-sdc-search-icon{ + position: absolute; + right: 40px; + top: 40px; + &.leftbar{ + top: 19px; + right: 18px; + } + &.magnification { + .sprite; + .sprite.magnification-glass; + .hand; + } + &.cancel { + .sprite; + .sprite.clear-text; + .hand; + } +} diff --git a/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form-view-model.ts b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form-view-model.ts new file mode 100644 index 0000000000..3e912706e0 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form-view-model.ts @@ -0,0 +1,358 @@ +'use strict'; +import {ArtifactModel, Resource, Component} from "app/models"; +import {ArtifactsUtils, FormState, ValidationUtils, ArtifactType} from "app/utils"; +import {CacheService} from "app/services"; + +export interface IEditArtifactModel { + artifactResource:ArtifactModel; + artifactTypes:Array<string>; + artifactFile:any; +} + +export interface IArtifactResourceFormViewModelScope extends ng.IScope { + forms:any; + $$childTail:any; + isNew:boolean; + isLoading:boolean; + validationPattern:RegExp; + urlValidationPattern:RegExp; + labelValidationPattern:RegExp; + integerValidationPattern:RegExp; + commentValidationPattern:RegExp; + artifactType:string; + editArtifactResourceModel:IEditArtifactModel; + defaultHeatTimeout:number; + validExtensions:any; + originalArtifactName:string; + editForm:ng.IFormController; + footerButtons:Array<any>; + modalInstanceArtifact:ng.ui.bootstrap.IModalServiceInstance; + + fileExtensions():string; + save(doNotCloseModal?:boolean):void; + saveAndAnother():void; + close():void; + getOptions():Array<string>; + isDeploymentHeat():boolean; + onFileChange():void; + setDefaultTimeout():void; + openEditEnvParametersModal(artifact:ArtifactModel):void; + getFormTitle():string; + fileUploadRequired():string; + isArtifactOwner():boolean; +} + +export class ArtifactResourceFormViewModel { + + static '$inject' = [ + '$scope', + '$uibModalInstance', + 'artifact', + 'Sdc.Services.CacheService', + 'ValidationPattern', + 'UrlValidationPattern', + 'LabelValidationPattern', + 'IntegerValidationPattern', + 'CommentValidationPattern', + 'ValidationUtils', + '$base64', + '$state', + 'ArtifactsUtils', + '$uibModal', + 'component' + ]; + + private formState:FormState; + private entityId:string; + + constructor(private $scope:IArtifactResourceFormViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private artifact:ArtifactModel, + private cacheService:CacheService, + private ValidationPattern:RegExp, + private UrlValidationPattern:RegExp, + private LabelValidationPattern:RegExp, + private IntegerValidationPattern:RegExp, + private CommentValidationPattern:RegExp, + private ValidationUtils:ValidationUtils, + private $base64:any, + private $state:any, + private artifactsUtils:ArtifactsUtils, + private $uibModal:ng.ui.bootstrap.IModalService, + private component:Component) { + + + this.entityId = this.component.uniqueId; + this.formState = angular.isDefined(artifact.artifactLabel) ? FormState.UPDATE : FormState.CREATE; + this.initScope(); + } + + private initEntity = ():void => { + this.$scope.editArtifactResourceModel.artifactResource = this.artifact; + this.$scope.originalArtifactName = this.artifact.artifactName; + }; + + + private initFooterButtons = ():void => { + + this.$scope.footerButtons = [ + {'name': 'Done', 'css': 'blue', 'callback': this.$scope.save} + ]; + if (this.$scope.isNew) { + this.$scope.footerButtons.push({ + 'name': 'Add Another', + 'css': 'grey', + 'disabled': !this.$scope.isNew && 'deployment' === this.$scope.artifactType, + 'callback': this.$scope.saveAndAnother + }); + } + }; + + private filterDeploymentArtifactTypeByResourceType = (resourceType:string):any => { + let result = {}; + _.each(this.$scope.validExtensions, function (typeSettings:any, typeName:string) { + if (!typeSettings.validForResourceTypes || typeSettings.validForResourceTypes.indexOf(resourceType) > -1) { + result[typeName] = typeSettings; + } + }); + + return result; + }; + + private initArtifactTypes = ():void => { + + let artifactTypes:any = this.cacheService.get('UIConfiguration'); + + if ('deployment' === this.$scope.artifactType) { + + + if ('HEAT_ENV' == this.artifact.artifactType || this.component.selectedInstance) { + this.$scope.validExtensions = artifactTypes.artifacts.deployment.resourceInstanceDeploymentArtifacts; + } else if (this.component.isResource()) { + this.$scope.validExtensions = artifactTypes.artifacts.deployment.resourceDeploymentArtifacts; + this.$scope.validExtensions = this.filterDeploymentArtifactTypeByResourceType((<Resource>this.component).resourceType); + } else { + this.$scope.validExtensions = artifactTypes.artifacts.deployment.serviceDeploymentArtifacts; + } + + if (this.$scope.validExtensions) { + this.$scope.editArtifactResourceModel.artifactTypes = Object.keys(this.$scope.validExtensions); + } + this.$scope.defaultHeatTimeout = artifactTypes.defaultHeatTimeout; + if (this.$scope.isNew) { + let isHeat = 'HEAT_ENV' == this.artifact.artifactType; + _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { + return 'HEAT' == item.substring(0, 4) || (!isHeat && item == "VF_MODULES_METADATA") || + _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, item); + }); + } + + } + if (this.$scope.artifactType === 'informational') { + this.$scope.editArtifactResourceModel.artifactTypes = artifactTypes.artifacts.other.map((element:any)=> { + return element.name; + }); + _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string)=> { + return _.has(ArtifactType.THIRD_PARTY_RESERVED_TYPES, item) || + _.has(ArtifactType.TOSCA, item); + }) + } + + if (this.component.isResource() && (<Resource>this.component).isCsarComponent()) { + _.remove(this.$scope.editArtifactResourceModel.artifactTypes, (item:string) => { + return this.artifactsUtils.isLicenseType(item); + }) + } + + }; + + private initEditArtifactResourceModel = ():void => { + this.$scope.editArtifactResourceModel = { + artifactResource: null, + artifactTypes: null, + artifactFile: {} + }; + + this.initEntity(); + }; + + private initScope = ():void => { + + this.$scope.validationPattern = this.ValidationPattern; + this.$scope.urlValidationPattern = this.UrlValidationPattern; + this.$scope.labelValidationPattern = this.LabelValidationPattern; + this.$scope.integerValidationPattern = this.IntegerValidationPattern; + this.$scope.commentValidationPattern = this.CommentValidationPattern; + this.$scope.isLoading = false; + this.$scope.isNew = (this.formState === FormState.CREATE); + this.$scope.artifactType = this.artifactsUtils.getArtifactTypeByState(this.$state.current.name); + this.$scope.modalInstanceArtifact = this.$uibModalInstance; + + this.initEditArtifactResourceModel(); + this.initArtifactTypes(); + + // In case of edit, show the file name in browse. + if (this.artifact.artifactName !== "" && 'HEAT_ENV' !== this.artifact.artifactType) { + this.$scope.editArtifactResourceModel.artifactFile = {}; + this.$scope.editArtifactResourceModel.artifactFile.filename = this.artifact.artifactName; + } + + //scope methods + this.$scope.isDeploymentHeat = ():boolean => { + return !this.$scope.isNew && this.$scope.artifactType === 'deployment' + && this.$scope.editArtifactResourceModel.artifactResource.isHEAT(); + + }; + this.$scope.onFileChange = ():void => { + if (this.$scope.editArtifactResourceModel.artifactFile && this.$scope.editArtifactResourceModel.artifactFile.filename) { + this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; + } else { + this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.originalArtifactName; + } + }; + this.$scope.setDefaultTimeout = ():void => { + if (this.$scope.isDeploymentHeat() && !this.$scope.editArtifactResourceModel.artifactResource.timeout) { + this.$scope.editArtifactResourceModel.artifactResource.timeout = this.$scope.defaultHeatTimeout; + } + + if (this.$scope.editArtifactResourceModel.artifactFile.filename) { + this.$scope.editArtifactResourceModel.artifactFile = {}; + this.$scope.forms.editForm.myArtifactFile.$setValidity('required', false); + } + }; + + this.$scope.fileExtensions = ():string => { + let type:string = this.$scope.editArtifactResourceModel.artifactResource.artifactType; + return type && this.$scope.validExtensions && this.$scope.validExtensions[type].acceptedTypes ? + this.$scope.validExtensions[type].acceptedTypes.join(',') : ""; + }; + + this.$scope.save = (doNotCloseModal?:boolean):void => { + this.$scope.isLoading = true; + this.$scope.editArtifactResourceModel.artifactResource.description = this.ValidationUtils.stripAndSanitize(this.$scope.editArtifactResourceModel.artifactResource.description); + + if (!this.$scope.isDeploymentHeat()) { + this.$scope.editArtifactResourceModel.artifactResource.timeout = null; + } + + if (this.$scope.editArtifactResourceModel.artifactFile) { + this.$scope.editArtifactResourceModel.artifactResource.payloadData = this.$scope.editArtifactResourceModel.artifactFile.base64; + this.$scope.editArtifactResourceModel.artifactResource.artifactName = this.$scope.editArtifactResourceModel.artifactFile.filename; + } + + let onFaild = (response):void => { + this.$scope.isLoading = false; + console.info('onFaild', response); + }; + + let onSuccess = (artifactResource:ArtifactModel):void => { + this.$scope.isLoading = false; + this.$scope.originalArtifactName = ""; + + if (this.$scope.isDeploymentHeat()) { + if (artifactResource.heatParameters) { + this.$scope.openEditEnvParametersModal(artifactResource); + } + } + + if (!doNotCloseModal) { + this.$uibModalInstance.close(); + } else { + this.$scope.editArtifactResourceModel.artifactFile = null; + angular.element("input[type='file']").val(null); // for support chrome when upload the same file + this.artifactsUtils.addAnotherAfterSave(this.$scope); + } + + }; + + if ('HEAT_ENV' == this.artifact.artifactType) { + if (this.component.selectedInstance) { + this.component.uploadInstanceEnvFile(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); + } else { + this.component.addOrUpdateArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); + + } + } else if (this.$scope.isArtifactOwner()) { + this.component.addOrUpdateInstanceArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); + } else { + this.component.addOrUpdateArtifact(this.$scope.editArtifactResourceModel.artifactResource).then(onSuccess, onFaild); + } + }; + + this.$scope.isArtifactOwner = ():boolean=> { + return this.component.isService() && !!this.component.selectedInstance; + }; + + this.$scope.saveAndAnother = ():void => { + this.$scope.save(true); + }; + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + this.$scope.fileUploadRequired = ():string => { + if (this.$scope.editArtifactResourceModel.artifactFile.filename) { + // This is edit mode + return 'false'; + } else { + return 'true'; + } + }; + + this.$scope.getFormTitle = ():string => { + if ('HEAT_ENV' == this.artifact.artifactType) { + return 'Update HEAT ENV'; + } + if (this.$scope.isDeploymentHeat()) { + if (!this.$scope.editArtifactResourceModel.artifactResource.artifactChecksum) { + return 'Add HEAT Template'; + } + return 'Update HEAT Template'; + } + if (this.$scope.isNew) { + return 'Add Artifact'; + } + return 'Update Artifact'; + }; + + this.$scope.openEditEnvParametersModal = (artifactResource:ArtifactModel):void => { + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + templateUrl: '../env-parameters-form/env-parameters-form.html', + controller: 'Sdc.ViewModels.EnvParametersFormViewModel', + size: 'sdc-md', + backdrop: 'static', + resolve: { + artifact: ():ArtifactModel => { + return artifactResource; + }, + component: ():Component => { + return this.component; + } + } + }; + + let modalInstance:ng.ui.bootstrap.IModalServiceInstance = this.$uibModal.open(modalOptions); + modalInstance + .result + .then(():void => { + }); + }; + + this.$scope.forms = {}; + + this.initFooterButtons(); + + + this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { + if(this.$scope.forms.editForm) { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + if (this.$scope.isNew) { + this.$scope.footerButtons[1].disabled = this.$scope.forms.editForm.$invalid; + } + } + }); + + } +} diff --git a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form-view.html b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form-view.html index 74a19c8776..0984c6872d 100644 --- a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form-view.html +++ b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form-view.html @@ -1,4 +1,4 @@ -<sdc-modal modal="modalInstanceArtifact" type="classic" class="sdc-add-artifact" buttons="footerButtons" header="{{getFormTitle()}}" show-close-button="true" get-close-modal-response="close"> +<sdc-modal modal="modalInstanceArtifact" type="classic" class="sdc-add-artifact" buttons="footerButtons" header="{{getFormTitle()}}" show-close-button="true" get-close-modal-response="close" data-tests-id="sdc-add-artifact"> <loader data-display="isLoading"></loader> @@ -19,7 +19,7 @@ data-ng-class="{'error': forms.editForm.myArtifactFile.$dirty && forms.editForm.myArtifactFile.$invalid}"></file-upload> <div class="input-error-file-upload" data-ng-show="forms.editForm.myArtifactFile.$dirty && forms.editForm.myArtifactFile.$invalid"> - <span ng-show="forms.editForm.myArtifactFile.$error.required && !forms.editForm.myArtifactFile.$error.emptyFile" translate="ADD_ARTIFACT_ERROR_FILE_REQUIRED"></span> + <span ng-show="forms.editForm.myArtifactFile.$error.required || forms.editForm.myArtifactFile.$error.emptyFile" translate="ADD_ARTIFACT_ERROR_FILE_REQUIRED"></span> <span ng-show="forms.editForm.myArtifactFile.$error.maxsize" translate="VALIDATION_ERROR_MAX_FILE_SIZE"></span> <span ng-if="artifactType === 'deployment'" ng-show="forms.editForm.myArtifactFile.$error.filetype" translate="ADD_ARTIFACT_ERROR_VALID_EXTENSIONS" translate-values="{'extensions': '{{fileExtensions()}}' }"></span> <span ng-show="forms.editForm.myArtifactFile.$error.emptyFile" translate="VALIDATION_ERROR_EMPTY_FILE"></span> @@ -45,7 +45,7 @@ data-ng-pattern="labelValidationPattern" maxlength="25" data-ng-disabled="!isNew" - data-tests-id="artifact-label" + data-tests-id="artifactLabel" autofocus/> <div class="input-error" data-ng-show="forms.editForm.artifactLabel.$dirty && forms.editForm.artifactLabel.$invalid"> diff --git a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form.less b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form.less index 1f77958c88..1f77958c88 100644 --- a/catalog-ui/app/scripts/view-models/forms/artifact-form/artifact-form.less +++ b/catalog-ui/src/app/view-models/forms/artifact-form/artifact-form.less diff --git a/catalog-ui/app/scripts/view-models/forms/attribute-form/attribute-form-view.html b/catalog-ui/src/app/view-models/forms/attribute-form/attribute-form-view.html index 432b32fbd3..90b8f67df4 100644 --- a/catalog-ui/app/scripts/view-models/forms/attribute-form/attribute-form-view.html +++ b/catalog-ui/src/app/view-models/forms/attribute-form/attribute-form-view.html @@ -106,11 +106,10 @@ data-ng-maxlength="100" data-ng-disabled="editAttributeModel.attribute.readonly && !isAttributeValueOwner()" maxlength="100" - data-ng-model="editAttributeModel.attribute[isAttributeValueOwner()?'value':'defaultValue']" + data-ng-model="attributeValue.value" type="text" name="value" data-custom-validation="" data-validation-func="validateUniqueKeys" - data-tests-id="defaultvalue" data-ng-pattern="validationPattern" data-ng-model-options="{ debounce: 200 }" data-ng-change="!forms.editForm.value.$error.pattern && ('integer'==editAttributeModel.attribute.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editAttributeModel.attribute.value)) || onValueChange())" @@ -121,7 +120,7 @@ data-ng-disabled="editAttributeModel.attribute.readonly && !isAttributeValueOwner()" name="value" data-ng-change="onValueChange()" - data-ng-model="editAttributeModel.attribute[isAttributeValueOwner()?'value':'defaultValue']"> + data-ng-model="attributeValue.value"> <option value="true">true</option> <option value="false">false</option> </select> diff --git a/catalog-ui/src/app/view-models/forms/attribute-form/attribute-from-view-model.ts b/catalog-ui/src/app/view-models/forms/attribute-form/attribute-from-view-model.ts new file mode 100644 index 0000000000..122cf10ed2 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/attribute-form/attribute-from-view-model.ts @@ -0,0 +1,241 @@ +'use strict'; +import {AttributeModel, Component} from "app/models"; +import {IMapRegex, ValidationUtils, FormState, PROPERTY_TYPES} from "app/utils"; + +export interface IEditAttributeModel { + attribute:AttributeModel; + types:Array<string>; + simpleTypes:Array<string>; +} + +export class attributeValue {//in order to solve DE226783, we update the value on another obj + value:string; +} + +interface IAttributeFormViewModelScope extends ng.IScope { + $$childTail:any; + forms:any; + editForm:ng.IFormController; + footerButtons:Array<any>; + isService:boolean; + editAttributeModel:IEditAttributeModel; + modalInstanceAttribute:ng.ui.bootstrap.IModalServiceInstance; + isNew:boolean; + listRegex:IMapRegex; + mapRegex:IMapRegex; + propertyNameValidationPattern:RegExp; + commentValidationPattern:RegExp; + isLoading:boolean; + validationPattern:RegExp; + attributeValue:attributeValue; + + save():void; + close():void; + onTypeChange():void; + onValueChange():void; + isAttributeValueOwner():boolean; + validateIntRange(value:string):boolean; + validateUniqueKeys(viewValue:string):boolean; + getValidationTranslate():string; + showSchema():boolean; + isSchemaEditable():boolean; + validateName():void; +} + +export class AttributeFormViewModel { + + static '$inject' = [ + '$scope', + '$uibModalInstance', + 'attribute', + 'ValidationUtils', + 'CommentValidationPattern', + 'PropertyNameValidationPattern', + 'component' + ]; + + private formState:FormState; + + + constructor(private $scope:IAttributeFormViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private attribute:AttributeModel, + private ValidationUtils:ValidationUtils, + private CommentValidationPattern:RegExp, + private PropertyNameValidationPattern:RegExp, + private component:Component) { + this.formState = angular.isDefined(attribute.name) ? FormState.UPDATE : FormState.CREATE; + this.initScope(); + } + + private initResource = ():void => { + this.$scope.editAttributeModel.attribute = new AttributeModel(this.attribute); + if (this.$scope.editAttributeModel.types.indexOf(this.attribute.type) === -1) {//attribute defaulte type is string too? + this.attribute.type = "string"; + } + }; + + private initEditAttributeModel = ():void => { + this.$scope.editAttributeModel = { + attribute: null, + types: ['integer', 'string', 'float', 'boolean', 'list', 'map'], + simpleTypes: ['integer', 'string', 'float', 'boolean'] + }; + + this.initResource(); + }; + + private initScope = ():void => { + + //scope attributes + this.$scope.forms = {}; + this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + this.$scope.commentValidationPattern = this.CommentValidationPattern; + + this.$scope.modalInstanceAttribute = this.$uibModalInstance; + this.$scope.listRegex = this.ValidationUtils.getPropertyListPatterns(); + this.$scope.mapRegex = this.ValidationUtils.getPropertyMapPatterns(); + + this.$scope.isNew = (this.formState === FormState.CREATE); + this.$scope.isLoading = false; + this.$scope.attributeValue = new attributeValue(); + + this.initEditAttributeModel(); + this.setValidationPattern(); + + //scope methods + this.$scope.save = ():void => { + if (!this.$scope.forms.editForm.$invalid) { + let attribute:AttributeModel = this.$scope.editAttributeModel.attribute; + this.$scope.editAttributeModel.attribute.description = this.ValidationUtils.stripAndSanitize(this.$scope.editAttributeModel.attribute.description); + ////if read only - just closes the modal + if (this.$scope.editAttributeModel.attribute.readonly && !this.$scope.isAttributeValueOwner()) { + this.$uibModalInstance.close(); + return; + } + this.$scope.isLoading = true; + let onAttributeFaild = (response):void => { + console.info('onFaild', response); + this.$scope.isLoading = false; + }; + + let onAttributeSuccess = (attributeFromBE:AttributeModel):void => { + console.info('onAttributeResourceSuccess : ', attributeFromBE); + this.$scope.isLoading = false; + this.$uibModalInstance.close(); + }; + + //in case we have uniqueId we call update method + if (this.$scope.isAttributeValueOwner()) { + attribute.value = this.$scope.attributeValue.value; + this.component.updateInstanceAttribute(attribute).then(onAttributeSuccess, onAttributeFaild); + } else { + attribute.defaultValue = this.$scope.attributeValue.value; + this.component.addOrUpdateAttribute(attribute).then(onAttributeSuccess, onAttributeFaild); + } + } + }; + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + this.$scope.validateName = ():void => { + let existsAttr:AttributeModel = _.find(this.component.attributes, (attribute:AttributeModel) => { + return attribute.name === this.$scope.editAttributeModel.attribute.name; + }); + if (existsAttr) { + this.$scope.forms.editForm["attributeName"].$setValidity('nameExist', false); + } else { + this.$scope.forms.editForm["attributeName"].$setValidity('nameExist', true); + } + + }; + + this.$scope.onTypeChange = ():void => { + this.$scope.editAttributeModel.attribute.value = ''; + this.$scope.editAttributeModel.attribute.defaultValue = ''; + this.setValidationPattern(); + }; + + this.$scope.isAttributeValueOwner = ():boolean=> { + return this.component.isService() || !!this.component.selectedInstance; + }; + + this.$scope.onValueChange = ():void => { + if (!this.$scope.editAttributeModel.attribute.value) { + if (this.$scope.isAttributeValueOwner()) { + this.$scope.editAttributeModel.attribute.value = this.$scope.editAttributeModel.attribute.defaultValue; + } + } + }; + + + this.$scope.validateUniqueKeys = (viewValue:string):boolean => { + if (this.$scope.editAttributeModel.attribute.type === 'map') { + return this.ValidationUtils.validateUniqueKeys(viewValue); + } + else { + return true; //always valid if not a map + } + }; + + this.$scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + this.$scope.isSchemaEditable = ():boolean => { + let schemaType = this.$scope.editAttributeModel.attribute.schema.property.type; + return this.$scope.editAttributeModel.simpleTypes.indexOf(schemaType) > -1 || !schemaType; + }; + + this.$scope.showSchema = ():boolean => { + return ['list', 'map'].indexOf(this.$scope.editAttributeModel.attribute.type) > -1; + }; + + this.$scope.getValidationTranslate = ():string => { + let result = "ATTRIBUTE_EDIT_PATTERN"; + if (this.$scope.showSchema()) { + + result = "ATTRIBUTE_EDIT_" + this.$scope.editAttributeModel.attribute.type.toUpperCase(); + + if (this.$scope.editAttributeModel.attribute.schema.property.type === PROPERTY_TYPES.STRING) { + result += "_STRING"; + } else if (this.$scope.editAttributeModel.attribute.schema.property.type === PROPERTY_TYPES.BOOLEAN) { + result += "_BOOLEAN"; + } else { + result += "_GENERIC"; + } + } + + return result; + }; + + // Add the done button at the footer. + this.$scope.footerButtons = [ + {'name': 'Done', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watchCollection("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + this.$scope.attributeValue.value = this.$scope.isAttributeValueOwner() ? this.$scope.editAttributeModel.attribute.value : this.$scope.editAttributeModel.attribute.defaultValue; + }; + + + private setValidationPattern = ():void => { + + if (this.$scope.editAttributeModel.attribute.type === 'list') { + this.$scope.validationPattern = this.$scope.listRegex[this.$scope.editAttributeModel.attribute.schema.property.type]; + } + else if (this.$scope.editAttributeModel.attribute.type === 'map') { + this.$scope.validationPattern = this.$scope.mapRegex[this.$scope.editAttributeModel.attribute.schema.property.type]; + } + else { + this.$scope.validationPattern = this.ValidationUtils.getValidationPattern(this.$scope.editAttributeModel.attribute.type); + } + + }; +} diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html new file mode 100644 index 0000000000..ae13844532 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.html @@ -0,0 +1,92 @@ +<sdc-modal modal="envParametersModal" type="classic" class="sdc-env-form-container" buttons="buttons" header="{{artifactResource.artifactDisplayName}}" show-close-button="true"> + <div class="w-sdc-env-form-container"> + <div class="w-sdc-env-search pull-left"> + <input type="text" class="w-sdc-env-search-input" placeholder="Search" data-ng-model="searchText" data-tests-id="search-env-param-name"/> + <div class="search-icon-container"> + <span class="w-sdc-search-icon env-search-icon magnification-white"></span> + </div> + </div> + <div class="table-container-flex"> + <div class="table"> + <div class="head flex-container"> + <div class="table-header head-row flex-item" ng-repeat="header in tableHeadersList track by $index"> + <info-tooltip class="header-info" data-ng-if="header.info" class="info-button" info-message-translate="{{header.info}}" direction="left"></info-tooltip> + {{header.title}} + </div> + </div> + <div class="body"> + <perfect-scrollbar suppress-scroll-x="true" scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <ng-form name="forms.editForm" class="w-sdc-form"> + <div data-ng-repeat="parameter in heatParameters| filter:{filterTerm:searchText} track by $index " + class="flex-container data-row" + data-ng-init="parameter.filterTerm=parameter.name + ' ' + parameter.currentValue + ' ' + parameter.defaultValue + ' ' +parameter.description"> + <div class="table-col-general flex-item" data-tests-id="heatParameterName_{{parameter.name}}"> + {{parameter.name}} + <span class="sprite-new show-desc hand" + uib-popover-template="templatePopover" + popover-class="parameter-description-popover top" + popover-title="Parameter Description" + popover-placement="top-left" + popover-is-open="selectedParameter.name == parameter.name" + popover-trigger="'none'" + popover-append-to-body="true" + data-ng-click="openDescPopover(parameter)"></span> + </div> + + <div class="table-col-general flex-item text"> + <span data-tests-id="default-value-of-{{parameter.name}}" tooltips tooltip-content="{{parameter.defaultValue}}">{{parameter.defaultValue}}</span> + </div> + + <!--<div class="table-col-general flex-item">--> + <!--<input type="text" value="{{parameter.currentValue}}"/>--> + <!--</div>--> + + <div class="table-col-general flex-item left-column-container"> + + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm[parameter.name].$dirty && forms.editForm[parameter.name].$invalid), required: (parameter.defaultValue)}"> + <span class="required-symbol">*</span> + <div class="input-parameter"> + <input class="i-sdc-form-input" data-ng-class="{error: (forms.editForm[parameter.name].$invalid)}" + data-ng-model-options="{ debounce: 200 }" + data-ng-model="parameter.currentValue" + value="{{parameter.currentValue}}" + type="text" + name="{{parameter.name}}" + data-ng-pattern="getValidationPattern(parameter.type, 'heat')" + data-ng-required="parameter.defaultValue" + data-ng-change="'json'==parameter.type && forms.editForm[parameter.name].$setValidity('pattern', validateJson(parameter.currentValue))" + data-ng-blur="(forms.editForm[parameter.name].$error.required && (parameter.currentValue=parameter.defaultValue))" + data-tests-id="value-field-of-{{parameter.name}}"/> + + <div class="action-button"> + <div class="sprite-new revert-param" data-ng-if="parameter.defaultValue" data-ng-click="parameter.currentValue = parameter.defaultValue" + data-tests-id="revert-{{parameter.name}}"> + </div> + <div class="sprite-new delete-param" + data-ng-if="!parameter.defaultValue" + data-ng-disabled="!parameter.currentValue" + data-ng-class="{disabled:!parameter.currentValue}" + data-ng-click="parameter.currentValue = ''" + data-tests-id="delete-{{parameter.name}}"> + </div> + </div> + </div> + <div class="input-error" data-ng-show="forms.editForm[parameter.name].$invalid"> + <span ng-show="forms.editForm[parameter.name].$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Value'}"></span> + <span ng-show="forms.editForm[parameter.name].$error.pattern && parameter.type==='string'" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + <span ng-show="forms.editForm[parameter.name].$error.pattern && !(parameter.type==='string')" translate="VALIDATION_ERROR_TYPE" translate-values="{'type': '{{parameter.type}}'}"></span> + </div> + </div> + + </div> + + </div> + </ng-form> + + </perfect-scrollbar> + </div> + </div> + </div> + </div> + </div> +</sdc-modal> diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less new file mode 100644 index 0000000000..a25a2c5f62 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.less @@ -0,0 +1,178 @@ + +.sdc-env-form-container{ + .w-sdc-modal-body{ + padding: 20px 10px 2px 10px; + } + .w-sdc-modal-body-content{ + .b_6; + display: block; + } + + .env-file-generation-label{ + .p_9; + .bold; + margin-bottom: 20px; + } +} + +.w-sdc-env-form-container { + height: 650px; + + .w-sdc-env-search { + padding: 10px 20px 20px 0; + white-space: nowrap; + position: relative; + width: 60%; + height: 64px; + + .env-search-icon { + top: 9px; + right: 11px; + } + + .magnification-white { + .sprite-new; + .search-white-icon; + .hand; + } + + .search-icon-container { + width: 35px; + height: 30px; + background-color: @main_color_a; + white-space: nowrap; + float: right; + position: relative; + bottom: 31px; + right: 1px; + border-radius: 0px 4px 4px 0px; + .hand + } + + .w-sdc-env-search-input { + border: 1px solid @color_e; + .border-radius(4px); + height: 32px; + margin: 0; + padding: 0px 28px 3px 10px; + vertical-align: 4px; + width: 100%; + outline: none; + font-style: italic; + } + } + + .table-container-flex { + height: 570px; + + .table { + height: 100%; + .flex-item:nth-child(1) { + flex-grow: 20; + .show-desc{ + float: right; + top: 10px; + position: relative; + } + } + + .flex-item:nth-child(2) { + flex-grow: 10; + } + + .flex-item:nth-child(3) { + flex-grow: 10; + } + .scrollbar-container{ + max-height: 527px; + } + .left-column-container{ + .required-symbol { + .m_14_m; + color: #f33; + display: none; + position: relative; + left: -4px; + top: 3px; + } + + .i-sdc-form-item{ + border-right: none; + margin: 0px; + + .input-parameter{ + border: none; + height: 30px; + width: 254px; + float: right; + input{ + .m_13_m; + width: 100%; + display: inline-flex; + padding-right: 33px; + } + .action-button{ + border-left: solid 1px @main_color_o; + position: relative; + height: 20px; + width: 25px; + top: -25px; + left: 228px; + padding-left: 6px; + background-color: @main_color_p; + div:not(.disable){ + .hand; + } + } + } + + &.required{ + .required-symbol { + display: inline-flex; + } + .input-parameter { + width: 250px; + } + .action-button{ + left: 224px; + } + } + } + + + + } + } + + .text{ + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + white-space: nowrap; + } + } + + + .parameter-description{ + background-color: @func_color_r; + border-left: 4px solid @main_color_a; + padding: 10px 30px; + } +} + +.header-info{ + float: right; +} + +.parameter-description-popover{ + z-index: 1100; + min-width: 210px; + .arrow{ + left: 20px !important; + border-width: 7px; + bottom: -8px !important; + } + .popover-content{ + .f-type._13_m;; + } +} diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts new file mode 100644 index 0000000000..476af4ada9 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parameters-form.ts @@ -0,0 +1,153 @@ +'use strict'; +import {ValidationUtils} from "app/utils"; +import {ArtifactModel, HeatParameterModel, Component} from "app/models"; + +export interface IEnvParametersFormViewModelScope extends ng.IScope { + isLoading:boolean; + type:string; + heatParameters:Array<HeatParameterModel>; + forms:any; + artifactResource:ArtifactModel; + buttons:Array<any>; + envParametersModal:ng.ui.bootstrap.IModalServiceInstance; + tableHeadersList:Array<any>; + selectedParameter:HeatParameterModel; + templatePopover:string; + + getValidationPattern(type:string):RegExp; + isInstance():boolean; + validateJson(json:string):boolean; + close():void; + save():void; + openDescPopover(selectedParam:HeatParameterModel):void; + closeDescriptionPopover():void; +} + +export class EnvParametersFormViewModel { + + static '$inject' = [ + '$scope', + '$templateCache', + '$state', + '$uibModalInstance', + 'artifact', + 'ValidationUtils', + 'component' + ]; + + constructor(private $scope:IEnvParametersFormViewModelScope, + private $templateCache:ng.ITemplateCacheService, + private $state:any, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private artifact:ArtifactModel, + private ValidationUtils:ValidationUtils, + private component:Component) { + + + this.initScope(); + } + + private updateInstanceHeat = ():void => { + let success = (responseArtifact:ArtifactModel):void => { + this.$scope.isLoading = false; + this.$uibModalInstance.close(); + }; + + let error = ():void => { + this.$scope.isLoading = false; + console.info('Failed to load save artifact'); + }; + + this.component.addOrUpdateInstanceArtifact(this.$scope.artifactResource).then(success, error); + }; + + private initScope = ():void => { + this.$scope.forms = {}; + this.$scope.envParametersModal = this.$uibModalInstance; + this.$scope.artifactResource = this.artifact; + this.$scope.heatParameters = angular.copy(this.artifact.heatParameters); + + this.$scope.tableHeadersList = [ + {title: "Parameter", property: "name"}, + {title: "Default Value", property: "defaultValue", info: "DEFAULT_VALUE_INFO"}, + {title: "Current Value", property: "currentValue", info: "CURRENT_VALUE_INFO"} + ]; + + this.$templateCache.put("env-parametr-description-popover.html", require('app/view-models/forms/env-parameters-form/env-parametr-description-popover.html')); + this.$scope.templatePopover = "env-parametr-description-popover.html"; + + this.$scope.getValidationPattern = (validationType:string, parameterType?:string):RegExp => { + return this.ValidationUtils.getValidationPattern(validationType, parameterType); + }; + + this.$scope.validateJson = (json:string):boolean => { + if (!json) { + return true; + } + return this.ValidationUtils.validateJson(json); + }; + + this.$scope.isInstance = ():boolean => { + return !!this.component.selectedInstance; + }; + + this.$scope.save = ():void => { + this.$scope.buttons[0].disabled = true;//prevent double click (DE246266) + this.$scope.isLoading = true; + this.artifact.heatParameters = this.$scope.heatParameters; + this.artifact.heatParameters.forEach((parameter:any):void => { + /* if ("" === parameter.currentValue) { + parameter.currentValue = null; + }else */ + if (!parameter.currentValue && parameter.defaultValue) { + parameter.currentValue = parameter.defaultValue; + } + }); + + if (this.$scope.isInstance()) { + this.updateInstanceHeat(); + return; + } + + let success = (responseArtifact:ArtifactModel):void => { + this.$scope.isLoading = false; + this.$uibModalInstance.close(); + + }; + + let error = ():void => { + this.$scope.isLoading = false; + console.info('Failed to load save artifact'); + }; + + this.component.addOrUpdateArtifact(this.$scope.artifactResource).then(success, error); + }; + + this.$scope.close = ():void => { + //this.artifact.heatParameters.forEach((parameter:any):void => { + // if (!parameter.currentValue && parameter.defaultValue) { + // parameter.currentValue = parameter.defaultValue; + // } + //}); + this.$uibModalInstance.dismiss(); + }; + + this.$scope.openDescPopover = (selectedParam:HeatParameterModel):void => { + this.$scope.selectedParameter = selectedParam; + }; + + this.$scope.closeDescriptionPopover = ():void => { + this.$scope.selectedParameter = null; + }; + + this.$scope.buttons = [ + {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.buttons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + }; +} diff --git a/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parametr-description-popover.html b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parametr-description-popover.html new file mode 100644 index 0000000000..ed127c6bfb --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/env-parameters-form/env-parametr-description-popover.html @@ -0,0 +1,4 @@ +<div> + <span data-tests-id='popover-x-button' data-ng-click='closeDescriptionPopover()' class='tlv-sprite tlv-x-btn close-popover-btn'></span> + {{selectedParameter.description}} +</div> diff --git a/catalog-ui/src/app/view-models/forms/input-form/input-form-view-modal.ts b/catalog-ui/src/app/view-models/forms/input-form/input-form-view-modal.ts new file mode 100644 index 0000000000..e87e5c6c7d --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/input-form/input-form-view-modal.ts @@ -0,0 +1,126 @@ +'use strict'; +import {FormState, PROPERTY_TYPES, ValidationUtils, PROPERTY_VALUE_CONSTRAINTS} from "app/utils"; +import {InputModel} from "app/models"; + +export interface IInputEditModel { + editInput:InputModel; +} + +export interface IInputFormViewModelScope extends ng.IScope { + forms:any; + editForm:ng.IFormController; + footerButtons:Array<any>; + isService:boolean; + modalInstanceInput:ng.ui.bootstrap.IModalServiceInstance; + isLoading:boolean; + inputEditModel:IInputEditModel; + myValue:any; + maxLength:number; + + save():void; + close():void; + validateIntRange(value:string):boolean; + validateJson(json:string):boolean; + getValidationPattern(type:string):RegExp; + showSchema():boolean; +} + +export class InputFormViewModel { + + static '$inject' = [ + '$scope', + '$uibModalInstance', + 'ValidationUtils', + 'input' + ]; + + private formState:FormState; + + + constructor(private $scope:IInputFormViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private ValidationUtils:ValidationUtils, + private input:InputModel) { + this.initScope(); + this.initMyValue(); + } + + private initMyValue = ():void => { + switch (this.$scope.inputEditModel.editInput.type) { + case PROPERTY_TYPES.MAP: + this.$scope.myValue = this.$scope.inputEditModel.editInput.defaultValue ? JSON.parse(this.$scope.inputEditModel.editInput.defaultValue) : {'': null}; + break; + case PROPERTY_TYPES.LIST: + this.$scope.myValue = this.$scope.inputEditModel.editInput.defaultValue ? JSON.parse(this.$scope.inputEditModel.editInput.defaultValue) : []; + break; + } + }; + + private initDefaultValueMaxLength = ():void => { + switch (this.$scope.inputEditModel.editInput.type) { + case PROPERTY_TYPES.MAP: + case PROPERTY_TYPES.LIST: + this.$scope.maxLength = this.$scope.inputEditModel.editInput.schema.property.type == PROPERTY_TYPES.JSON ? + PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH : + PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; + break; + case PROPERTY_TYPES.JSON: + this.$scope.maxLength = PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH; + break; + default: + this.$scope.maxLength = PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; + } + }; + + private initScope = ():void => { + this.$scope.forms = {}; + this.$scope.modalInstanceInput = this.$uibModalInstance; + this.$scope.inputEditModel = { + editInput: null + }; + this.$scope.inputEditModel.editInput = this.input; + this.initDefaultValueMaxLength(); + + //scope methods + this.$scope.save = ():void => { + if (this.$scope.showSchema()) { + this.$scope.inputEditModel.editInput.defaultValue = JSON.stringify(this.$scope.myValue); + } + }; + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + this.$scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + this.$scope.validateJson = (json:string):boolean => { + if (!json) { + return true; + } + return this.ValidationUtils.validateJson(json); + }; + + this.$scope.showSchema = ():boolean => { + return ['list', 'map'].indexOf(this.$scope.inputEditModel.editInput.type) > -1; + }; + + this.$scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + // Add the done button at the footer. + this.$scope.footerButtons = [ + {'name': 'Done', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watchCollection("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + }; +} + diff --git a/catalog-ui/src/app/view-models/forms/input-form/input-form-view.html b/catalog-ui/src/app/view-models/forms/input-form/input-form-view.html new file mode 100644 index 0000000000..1bf6dc4ca9 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/input-form/input-form-view.html @@ -0,0 +1,125 @@ +<sdc-modal modal="modalInstanceInput" type="classic" class="sdc-edit-input-container" buttons="footerButtons" header="Update Input" show-close-button="true"> + + <div class="sdc-edit-input-form-container" > + <form novalidate class="w-sdc-form two-columns" name="forms.editForm" > + + <div class="w-sdc-form-columns-wrapper"> + + <div class="w-sdc-form-column"> + + <!-- Name --> + <div class="i-sdc-form-item"> + <label class="i-sdc-form-label">Name</label> + <input class="i-sdc-form-input" + data-tests-id="inputName" + data-ng-maxlength="50" + data-ng-disabled="true" + maxlength="50" + data-ng-model="inputEditModel.editInput.name" + type="text" + name="inputName" + autofocus /> + </div> + + <!-- Description --> + <div class="i-sdc-form-item"> + <label class="i-sdc-form-label">Description</label> + <textarea class="i-sdc-form-textarea" + data-ng-disabled="true" + name="description" + data-ng-model="inputEditModel.editInput.description" + data-tests-id="description"></textarea> + </div> + + + </div> + + <div class="w-sdc-form-column"> + <!-- Type --> + <div class="i-sdc-form-item"> + <label class="i-sdc-form-label">Type</label> + <input class="i-sdc-form-input" + data-tests-id="type" + data-ng-disabled="true" + data-ng-model="inputEditModel.editInput.type" + type="text" + name="type"/> + </div> + <!-- schema --> + <div class="i-sdc-form-item" + data-ng-if="showSchema()"> + <label class="i-sdc-form-label">Entry Schema</label> + <input class="i-sdc-form-input" + data-tests-id="schema" + data-ng-disabled="true" + data-ng-model="inputEditModel.editInput.schema.property.type" + type="text" + name="schema"/> + </div> + <!-- Default value --> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> + <label class="i-sdc-form-label">Default Value</label> + <div data-ng-switch="inputEditModel.editInput.type"> + <div ng-switch-when="map"> + <type-map value-obj-ref="myValue" + schema-property="inputEditModel.editInput.schema.property" + parent-form-obj="forms.editForm" + fields-prefix-name="'input-value-'" + read-only="true" + default-value="" + types="[]" + max-length="maxLength"></type-map> + </div> + <div ng-switch-when="list"> + <type-list value-obj-ref="myValue" + schema-property="inputEditModel.editInput.schema.property" + parent-form-obj="forms.editForm" + fields-prefix-name="'input-value-'" + read-only="true" + default-value="" + types="[]" + max-length="maxLength"></type-list> + </div> + <div ng-switch-default> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> + <input class="i-sdc-form-input" + data-tests-id="defaultvalue" + ng-if="inputEditModel.editInput.type != 'boolean'" + data-ng-maxlength="maxLength" + data-ng-disabled="true" + maxlength="{{maxLength}}" + data-ng-model="inputEditModel.editInput.defaultValue" + type="text" + name="value" + data-ng-pattern="getValidationPattern(input.type)" + data-ng-model-options="{ debounce: 200 }" + data-ng-change="('json'==inputEditModel.editInput.type && forms.editForm.value.$setValidity('pattern', validateJson(inputEditModel.editInput.defaultValue))) + ||(!forms.editForm.value.$error.pattern && ('integer'==inputEditModel.editInput.type && forms.editForm.value.$setValidity('pattern', validateIntRange(inputEditModel.editInput.defaultValue)) || onValueChange()))" + autofocus /> + <select class="i-sdc-form-select" + data-tests-id="booleantype" + ng-if="inputEditModel.editInput.type == 'boolean'" + data-ng-disabled="true" + name="value" + data-ng-model="inputEditModel.editInput.defaultValue"> + <option value="true">true</option> + <option value="false">false</option> + </select> + + <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid"> + <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span> + <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span> + </div> + </div> + </div> + </div> + </div> + + </div> + + </div> + + </form> + </div> + +</sdc-modal> diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts new file mode 100644 index 0000000000..1ba5a90bb4 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts @@ -0,0 +1,204 @@ +/** + * Created by obarda on 1/19/2017. + */ +'use strict'; +import {DataTypesService} from "app/services/data-types-service"; +import {PropertyModel, DataTypesMap, Component} from "app/models"; +import {ValidationUtils, PROPERTY_DATA} from "app/utils"; + +export interface IPropertyFormBaseViewScope extends ng.IScope { + + forms:any; + editForm:ng.IFormController; + + property:PropertyModel; + types:Array<string>; + nonPrimitiveTypes:Array<string>; + simpleTypes:Array<string>; + + footerButtons:Array<any>; + modalPropertyFormBase:ng.ui.bootstrap.IModalServiceInstance; + currentPropertyIndex:number; + isLastProperty:boolean; + innerViewSrcUrl:string; + + //Disabling filed - each child controller can change this when needed + isNew:boolean; + isTypeSelectorDisable:boolean; + isDeleteDisable:boolean; + isNameDisable:boolean; + isDescriptionDisable:boolean; + isPropertyValueDisable:boolean; + isArrowsDisabled:boolean; + + //Validation pattern + validationPattern:RegExp; + propertyNameValidationPattern:RegExp; + commentValidationPattern:RegExp; + numberValidationPattern:RegExp; + + dataTypes:DataTypesMap; + + isLoading:boolean; + + save():void; + close():void; + getNext():void; + getPrev():void; + getValidationPattern(type:string):RegExp; +} + +export abstract class PropertyFormBaseView { + + + constructor(protected $scope:IPropertyFormBaseViewScope, + protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + protected $injector:ng.auto.IInjectorService, + protected originalProperty:PropertyModel, + protected component:Component, + protected filteredProperties:Array<PropertyModel>, + protected DataTypesService:DataTypesService) { + + this.initScope(); + + } + + protected validationUtils:ValidationUtils; + + protected isPropertyValueOwner = ():boolean => { + return this.component.isService() || !!this.component.selectedInstance; + }; + + private isDisable = ():boolean => { + return this.isPropertyValueOwner() || this.$scope.property.readonly; + }; + + + //This is the difault state, Childs screens can change if needed + protected initButtonsState = ():void => { + let isDisable = this.isDisable(); + + this.$scope.isArrowsDisabled = false; + this.$scope.isDeleteDisable = isDisable; + this.$scope.isDescriptionDisable = isDisable; + this.$scope.isNameDisable = isDisable; + this.$scope.isTypeSelectorDisable = isDisable; + this.$scope.isPropertyValueDisable = this.$scope.property.readonly && !this.isPropertyValueOwner(); + }; + + protected initValidations = ():void => { + + this.$scope.validationPattern = this.$injector.get('ValidationPattern'); + this.$scope.propertyNameValidationPattern = this.$injector.get('PropertyNameValidationPattern'); + this.$scope.commentValidationPattern = this.$injector.get('CommentValidationPattern'); + this.$scope.numberValidationPattern = this.$injector.get('NumberValidationPattern'); + this.validationUtils = this.$injector.get('ValidationUtils'); + }; + + //Functions implemented on child's scope if needed + abstract save(doNotCloseModal?:boolean):ng.IPromise<boolean>; + + protected onPropertyChange():void { + }; + + private updatePropertyByIndex = (index:number):void => { + this.$scope.property = new PropertyModel(this.filteredProperties[index]); + this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1); + this.onPropertyChange(); + }; + + private initScope = ():void => { + + this.$scope.forms = {}; + this.$scope.isLoading = false; + this.$scope.property = new PropertyModel(this.originalProperty); //we create a new Object so if user press cance we won't update the property + this.$scope.types = PROPERTY_DATA.TYPES; //All types - simple type + map + list + this.$scope.simpleTypes = PROPERTY_DATA.SIMPLE_TYPES; //All simple types + this.$scope.dataTypes = this.DataTypesService.getAllDataTypes(); //Get all data types in service + this.$scope.modalPropertyFormBase = this.$uibModalInstance; + this.$scope.isNew = !angular.isDefined(this.$scope.property.name); + + this.initValidations(); + this.initButtonsState(); + this.filteredProperties = _.sortBy(this.filteredProperties, 'name'); + this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, propety => propety.uniqueId == this.$scope.property.uniqueId); + this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1); + + this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> { + return this.$scope.types.indexOf(type) == -1; + }); + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + this.$scope.save = ():void => { + + let onSuccess = ():void => { + this.$scope.isLoading = false; + }; + let onFailed = ():void => { + this.$scope.isLoading = false; + }; + + this.$scope.isLoading = true; + this.save(true).then(onSuccess, onFailed); // Child controller implement save logic + }; + + // Add the done button at the footer. + this.$scope.footerButtons = [ + {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + + this.$scope.getPrev = ():void=> { + + let onSuccess = ():void => { + this.$scope.isLoading = false; + this.updatePropertyByIndex(--this.$scope.currentPropertyIndex); + }; + let onFailed = ():void => { + this.$scope.isLoading = false; + }; + + if (!this.$scope.property.readonly) { + this.$scope.isLoading = true; + this.save(false).then(onSuccess, onFailed); + + } else { + this.updatePropertyByIndex(--this.$scope.currentPropertyIndex); + } + + }; + + this.$scope.getNext = ():void=> { + + let onSuccess = ():void => { + this.$scope.isLoading = false; + this.updatePropertyByIndex(++this.$scope.currentPropertyIndex); + }; + let onFailed = ():void => { + this.$scope.isLoading = false; + }; + + if (!this.$scope.property.readonly) { + this.$scope.isLoading = true; + this.save(false).then(onSuccess, onFailed); + } else { + this.updatePropertyByIndex(++this.$scope.currentPropertyIndex); + } + + }; + + + this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + + this.$scope.getValidationPattern = (type:string):RegExp => { + return this.validationUtils.getValidationPattern(type); + }; + } +} diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html new file mode 100644 index 0000000000..7cb05bf4ca --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html @@ -0,0 +1,132 @@ +<sdc-modal modal="modalPropertyFormBase" type="classic" class="sdc-edit-property-container" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true" data-tests-id="sdc-edit-property-container"> + <loader data-display="isLoading" relative="false" size="medium"></loader> + <div class="sdc-modal-top-bar" data-ng-if="!isNew"> + <div class="sdc-modal-top-bar-buttons"> + <span ng-click="delete(property)" data-ng-class="{'disabled' : isDeleteDisable}" class="sprite-new delete-btn" data-tests-id="delete_property" sdc-smart-tooltip="">Delete</span> + <span class="delimiter"></span> + <span data-ng-click="getPrev()" data-ng-class="{'disabled' : !currentPropertyIndex || forms.editForm.$invalid || isArrowsDisabled}" class="sprite-new left-arrow" data-tests-id="get-prev" sdc-smart-tooltip="">Previous</span> + <span data-ng-click="getNext()" data-ng-class="{'disabled' : isLastProperty || forms.editForm.$invalid || isArrowsDisabled}" class="sprite-new right-arrow" data-tests-id="get-next" sdc-smart-tooltip="">Next</span> + </div> + </div> + + <div class="sdc-edit-property-form-container" > + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <form class="w-sdc-form two-columns" name="forms.editForm" > + + <div class="w-sdc-form-columns-wrapper"> + + <div class="w-sdc-form-column"> + + <!-- Name --> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid)}"> + <label class="i-sdc-form-label" ng-class="{'required': !isService}">Name</label> + <input class="i-sdc-form-input" + data-tests-id="propertyName" + data-ng-maxlength="50" + data-ng-disabled="isNameDisable" + maxlength="50" + data-ng-model="property.name" + type="text" + name="propertyName" + data-ng-pattern="propertyNameValidationPattern" + data-required + data-ng-model-options="{ debounce: 200 }" + autofocus /> + + <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid"> + <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span> + <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> + <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + </div> + </div> + </div> + + <div class="w-sdc-form-column"> + <div class="w-sdc-form-columns-wrapper"> + <div class="w-sdc-form-column"> + <!-- Type --> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}"> + <label class="i-sdc-form-label" ng-class="{'required': !isService}">Type</label> + <select class="i-sdc-form-select" + data-tests-id="propertyType" + data-required + data-ng-disabled="isTypeSelectorDisable" + name="type" + data-ng-change="onTypeChange()" + data-ng-model="property.type"> + <option value="">Choose Type</option> + <option data-ng-repeat="type in types" + value="{{type}}">{{type}}</option> + <option data-ng-repeat="type in nonPrimitiveTypes" + value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option> + </select> + + <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid"> + <span ng-show="forms.editForm.type.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Type' }"></span> + </div> + </div> + </div> + <div class="w-sdc-form-column" data-ng-if="showSchema()"> + <!-- Entry Schema --> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid)}"> + <label class="i-sdc-form-label required">Entry Schema</label> + <select class="i-sdc-form-select" + data-required + data-tests-id="schema-type" + data-ng-disabled="isPropertyValueOwner() || property.readonly" + name="schemaType" + data-ng-change="onSchemaTypeChange()" + data-ng-model="property.schema.property.type"> + <option value="">Choose Schema Type</option> + <option data-ng-repeat="type in simpleTypes" + value="{{type}}">{{type}}</option> + <option data-ng-repeat="type in nonPrimitiveTypes" + value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option> + </select> + + <div class="input-error" data-ng-show="forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid"> + <span ng-show="forms.editForm.schemaType.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Entry schema' }"></span> + </div> + </div> + </div> + </div> + + <!-- Constraints by type --> + <div class="i-sdc-form-item" data-ng-if="false"> + <label class="i-sdc-form-label required">Constraints by type</label> + <div> + Should be constraints by type(TBD) + </div> + </div> + + </div> + + </div> + <!-- Description --> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}"> + <label class="i-sdc-form-label">Description</label> + <textarea class="i-sdc-form-textarea" + data-ng-maxlength="256" + data-ng-disabled="isDescriptionDisable" + maxlength="256" + data-ng-pattern="commentValidationPattern" + name="description" + data-ng-model="property.description" + data-ng-model-options="{ debounce: 200 }" + data-tests-id="description" + ></textarea> + + <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid"> + <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> + <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + <span ng-show="forms.editForm.description.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Description' }"></span> + </div> + </div> + <!-- Default value - insert in dynamic template url --> + <ng-include src="innerViewSrcUrl"></ng-include> + <span class="w-sdc-form-note" data-ng-show="forms.editForm.$invalid && false" translate="LABEL_ALL_FIELDS_ARE_MANDATORY"></span> + </form> + </perfect-scrollbar> + </div> + +</sdc-modal> diff --git a/catalog-ui/app/scripts/view-models/forms/property-form/property-form.less b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less index 15e30af4ee..15e30af4ee 100644 --- a/catalog-ui/app/scripts/view-models/forms/property-form/property-form.less +++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts new file mode 100644 index 0000000000..b3557b055f --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts @@ -0,0 +1,322 @@ +'use strict'; +import { + PROPERTY_TYPES, ModalsHandler, ValidationUtils, PROPERTY_VALUE_CONSTRAINTS, FormState, PROPERTY_DATA} from "app/utils"; +import {DataTypesService} from "app/services"; +import {PropertyModel, DataTypesMap, Component} from "app/models"; + +export interface IEditPropertyModel { + property:PropertyModel; + types:Array<string>; + simpleTypes:Array<string>; +} + +interface IPropertyFormViewModelScope extends ng.IScope { + forms:any; + editForm:ng.IFormController; + footerButtons:Array<any>; + isNew:boolean; + isLoading:boolean; + isService:boolean; + validationPattern:RegExp; + propertyNameValidationPattern:RegExp; + commentValidationPattern:RegExp; + editPropertyModel:IEditPropertyModel; + modalInstanceProperty:ng.ui.bootstrap.IModalServiceInstance; + currentPropertyIndex:number; + isLastProperty:boolean; + myValue:any; + nonPrimitiveTypes:Array<string>; + dataTypes:DataTypesMap; + isTypeDataType:boolean; + maxLength:number; + isPropertyValueOwner:boolean; + + validateJson(json:string):boolean; + save(doNotCloseModal?:boolean):void; + getValidationPattern(type:string):RegExp; + validateIntRange(value:string):boolean; + close():void; + onValueChange():void; + onSchemaTypeChange():void; + onTypeChange(resetSchema:boolean):void; + showSchema():boolean; + delete(property:PropertyModel):void; + getPrev():void; + getNext():void; + isSimpleType(typeName:string):boolean; + getDefaultValue():any; +} + +export class PropertyFormViewModel { + + static '$inject' = [ + '$scope', + 'Sdc.Services.DataTypesService', + '$uibModalInstance', + 'property', + 'ValidationPattern', + 'PropertyNameValidationPattern', + 'CommentValidationPattern', + 'ValidationUtils', + 'component', + '$filter', + 'ModalsHandler', + 'filteredProperties', + '$timeout', + 'isPropertyValueOwner' + ]; + + private formState:FormState; + + constructor(private $scope:IPropertyFormViewModelScope, + private DataTypesService:DataTypesService, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private property:PropertyModel, + private ValidationPattern:RegExp, + private PropertyNameValidationPattern:RegExp, + private CommentValidationPattern:RegExp, + private ValidationUtils:ValidationUtils, + private component:Component, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private filteredProperties:Array<PropertyModel>, + private $timeout:ng.ITimeoutService, + private isPropertyValueOwner:boolean) { + + this.formState = angular.isDefined(property.name) ? FormState.UPDATE : FormState.CREATE; + this.initScope(); + } + + private initResource = ():void => { + this.$scope.editPropertyModel.property = new PropertyModel(this.property); + this.$scope.editPropertyModel.property.type = this.property.type ? this.property.type : null; + this.setMaxLength(); + this.initAddOnLabels(); + }; + + //init property add-ons labels that show up at the left side of the input. + private initAddOnLabels = () => { + if (this.$scope.editPropertyModel.property.name == 'network_role' && this.$scope.isService) { + //the server sends back the normalized name. Remove it (to prevent interference with validation) and set the addon label to the component name directly. + //Note: this cant be done in properties.ts because we dont have access to the component + if (this.$scope.editPropertyModel.property.value) { + let splitProp = this.$scope.editPropertyModel.property.value.split(new RegExp(this.component.normalizedName + '.', "gi")); + this.$scope.editPropertyModel.property.value = splitProp.pop(); + } + this.$scope.editPropertyModel.property.addOn = this.component.name; + } + } + + private initEditPropertyModel = ():void => { + this.$scope.editPropertyModel = { + property: null, + types: PROPERTY_DATA.TYPES, + simpleTypes: PROPERTY_DATA.SIMPLE_TYPES + }; + + this.initResource(); + }; + + private initForNotSimpleType = ():void => { + let property = this.$scope.editPropertyModel.property; + this.$scope.isTypeDataType = this.DataTypesService.isDataTypeForPropertyType(this.$scope.editPropertyModel.property); + if (property.type && this.$scope.editPropertyModel.simpleTypes.indexOf(property.type) == -1) { + if (!(property.value || property.defaultValue)) { + switch (property.type) { + case PROPERTY_TYPES.MAP: + this.$scope.myValue = {'': null}; + break; + case PROPERTY_TYPES.LIST: + this.$scope.myValue = []; + break; + default: + this.$scope.myValue = {}; + } + } else { + this.$scope.myValue = JSON.parse(property.value || property.defaultValue); + } + } + }; + + private setMaxLength = ():void => { + switch (this.$scope.editPropertyModel.property.type) { + case PROPERTY_TYPES.MAP: + case PROPERTY_TYPES.LIST: + this.$scope.maxLength = this.$scope.editPropertyModel.property.schema.property.type == PROPERTY_TYPES.JSON ? + PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH : + PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; + break; + case PROPERTY_TYPES.JSON: + this.$scope.maxLength = PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH; + break; + default: + this.$scope.maxLength =PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH; + } + }; + + + private initScope = ():void => { + + //scope properties + this.$scope.forms = {}; + this.$scope.validationPattern = this.ValidationPattern; + this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern; + this.$scope.commentValidationPattern = this.CommentValidationPattern; + this.$scope.isLoading = false; + this.$scope.isNew = (this.formState === FormState.CREATE); + this.$scope.isService = this.component.isService(); + this.$scope.modalInstanceProperty = this.$uibModalInstance; + this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, i=> i.name == this.property.name); + this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1); + this.$scope.dataTypes = this.DataTypesService.getAllDataTypes(); + this.$scope.isPropertyValueOwner = this.isPropertyValueOwner; + this.initEditPropertyModel(); + + this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> { + return this.$scope.editPropertyModel.types.indexOf(type) == -1; + }); + this.initForNotSimpleType(); + + + this.$scope.validateJson = (json:string):boolean => { + if (!json) { + return true; + } + return this.ValidationUtils.validateJson(json); + }; + + + //scope methods + this.$scope.save = (doNotCloseModal?:boolean):void => { + let property:PropertyModel = this.$scope.editPropertyModel.property; + this.$scope.editPropertyModel.property.description = this.ValidationUtils.stripAndSanitize(this.$scope.editPropertyModel.property.description); + //if read only - or no changes made - just closes the modal + //need to check for property.value changes manually to detect if map properties deleted + if ((this.$scope.editPropertyModel.property.readonly && !this.$scope.isPropertyValueOwner) + || (!this.$scope.forms.editForm.$dirty && angular.equals(JSON.stringify(this.$scope.myValue), this.$scope.editPropertyModel.property.value))) { + this.$uibModalInstance.close(); + return; + } + + this.$scope.isLoading = true; + + let onPropertyFaild = (response):void => { + console.info('onFaild', response); + this.$scope.isLoading = false; + }; + + let onPropertySuccess = (propertyFromBE:PropertyModel):void => { + console.info('onPropertyResourceSuccess : ', propertyFromBE); + this.$scope.isLoading = false; + + if (!doNotCloseModal) { + this.$uibModalInstance.close(); + } else { + this.$scope.forms.editForm.$setPristine(); + this.$scope.editPropertyModel.property = new PropertyModel(); + } + }; + + //in case we have uniqueId we call update method + if (this.$scope.isPropertyValueOwner) { + if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) { + let myValueString:string = JSON.stringify(this.$scope.myValue); + property.value = myValueString; + } + this.component.updateInstanceProperty(property).then(onPropertySuccess, onPropertyFaild); + } else { + if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) { + let myValueString:string = JSON.stringify(this.$scope.myValue); + property.defaultValue = myValueString; + } else { + this.$scope.editPropertyModel.property.defaultValue = this.$scope.editPropertyModel.property.value; + } + this.component.addOrUpdateProperty(property).then(onPropertySuccess, onPropertyFaild); + } + }; + + this.$scope.getPrev = ():void=> { + this.property = this.filteredProperties[--this.$scope.currentPropertyIndex]; + this.initResource(); + this.initForNotSimpleType(); + this.$scope.isLastProperty = false; + }; + + this.$scope.getNext = ():void=> { + this.property = this.filteredProperties[++this.$scope.currentPropertyIndex]; + this.initResource(); + this.initForNotSimpleType(); + this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1); + }; + + this.$scope.isSimpleType = (typeName:string):boolean=> { + return typeName && this.$scope.editPropertyModel.simpleTypes.indexOf(typeName) != -1; + }; + + this.$scope.showSchema = ():boolean => { + return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.$scope.editPropertyModel.property.type) > -1; + }; + + this.$scope.getValidationPattern = (type:string):RegExp => { + return this.ValidationUtils.getValidationPattern(type); + }; + + this.$scope.validateIntRange = (value:string):boolean => { + return !value || this.ValidationUtils.validateIntRange(value); + }; + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + // put default value when instance value is empty + this.$scope.onValueChange = ():void => { + if (!this.$scope.editPropertyModel.property.value) { + if (this.$scope.isPropertyValueOwner) { + this.$scope.editPropertyModel.property.value = this.$scope.editPropertyModel.property.defaultValue; + } + } + }; + + // Add the done button at the footer. + this.$scope.footerButtons = [ + {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid; + }); + + this.$scope.getDefaultValue = ():any => { + return this.$scope.isPropertyValueOwner ? this.$scope.editPropertyModel.property.defaultValue : null; + }; + + this.$scope.onTypeChange = ():void => { + this.$scope.editPropertyModel.property.value = ''; + this.$scope.editPropertyModel.property.defaultValue = ''; + this.setMaxLength(); + this.initForNotSimpleType(); + }; + + this.$scope.onSchemaTypeChange = ():void => { + if (this.$scope.editPropertyModel.property.type == PROPERTY_TYPES.MAP) { + this.$scope.myValue = {'': null}; + } else if (this.$scope.editPropertyModel.property.type == PROPERTY_TYPES.LIST) { + this.$scope.myValue = []; + } + this.setMaxLength(); + }; + + this.$scope.delete = (property:PropertyModel):void => { + let onOk = ():void => { + this.component.deleteProperty(property.uniqueId).then( + this.$scope.close + ); + }; + let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/forms/property-form/property-form-view.html b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html index d593d47a77..f92d9a5ddc 100644 --- a/catalog-ui/app/scripts/view-models/forms/property-form/property-form-view.html +++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html @@ -1,7 +1,8 @@ <sdc-modal modal="modalInstanceProperty" type="classic" class="sdc-edit-property-container" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true" data-tests-id="sdc-edit-property-container"> + <loader data-display="isLoading" relative="false" size="medium"></loader> <div class="sdc-modal-top-bar" data-ng-if="!isNew"> <div class="sdc-modal-top-bar-buttons"> - <span ng-click="delete(editPropertyModel.property)" data-ng-class="{'disabled' : isPropertyValueOwner()||editPropertyModel.property.readonly}" class="sprite-new delete-btn" data-tests-id="delete_property" sdc-smart-tooltip="">Delete</span> + <span ng-click="delete(editPropertyModel.property)" data-ng-class="{'disabled' : isPropertyValueOwner || editPropertyModel.property.readonly}" class="sprite-new delete-btn" data-tests-id="delete_property" sdc-smart-tooltip="">Delete</span> <span class="delimiter"></span> <span data-ng-click="getPrev()" data-ng-class="{'disabled' : !currentPropertyIndex }" class="sprite-new left-arrow" data-tests-id="get-prev" sdc-smart-tooltip="">Previous</span> <span data-ng-click="getNext()" data-ng-class="{'disabled' : isLastProperty }" class="sprite-new right-arrow" data-tests-id="get-next" sdc-smart-tooltip="">Next</span> @@ -34,28 +35,10 @@ <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid"> <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span> - <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '128' }"></span> + <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> </div> - </div> - - <!-- Input source --> - <!--div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.source.$dirty && forms.editForm.source.$invalid)}"> - <label class="i-sdc-form-label required">Input Source</label> - <select class="i-sdc-form-select" - data-required - name="source" - data-ng-model="editPropertyModel.property.source" - data-ng-options="source for source in editPropertyModel.sources"> - <option value="" >Choose Input Source</option> - </select> - <sdc-error-tooltip data-ng-show="forms.editForm.source.$dirty && forms.editForm.source.$invalid"> - <span ng-show="forms.editForm.source.$error.required">source is required.</span> - </sdc-error-tooltip> - </div--> - - </div> <div class="w-sdc-form-column"> @@ -67,7 +50,7 @@ <select class="i-sdc-form-select" data-tests-id="propertyType" data-required - data-ng-disabled="isPropertyValueOwner() || editPropertyModel.property.readonly" + data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly" name="type" data-ng-change="onTypeChange()" data-ng-model="editPropertyModel.property.type"> @@ -90,7 +73,7 @@ <select class="i-sdc-form-select" data-required data-tests-id="schema-type" - data-ng-disabled="isPropertyValueOwner() || editPropertyModel.property.readonly" + data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly" name="schemaType" data-ng-change="onSchemaTypeChange()" data-ng-model="editPropertyModel.property.schema.property.type"> @@ -123,9 +106,9 @@ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}"> <label class="i-sdc-form-label">Description</label> <textarea class="i-sdc-form-textarea" - data-ng-maxlength="256" - data-ng-disabled="isPropertyValueOwner() || editPropertyModel.property.readonly" - maxlength="256" + data-ng-maxlength="400" + data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly" + maxlength="400" data-ng-pattern="commentValidationPattern" name="description" data-ng-model="editPropertyModel.property.description" @@ -141,16 +124,15 @@ </div> <!-- Default value --> - <div data-ng-if="dataTypes" class="default-value-section i-sdc-form-item"> + <div class="default-value-section i-sdc-form-item"> <label class="i-sdc-form-label">Default Value</label> <div data-ng-if="isTypeDataType"> <fields-structure value-obj-ref="myValue" type-name="editPropertyModel.property.type" parent-form-obj="forms.editForm" fields-prefix-name="currentPropertyIndex" - read-only="editPropertyModel.property.readonly && !isPropertyValueOwner()" + read-only="editPropertyModel.property.readonly && !isPropertyValueOwner" default-value="{{getDefaultValue()}}" - types="dataTypes" expand-by-default="true"></fields-structure> </div> @@ -160,9 +142,8 @@ schema-property="editPropertyModel.property.schema.property" parent-form-obj="forms.editForm" fields-prefix-name="currentPropertyIndex" - read-only="editPropertyModel.property.readonly && !isPropertyValueOwner()" + read-only="editPropertyModel.property.readonly && !isPropertyValueOwner" default-value="{{getDefaultValue()}}" - types="dataTypes" max-length="maxLength"></type-map> </div> <div ng-switch-when="list"> @@ -170,30 +151,32 @@ schema-property="editPropertyModel.property.schema.property" parent-form-obj="forms.editForm" fields-prefix-name="currentPropertyIndex" - read-only="editPropertyModel.property.readonly && !isPropertyValueOwner()" + read-only="editPropertyModel.property.readonly && !isPropertyValueOwner" default-value="{{getDefaultValue()}}" - types="dataTypes" max-length="maxLength"></type-list> </div> <div ng-switch-default> - <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid), 'input-group' : editPropertyModel.property.addOn}"> + <span ng-if="editPropertyModel.property.addOn" class="input-group-addon">{{editPropertyModel.property.addOn}}</span> <input class="i-sdc-form-input" data-tests-id="defaultvalue" ng-if="!((editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean')" data-ng-maxlength="maxLength" - data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner()" + data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner" maxlength="{{maxLength}}" data-ng-model="editPropertyModel.property.value" type="text" name="value" data-ng-pattern="getValidationPattern((editPropertyModel.property.simpleType||editPropertyModel.property.type))" data-ng-model-options="{ debounce: 200 }" - data-ng-change="!forms.editForm.value.$error.pattern && ('integer'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editPropertyModel.property.value)) || onValueChange())" + data-ng-change="('json'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateJson(editPropertyModel.property.value))) + ||(!forms.editForm.value.$error.pattern && ('integer'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editPropertyModel.property.value)) || onValueChange()))" + data-ng-change="" autofocus /> <select class="i-sdc-form-select" data-tests-id="booleantype" ng-if="(editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean'" - data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner()" + data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner" name="value" data-ng-change="onValueChange()" data-ng-model="editPropertyModel.property.value"> @@ -205,7 +188,6 @@ <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property' }"></span> <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span> <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span> - <span ng-show="forms.editForm.value.$error.customValidation" translate="PROPERTY_EDIT_MAP_UNIQUE_KEYS"></span> </div> </div> </div> diff --git a/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts new file mode 100644 index 0000000000..7359ac0e91 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts @@ -0,0 +1,206 @@ +/** + * Created by obarda on 1/18/2017. + */ +'use strict'; +import {PropertyModel, DisplayModule, Component, Resource, Service, ComponentInstance} from "app/models"; +import {UNIQUE_GROUP_PROPERTIES_NAME} from "app/utils"; +import {IPropertyFormBaseViewScope, PropertyFormBaseView} from "../base-property-form/property-form-base-model"; +import {DataTypesService} from "app/services/data-types-service"; + +export interface IModulePropertyViewScope extends IPropertyFormBaseViewScope { + onValueChange():void; +} + +export class ModulePropertyView extends PropertyFormBaseView { + + static '$inject' = [ + '$scope', + '$templateCache', + '$uibModalInstance', + '$injector', + 'originalProperty', + 'component', + 'selectedModule', + 'Sdc.Services.DataTypesService', + '$q' + ]; + + constructor(protected $scope:IModulePropertyViewScope, + protected $templateCache:ng.ITemplateCacheService, + protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + protected $injector:ng.auto.IInjectorService, + protected originalProperty:PropertyModel, + protected component:Component, + private selectedModule:DisplayModule, + protected DataTypesService:DataTypesService, + private $q:ng.IQService) { + super($scope, $uibModalInstance, $injector, originalProperty, component, selectedModule.properties, DataTypesService); + + this.$templateCache.put("module-property-view.html", require('app/view-models/forms/property-forms/module-property-modal/module-property-view.html')); + this.$scope.innerViewSrcUrl = "module-property-view.html"; + this.initChildScope(); + } + + private findPropertyByName = (propertyName:string):PropertyModel => { + let property:PropertyModel = _.find(this.filteredProperties, (property:PropertyModel) => { + return property.name === propertyName; + }); + return property; + }; + + save(isNeedToCloseModal):ng.IPromise<boolean> { + + let deferred = this.$q.defer(); + + let onSuccess = (properties:Array<PropertyModel>):void => { + deferred.resolve(true); + if (isNeedToCloseModal === true) { + this.$scope.close(); + } + }; + + let onFailed = ():void => { + deferred.resolve(false); + }; + + let property = _.find(this.selectedModule.properties, (property) => { + return property.uniqueId === this.$scope.property.uniqueId; + }); + if (property.value !== this.$scope.property.value) { + if (this.component.isResource()) { + (<Resource>this.component).updateResourceGroupProperties(this.selectedModule, [this.$scope.property]).then(onSuccess, onFailed); // for now we only update one property at a time + } + if (this.component.isService()) { + // Find the component instance of the group instance + let componentInstance:ComponentInstance = _.find(this.component.componentInstances, (componentInstance:ComponentInstance) => { + let groupInstance = _.find(componentInstance.groupInstances, {uniqueId: this.selectedModule.groupInstanceUniqueId}); + return groupInstance !== undefined; + + }); + (<Service>this.component).updateGroupInstanceProperties(componentInstance.uniqueId, this.selectedModule, [this.$scope.property]).then(onSuccess, onFailed); // for now we only update one property at a time + } + } else { + deferred.resolve(true); + } + return deferred.promise; + } + + onPropertyChange():void { + this.initValidation(); + } + + protected initValidation = ():void => { + + this.$scope.isDeleteDisable = true; + this.$scope.isNameDisable = true; + this.$scope.isTypeSelectorDisable = true; + this.$scope.isDescriptionDisable = true; + + switch (this.$scope.property.name) { + case UNIQUE_GROUP_PROPERTIES_NAME.IS_BASE: + case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_TYPE: + case UNIQUE_GROUP_PROPERTIES_NAME.VOLUME_GROUP: + case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_LABEL: + this.$scope.property.readonly = true; + break; + case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_DESCRIPTION: + if (this.component.isService()) { + this.$scope.property.readonly = true; + } else { + this.$scope.property.readonly = false; + } + break; + } + }; + + private isUniqueProperty = ():boolean => { + return this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES || + this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES || + this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT; + }; + + + private initChildScope = ():void => { + + this.initValidation(); + + // put default value when instance value is empty + this.$scope.onValueChange = ():void => { + + if (!this.$scope.property.value) { // Resetting to default value + if (this.isPropertyValueOwner()) { + if (this.component.isService()) { + this.$scope.property.value = this.$scope.property.parentValue; + } else { + this.$scope.property.value = this.$scope.property.defaultValue; + } + } + } + + if (this.isUniqueProperty()) { + + let isValid = true; + let maxProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES); + let minProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES); + let initialCountProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT); + + let maxPropertyValue = parseInt(maxProperty.value); + let minPropertyValue = parseInt(minProperty.value); + let initialCountPropertyValue = parseInt(initialCountProperty.value); + let propertyValue = parseInt(this.$scope.property.value); + let parentPropertyValue = parseInt(this.$scope.property.parentValue); + + switch (this.$scope.property.name) { + + case UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES: + if (!maxPropertyValue || maxPropertyValue === null) { + isValid = propertyValue <= initialCountPropertyValue; + } + else { + isValid = propertyValue && (propertyValue <= maxPropertyValue && propertyValue <= initialCountPropertyValue); + } + this.$scope.forms.editForm["value"].$setValidity('maxValidation', isValid); + if (this.component.isService()) { + if (!parentPropertyValue || parentPropertyValue === null) { + isValid = true; + } else { + isValid = propertyValue >= parentPropertyValue; + this.$scope.forms.editForm["value"].$setValidity('minValidationVfLevel', isValid); + } + } + break; + case UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES: + if (!minPropertyValue || minPropertyValue === null) { + isValid = propertyValue >= initialCountPropertyValue; + } else { + isValid = !propertyValue || (propertyValue >= minPropertyValue && propertyValue >= initialCountPropertyValue); + } + this.$scope.forms.editForm["value"].$setValidity('minValidation', isValid); + if (this.component.isService()) { + if (!parentPropertyValue || parentPropertyValue === null) { + isValid = true; + } + else { + isValid = propertyValue <= parentPropertyValue; + this.$scope.forms.editForm["value"].$setValidity('maxValidationVfLevel', isValid); + } + } + break; + case UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT: + if ((!minPropertyValue || minPropertyValue === null) && (!maxPropertyValue || maxPropertyValue === null)) { + isValid = true; + } else if (!minPropertyValue || minPropertyValue === null) { + isValid = propertyValue <= maxPropertyValue; + } else if (!maxPropertyValue || maxPropertyValue === null) { + isValid = propertyValue >= minPropertyValue; + } else { + isValid = minPropertyValue <= propertyValue && propertyValue <= maxPropertyValue; + } + this.$scope.forms.editForm["value"].$setValidity('minOrMaxValidation', isValid); + break; + } + } + ; + } + } +} diff --git a/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html new file mode 100644 index 0000000000..175f4c199b --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html @@ -0,0 +1,41 @@ +<div class="default-value-section i-sdc-form-item"> + <label class="i-sdc-form-label">Default Value</label> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> + <input class="i-sdc-form-input" + data-tests-id="defaultvalue" + ng-if="!((property.simpleType||property.type) == 'boolean')" + data-ng-maxlength="maxLength" + data-ng-disabled="property.readonly && !isPropertyValueOwner()" + maxlength="100" + data-ng-model="property.value" + type="text" + name="value" + data-ng-pattern="getValidationPattern(property.type)" + data-ng-model-options="{ debounce: 200 }" + data-ng-change="onValueChange()" + /> + <select class="i-sdc-form-select" + data-tests-id="booleantype" + ng-if="(property.simpleType||property.type) == 'boolean'" + data-ng-disabled="property.readonly && !isPropertyValueOwner()" + name="value" + data-ng-model="property.value"> + <option value="true">true</option> + <option value="false">false</option> + </select> + + <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid"> + <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" + translate-values="{'field': 'Property' }"></span> + <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" + translate-values="{'max': '{{maxLength}}' }"></span> + <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span> + <span ng-show="forms.editForm.value.$error.minValidation" translate="MIN_VALIDATION_ERROR"></span> + <span ng-show="forms.editForm.value.$error.maxValidation" translate="MAX_VALIDATION_ERROR"></span> + <span ng-show="forms.editForm.value.$error.minOrMaxValidation" translate="MIN_MAX_VALIDATION"></span> + <span ng-show="forms.editForm.value.$error.minValidationVfLevel" translate="MIN_VALIDATION_VF_LEVE_ERROR"></span> + <span ng-show="forms.editForm.value.$error.maxValidationVfLevel" translate="MAX_VALIDATION_VF_LEVE_ERROR"></span> + + </div> + </div> +</div> diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts new file mode 100644 index 0000000000..48aa47fdd0 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts @@ -0,0 +1,97 @@ +'use strict'; +import {DataTypesService} from "app/services/data-types-service"; +import {PropertyModel, InputPropertyBase, Component} from "app/models"; +import {IPropertyFormBaseViewScope, PropertyFormBaseView} from "../base-property-form/property-form-base-model"; +import {PROPERTY_TYPES} from "app/utils/constants"; + +interface ISelectDataTypeViewModelScope extends IPropertyFormBaseViewScope { + selectedPropertiesName:string; + dataTypesService:DataTypesService; + path:string; + isTypeDataType:boolean; + myValue:any; + isReadOnly:boolean; +} + +export class SelectDataTypeViewModel extends PropertyFormBaseView { + + static '$inject' = [ + '$scope', + '$templateCache', + '$uibModalInstance', + '$injector', + 'originalProperty', + 'component', + 'filteredProperties', + 'Sdc.Services.DataTypesService', + 'propertiesMap', + '$q' + ]; + + constructor(protected $scope:ISelectDataTypeViewModelScope, + protected $templateCache:ng.ITemplateCacheService, + protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + protected $injector:ng.auto.IInjectorService, + protected originalProperty:PropertyModel, + protected component:Component, + protected filteredProperties:Array<PropertyModel>, + protected DataTypesService:DataTypesService, + private propertiesMap:Array<InputPropertyBase>, + private $q:ng.IQService) { + super($scope, $uibModalInstance, $injector, originalProperty, component, filteredProperties, DataTypesService); + + this.$templateCache.put("select-datatype-modal-view.html", require('app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html')); + this.$scope.innerViewSrcUrl = "select-datatype-modal-view.html"; + this.initChildScope(); + } + + //scope methods + save(isNeedToCloseModal):ng.IPromise<boolean> { + let deferred = this.$q.defer(); + this.$scope.property.propertiesName = this.DataTypesService.selectedPropertiesName; + this.$scope.property.input = this.DataTypesService.selectedInput; + this.$scope.property.isAlreadySelected = true; + this.$uibModalInstance.close(this.$scope.property); + deferred.resolve(true); + return deferred.promise; + }; + + private initForNotSimpleType = ():void => { + let property = this.$scope.property; + this.$scope.isTypeDataType = this.DataTypesService.isDataTypeForPropertyType(this.$scope.property); + if (property.type && this.$scope.simpleTypes.indexOf(property.type) == -1) { + if (!(property.value || property.defaultValue)) { + switch (property.type) { + case PROPERTY_TYPES.MAP: + this.$scope.myValue = {'': null}; + break; + case PROPERTY_TYPES.LIST: + this.$scope.myValue = []; + break; + default: + this.$scope.myValue = {}; + } + } else { + this.$scope.myValue = JSON.parse(property.value || property.defaultValue); + } + } + }; + + //remove selection property on the modal + private removeSelected = ():void => { + this.DataTypesService.selectedPropertiesName = null; + this.DataTypesService.selectedInput = null; + }; + + private initChildScope = ():void => { + //scope properties + this.$scope.forms = {}; + this.$scope.path = this.$scope.property.name; + this.$scope.isArrowsDisabled = true; + this.DataTypesService.alreadySelectedProperties = this.propertiesMap; + this.$scope.dataTypesService = this.DataTypesService; + this.$scope.isReadOnly = true; + this.initForNotSimpleType(); + this.removeSelected(); + } +} diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html new file mode 100644 index 0000000000..acb0f292ff --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html @@ -0,0 +1,74 @@ +<!--<div>selectedPropertiesName - {{dataTypesService.selectedPropertiesName}}</div>--> +<!--<div>selectedInput - {{dataTypesService.selectedInput}}</div>--> + +<div data-ng-if="dataTypes" class="default-value-section i-sdc-form-item"> + <label class="i-sdc-form-label">Default Value</label> + <div data-ng-if="isTypeDataType"> + <select-fields-structure value-obj-ref="myValue" + type-name="property.type" + parent-form-obj="forms.editForm" + fields-prefix-name="currentPropertyIndex" + read-only="true" + default-value="{{getDefaultValue()}}" + path="{{property.name}}" + is-parent-already-input="false" + expand-by-default="true"></select-fields-structure> + + </div> + <div data-ng-if="!isTypeDataType" ng-switch="property.type"> + <div ng-switch-when="map"> + + <select-type-map value-obj-ref="myValue" + schema-property="property.schema.property" + parent-form-obj="forms.editForm" + fields-prefix-name="currentPropertyIndex" + read-only="true" + default-value="{{getDefaultValue()}}" + max-length="maxLength"></select-type-map> + </div> + <div ng-switch-when="list"> + <select-type-list value-obj-ref="myValue" + schema-property="property.schema.property" + parent-form-obj="forms.editForm" + fields-prefix-name="currentPropertyIndex" + read-only="true" + default-value="{{getDefaultValue()}}" + max-length="maxLength"></select-type-list> + </div> + <div ng-switch-default> + <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}"> + <input class="i-sdc-form-input" + data-tests-id="defaultvalue" + ng-if="!((property.simpleType||property.type) == 'boolean')" + data-ng-maxlength="maxLength" + data-ng-disabled="isReadOnly" + maxlength="{{maxLength}}" + data-ng-model="property.value" + type="text" + name="value" + data-ng-pattern="getValidationPattern((property.simpleType||property.type))" + data-ng-model-options="{ debounce: 200 }" + data-ng-change="('json'==property.type && forms.editForm.value.$setValidity('pattern', validateJson(property.value))) + ||(!forms.editForm.value.$error.pattern && ('integer'==property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(property.value)) || onValueChange()))" + data-ng-change="" + autofocus /> + <select class="i-sdc-form-select" + data-tests-id="booleantype" + ng-if="(property.simpleType||property.type) == 'boolean'" + data-ng-disabled="isReadOnly" + name="value" + data-ng-change="onValueChange()" + data-ng-model="property.value"> + <option value="true">true</option> + <option value="false">false</option> + </select> + + <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid"> + <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property' }"></span> + <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span> + <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span> + </div> + </div> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less new file mode 100644 index 0000000000..15e30af4ee --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less @@ -0,0 +1,63 @@ +.sdc-edit-property-container { + .scrollbar-container{ + height: 415px; + width: 830px; + .perfect-scrollbar; + } + + form{ + width: 813px; + [name="description"]{ + min-height:50px; + } + } + + .sdc-modal-top-bar{ + height: 40px; + .sdc-modal-top-bar-buttons { + float: right; + + > span:not(.delimiter){ + vertical-align: middle; + .hand; + + &.sprite-new { + text-indent: 100%; + } + &.disabled, &:hover.disabled { + pointer-events: none; + } + } + + .delete-btn{ + margin-right: 6px; + } + + .left-arrow{ + margin-right: 8px; + } + + .delimiter { + height: 20px; + width: 1px; + background-color: #959595; + display: inline-block; + vertical-align: middle; + margin-right: 10px; + } + } + } + + .w-sdc-form-note { + .h_9; + display: block; + position: relative; + top: 13px; + } + + .default-value-section{ + border-top: solid 1px @main_color_a; + padding-top: 15px; + margin-top: 15px; + } +} diff --git a/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts new file mode 100644 index 0000000000..869e3db584 --- /dev/null +++ b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-model.ts @@ -0,0 +1,95 @@ +'use strict'; +import {ComponentInstanceFactory} from "app/utils"; +import {ComponentInstance} from "app/models"; +import {Requirement, Component, Capability} from "app/models"; + +interface IResourceInstanceViewModelScope extends ng.IScope { + + componentInstanceModel:ComponentInstance; + validationPattern:RegExp; + oldName:string; + isAlreadyPressed:boolean; + footerButtons:Array<any>; + forms:any; + modalInstanceName:ng.ui.bootstrap.IModalServiceInstance; + + save():void; + close():void; +} + +export class ResourceInstanceNameViewModel { + + static '$inject' = [ + '$scope', + 'ValidationPattern', + '$uibModalInstance', + 'component' + ]; + + + constructor(private $scope:IResourceInstanceViewModelScope, + private ValidationPattern:RegExp, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private component:Component) { + + this.initScope(); + } + + + private initScope = ():void => { + this.$scope.forms = {}; + this.$scope.validationPattern = this.ValidationPattern; + this.$scope.componentInstanceModel = ComponentInstanceFactory.createComponentInstance(this.component.selectedInstance); + this.$scope.oldName = this.component.selectedInstance.name; + this.$scope.modalInstanceName = this.$uibModalInstance; + + this.$scope.isAlreadyPressed = false; + + + this.$scope.close = ():void => { + this.$uibModalInstance.dismiss(); + }; + + this.$scope.save = ():void => { + + let onFailed = () => { + this.$scope.isAlreadyPressed = true; + }; + + let onSuccess = (componentInstance:ComponentInstance) => { + this.$uibModalInstance.close(); + this.$scope.isAlreadyPressed = false; + this.$scope.componentInstanceModel = componentInstance; + //this.component.name = componentInstance.name;//DE219124 + this.component.selectedInstance.name = componentInstance.name; + //update requirements and capabilities owner name + _.forEach(this.component.selectedInstance.requirements, (requirementsArray:Array<Requirement>) => { + _.forEach(requirementsArray, (requirement:Requirement):void => { + requirement.ownerName = componentInstance.name; + }); + }); + + _.forEach(this.component.selectedInstance.capabilities, (capabilitiesArray:Array<Capability>) => { + _.forEach(capabilitiesArray, (capability:Capability):void => { + capability.ownerName = componentInstance.name; + }); + }); + + }; + + this.$scope.isAlreadyPressed = true; + if (this.$scope.oldName != this.$scope.componentInstanceModel.name) { + this.component.updateComponentInstance(this.$scope.componentInstanceModel).then(onSuccess, onFailed); + } + }; + + this.$scope.footerButtons = [ + {'name': 'OK', 'css': 'blue', 'callback': this.$scope.save}, + {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close} + ]; + + this.$scope.$watch("[forms.editNameForm.$invalid,componentInstanceModel.name,isAlreadyPressed]", (newVal, oldVal) => { + this.$scope.footerButtons[0].disabled = this.$scope.forms.editNameForm.$invalid || this.$scope.isAlreadyPressed || this.$scope.componentInstanceModel.name === this.$scope.oldName; + }); + } +} diff --git a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name-view.html b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-view.html index e04343adbd..e04343adbd 100644 --- a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name-view.html +++ b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name-view.html diff --git a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name.less b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name.less index 57698bef17..57698bef17 100644 --- a/catalog-ui/app/scripts/view-models/forms/resource-instance-name-form/resource-instance-name.less +++ b/catalog-ui/src/app/view-models/forms/resource-instance-name-form/resource-instance-name.less diff --git a/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts new file mode 100644 index 0000000000..3d8b6c3053 --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal-view-model.ts @@ -0,0 +1,73 @@ +'use strict'; +import {ValidationUtils, ModalType} from "app/utils"; + +export interface IConfirmationModalModel { + title:string; + message:string; + showComment:boolean; + type:ModalType; +} + +interface IConfirmationModalViewModelScope { + modalInstanceConfirmation:ng.ui.bootstrap.IModalServiceInstance; + confirmationModalModel:IConfirmationModalModel; + comment:any; + commentValidationPattern:RegExp; + editForm:ng.IFormController; + okButtonColor:string; + hideCancelButton:boolean; + ok():any; + cancel():void; +} + +export class ConfirmationModalViewModel { + + static '$inject' = ['$scope', '$uibModalInstance', 'confirmationModalModel', 'CommentValidationPattern', 'ValidationUtils']; + + constructor(private $scope:IConfirmationModalViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + confirmationModalModel:IConfirmationModalModel, + private CommentValidationPattern:RegExp, + private ValidationUtils:ValidationUtils) { + + this.initScope(confirmationModalModel); + } + + private initScope = (confirmationModalModel:IConfirmationModalModel):void => { + let self = this; + this.$scope.hideCancelButton = false; + this.$scope.modalInstanceConfirmation = this.$uibModalInstance; + this.$scope.confirmationModalModel = confirmationModalModel; + this.$scope.comment = {"text": ''}; + this.$scope.commentValidationPattern = this.CommentValidationPattern; + + this.$scope.ok = ():any => { + self.$uibModalInstance.close(this.ValidationUtils.stripAndSanitize(self.$scope.comment.text)); + }; + + this.$scope.cancel = ():void => { + console.info('Cancel pressed on: ' + this.$scope.confirmationModalModel.title); + self.$uibModalInstance.dismiss(); + }; + + // Set the OK button color according to modal type (standard, error, alert) + let _okButtonColor = 'blue'; // Default + switch (confirmationModalModel.type) { + case ModalType.STANDARD: + _okButtonColor = 'blue'; + break; + case ModalType.ERROR: + _okButtonColor = 'red'; + break; + case ModalType.ALERT: + this.$scope.hideCancelButton = true; + _okButtonColor = 'grey'; + break; + default: + _okButtonColor = 'blue'; + break; + } + this.$scope.okButtonColor = _okButtonColor; + + } +} diff --git a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view.html b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal-view.html index 09c27f8cd3..09c27f8cd3 100644 --- a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal-view.html +++ b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal-view.html diff --git a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal.less b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal.less index 666c41d5ed..666c41d5ed 100644 --- a/catalog-ui/app/scripts/view-models/modals/confirmation-modal/confirmation-modal.less +++ b/catalog-ui/src/app/view-models/modals/confirmation-modal/confirmation-modal.less diff --git a/catalog-ui/src/app/view-models/modals/email-modal/email-modal-view-model.ts b/catalog-ui/src/app/view-models/modals/email-modal/email-modal-view-model.ts new file mode 100644 index 0000000000..f1fb56d0ff --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/email-modal/email-modal-view-model.ts @@ -0,0 +1,96 @@ +'use strict'; +import {IAppConfigurtaion, Component, AsdcComment} from "app/models"; +import {ValidationUtils} from "app/utils"; + +export interface IEmailModalModel_Email { + to:string; + subject:string; + message:string; +} + +export interface IEmailModalModel_Data { + component:Component; + stateUrl:string; +} + +export interface IEmailModalModel { + title:string; + email:IEmailModalModel_Email; + data:IEmailModalModel_Data; +} + +interface IEmailModalViewModelScope { + modalInstanceEmail:ng.ui.bootstrap.IModalServiceInstance; + emailModalModel:IEmailModalModel; + submitInProgress:boolean; + commentValidationPattern:RegExp; + isLoading:boolean; + submit():any; + cancel():void; + validateField(field:any):boolean; +} + +export class EmailModalViewModel { + + static '$inject' = ['$scope', '$filter', 'sdcConfig', '$uibModalInstance', 'emailModalModel', 'ValidationUtils', 'CommentValidationPattern']; + + constructor(private $scope:IEmailModalViewModelScope, + private $filter:ng.IFilterService, + private sdcConfig:IAppConfigurtaion, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private emailModalModel:IEmailModalModel, + private ValidationUtils:ValidationUtils, + private CommentValidationPattern:RegExp) { + + this.initScope(emailModalModel); + } + + private initScope = (emailModalModel:IEmailModalModel):void => { + this.$scope.emailModalModel = emailModalModel; + this.$scope.submitInProgress = false; + this.$scope.commentValidationPattern = this.CommentValidationPattern; + this.$scope.modalInstanceEmail = this.$uibModalInstance; + + this.$scope.submit = ():any => { + + let onSuccess = (component:Component) => { + this.$scope.isLoading = false; + this.$scope.submitInProgress = false; + // showing the outlook modal according to the config json + if (this.sdcConfig.showOutlook) { + let link:string = encodeURI(this.sdcConfig.api.baseUrl + "?folder=Ready_For_Testing"); + let outlook:string = this.$filter('translate')("EMAIL_OUTLOOK_MESSAGE", "{'to': '" + emailModalModel.email.to + "','subject': '" + emailModalModel.email.subject + "','message': '" + emailModalModel.email.message + "', 'entityNameAndVersion': '" + emailModalModel.email.subject + "','link': '" + link + "'}"); + window.location.href = outlook; // Open outlook with the email to send + } + this.$uibModalInstance.close(component); // Close the dialog + }; + + let onError = () => { + this.$scope.isLoading = false; + this.$scope.submitInProgress = false; + this.$uibModalInstance.close(); // Close the dialog + }; + + // Submit to server + // Prevent from user pressing multiple times on submit. + if (this.$scope.submitInProgress === false) { + this.$scope.isLoading = true; + this.$scope.submitInProgress = true; + let comment:AsdcComment = new AsdcComment(); + comment.userRemarks = emailModalModel.email.message; + emailModalModel.data.component.changeLifecycleState(emailModalModel.data.stateUrl, comment).then(onSuccess, onError); + } + }; + + this.$scope.cancel = ():void => { + this.$uibModalInstance.dismiss(); + }; + + this.$scope.validateField = (field:any):boolean => { + if (field && field.$dirty && field.$invalid) { + return true; + } + return false; + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal-view.html b/catalog-ui/src/app/view-models/modals/email-modal/email-modal-view.html index 82293a3091..bf65428033 100644 --- a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal-view.html +++ b/catalog-ui/src/app/view-models/modals/email-modal/email-modal-view.html @@ -1,7 +1,6 @@ <sdc-modal modal="modalInstanceEmail" type="classic" class="w-sdc-modal-email modal-type-standard" header="{{emailModalModel.title}}" show-close-button="true"> <loader data-display="isLoading"></loader> <form novalidate class="w-sdc-form" name="editForm"> - <div class="w-sdc-modal-body"> <div class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.to)}"> <label class="i-sdc-form-label col-sm-2">To</label> @@ -69,7 +68,6 @@ </div> - </div> </form> <div class="w-sdc-modal-footer classic"> diff --git a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal.less b/catalog-ui/src/app/view-models/modals/email-modal/email-modal.less index b946a097cd..471089fa1a 100644 --- a/catalog-ui/app/scripts/view-models/modals/email-modal/email-modal.less +++ b/catalog-ui/src/app/view-models/modals/email-modal/email-modal.less @@ -27,6 +27,7 @@ box-sizing: border-box; width: 100%; height: 127px; + margin-bottom: 20px; } label {.m_14_m; text-align: left;} diff --git a/catalog-ui/src/app/view-models/modals/error-modal/error-403-view.html b/catalog-ui/src/app/view-models/modals/error-modal/error-403-view.html new file mode 100644 index 0000000000..41b1c6df1d --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/error-modal/error-403-view.html @@ -0,0 +1,4 @@ +<div class="sdc-error-403-container" > + <div class="sdc-error-403-container-title" translate="GENERAL_ERROR_403_TITLE"></div> + <div class="w-sdc-error-403-text w-sdc-form" translate="GENERAL_ERROR_403_DESCRIPTION" translate-values="{{ mailtoJson }}"></div> +</div> diff --git a/catalog-ui/src/app/view-models/modals/error-modal/error-view-model.ts b/catalog-ui/src/app/view-models/modals/error-modal/error-view-model.ts new file mode 100644 index 0000000000..f622a6f53b --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/error-modal/error-view-model.ts @@ -0,0 +1,19 @@ +'use strict'; +import {CookieService} from "app/services"; + +interface IErrorViewModelScope { + mailto:string; +} + +export class ErrorViewModel { + + static ADMIN_EMAIL = 'dl-asdcaccessrequest@att.com'; + static SUBJECT_PRFIEX = 'SDC Access Request for'; + + static '$inject' = ['$scope', 'Sdc.Services.CookieService', '$window']; + + constructor($scope:IErrorViewModelScope, cookieService:CookieService, $window) { + let userDetails = cookieService.getFirstName() + ' ' + cookieService.getLastName() + ' (' + cookieService.getUserId() + ')'; + $scope.mailto = ErrorViewModel.ADMIN_EMAIL + '?subject=' + $window.encodeURIComponent(ErrorViewModel.SUBJECT_PRFIEX + ' ' + userDetails); + } +} diff --git a/catalog-ui/app/scripts/view-models/modals/error-modal/error.less b/catalog-ui/src/app/view-models/modals/error-modal/error.less index 8297b5053d..8297b5053d 100644 --- a/catalog-ui/app/scripts/view-models/modals/error-modal/error.less +++ b/catalog-ui/src/app/view-models/modals/error-modal/error.less diff --git a/catalog-ui/src/app/view-models/modals/message-modal/message-base-modal-model.ts b/catalog-ui/src/app/view-models/modals/message-modal/message-base-modal-model.ts new file mode 100644 index 0000000000..3c9e75238a --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-base-modal-model.ts @@ -0,0 +1,43 @@ +'use strict'; +import {SEVERITY} from "app/utils"; + +export interface IMessageModalModel { + title:string; + message:string; + severity:SEVERITY; +} + +export interface IMessageModalViewModelScope extends ng.IScope { + footerButtons:Array<any>; + messageModalModel:IMessageModalModel; + modalInstanceError:ng.ui.bootstrap.IModalServiceInstance; + ok():void; +} + +export class MessageModalViewModel { + + constructor(private $baseScope:IMessageModalViewModelScope, + private $baseModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private baseMessageModalModel:IMessageModalModel) { + + this.initScope(baseMessageModalModel); + } + + private initScope = (messageModalViewModel:IMessageModalModel):void => { + + this.$baseScope.messageModalModel = messageModalViewModel; + this.$baseScope.modalInstanceError = this.$baseModalInstance; + + this.$baseScope.ok = ():void => { + this.$baseModalInstance.close(); + }; + + this.$baseScope.footerButtons = [ + { + 'name': 'OK', + 'css': 'grey', + 'callback': this.$baseScope.ok + } + ]; + } +} diff --git a/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.ts b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.ts new file mode 100644 index 0000000000..053ea41ba3 --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal-view-model.ts @@ -0,0 +1,22 @@ +'use strict'; +import {IMessageModalModel, MessageModalViewModel, IMessageModalViewModelScope} from "../message-base-modal-model"; + +export interface IClientMessageModalModel extends IMessageModalModel { +} + +export interface IClientMessageModalViewModelScope extends IMessageModalViewModelScope { + clientMessageModalModel:IClientMessageModalModel; +} + +export class ClientMessageModalViewModel extends MessageModalViewModel { + + static '$inject' = ['$scope', '$uibModalInstance', 'clientMessageModalModel']; + + constructor(private $scope:IClientMessageModalViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private clientMessageModalModel:IClientMessageModalModel) { + + super($scope, $uibModalInstance, clientMessageModalModel); + } + +} diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view.html b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal-view.html index cfb0a35f69..cfb0a35f69 100644 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-client-modal/client-message-modal-view.html +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal-view.html diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal.less b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal.less index e69de29bb2..e69de29bb2 100644 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal.less +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-client-modal/client-message-modal.less diff --git a/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts new file mode 100644 index 0000000000..5f1d5e7a92 --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal-view-model.ts @@ -0,0 +1,24 @@ +'use strict'; +import {IMessageModalModel, IMessageModalViewModelScope, MessageModalViewModel} from "../message-base-modal-model"; + +export interface IServerMessageModalModel extends IMessageModalModel { + status:string; + messageId:string; +} + +export interface IServerMessageModalViewModelScope extends IMessageModalViewModelScope { + serverMessageModalModel:IServerMessageModalModel; +} + +export class ServerMessageModalViewModel extends MessageModalViewModel { + + static '$inject' = ['$scope', '$uibModalInstance', 'serverMessageModalModel']; + + constructor(private $scope:IServerMessageModalViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private serverMessageModalModel:IServerMessageModalModel) { + + super($scope, $uibModalInstance, serverMessageModalModel); + } + +} diff --git a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view.html b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal-view.html index 294dc76c4c..294dc76c4c 100644 --- a/catalog-ui/app/scripts/view-models/modals/message-modal/message-server-modal/server-message-modal-view.html +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal-view.html diff --git a/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal.less b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal.less new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/message-modal/message-server-modal/server-message-modal.less diff --git a/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts new file mode 100644 index 0000000000..8e7e79c576 --- /dev/null +++ b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal-view-model.ts @@ -0,0 +1,249 @@ +'use strict'; +import {ComponentType, CHANGE_COMPONENT_CSAR_VERSION_FLAG, SEVERITY, FileUtils, ModalsHandler, ComponentFactory} from "app/utils"; +import {OnboardingService, CacheService} from "app/services"; +import {Component, IComponent, IUser, IAppConfigurtaion, Resource} from "app/models"; +import {IServerMessageModalModel} from "../message-modal/message-server-modal/server-message-modal-view-model"; +import {Dictionary} from "app/utils"; +import * as _ from 'underscore'; + +interface IOnboardingModalViewModelScope { + modalOnboarding:ng.ui.bootstrap.IModalServiceInstance; + componentsList:Array<IComponent>; + tableHeadersList:Array<any>; + selectedComponent:Component; + componentFromServer:Component; + reverse:boolean; + sortBy:string; + searchBind:string; + okButtonText:string; + isCsarComponentExists:boolean; + user:IUser; + isLoading:boolean; + + //this is for UI paging + numberOfItemsToDisplay:number; + allItemsDisplayed:boolean; + + doSelectComponent(component:Component):void; + doUpdateCsar():void; + doImportCsar():void; + sort(sortBy:string):void; + downloadCsar(packageId:string):void; + increaseNumItemsToDisplay():void; +} + +export class OnboardingModalViewModel { + + static '$inject' = [ + '$scope', + '$filter', + '$state', + 'sdcConfig', + '$uibModalInstance', + 'Sdc.Services.OnboardingService', + 'okButtonText', + 'currentCsarUUID', + 'Sdc.Services.CacheService', + 'FileUtils', + 'ComponentFactory', + 'ModalsHandler' + ]; + + constructor(private $scope:IOnboardingModalViewModelScope, + private $filter:ng.IFilterService, + private $state:any, + private sdcConfig:IAppConfigurtaion, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private onBoardingService:OnboardingService, + private okButtonText:string, + private currentCsarUUID:string, + private cacheService:CacheService, + private fileUtils:FileUtils, + private componentFactory:ComponentFactory, + private modalsHandler:ModalsHandler) { + + this.init(); + } + + /** + * Called from controller constructor, this will call onboarding service to get list + * of "mini" components (empty components created from CSAR). + * The list is inserted to componentsList on $scope. + * And then call initScope method. + */ + private init = ():void => { + this.initOnboardingComponentsList(); + }; + + private initScope = ():void => { + + this.initSortedTableScope(); + this.initModalScope(); + this.$scope.sortBy = "name"; // Default sort by + this.$scope.user = this.cacheService.get('user'); + this.$scope.okButtonText = this.okButtonText; + this.$scope.numberOfItemsToDisplay = 0; + this.$scope.allItemsDisplayed = false; + + // Dismiss the modal and pass the "mini" component to workspace general page + this.$scope.doImportCsar = ():void => { + this.$uibModalInstance.dismiss(); + this.$state.go('workspace.general', { + type: ComponentType.RESOURCE.toLowerCase(), + componentCsar: this.$scope.selectedComponent + }); + }; + + this.$scope.doUpdateCsar = ():void => { + // In case user select on update the checkin and submit for testing buttons (in general page) should be disabled. + // to do that we need to pass to workspace.general state parameter to know to disable the buttons. + this.$uibModalInstance.close(); + // Change the component version to the CSAR version we want to update. + /*(<Resource>this.$scope.componentFromServer).csarVersion = (<Resource>this.$scope.selectedComponent).csarVersion; + let component:Components.Component = this.componentFactory.createComponent(this.$scope.componentFromServer); + this.$state.go('workspace.general', {vspComponent: component, disableButtons: true });*/ + this.cacheService.set(CHANGE_COMPONENT_CSAR_VERSION_FLAG, (<Resource>this.$scope.selectedComponent).csarVersion); + this.$state.go('workspace.general', { + id: this.$scope.componentFromServer.uniqueId, + type: this.$scope.componentFromServer.componentType.toLowerCase(), + disableButtons: true + }); + }; + + this.$scope.downloadCsar = (packageId:string):void => { + this.$scope.isLoading = true; + this.onBoardingService.downloadOnboardingCsar(packageId).then( + (file:any):void => { + this.$scope.isLoading = false; + if (file) { + this.fileUtils.downloadFile(file, packageId + '.csar'); + } + }, ():void => { + this.$scope.isLoading = false; + var data:IServerMessageModalModel = { + title: 'Download error', + message: "Error downloading file", + severity: SEVERITY.ERROR, + messageId: "", + status: "" + }; + this.modalsHandler.openServerMessageModal(data); + } + ); + }; + + this.$scope.increaseNumItemsToDisplay = ():void => { + this.$scope.numberOfItemsToDisplay = this.$scope.numberOfItemsToDisplay + 40; + if (this.$scope.componentsList) { + this.$scope.allItemsDisplayed = this.$scope.numberOfItemsToDisplay >= this.$scope.componentsList.length; + } + }; + + // When the user select a row, set the component as selectedComponent + this.$scope.doSelectComponent = (component:Component):void => { + + if (this.$scope.selectedComponent === component) { + // Collapse the item + this.$scope.selectedComponent = undefined; + return; + } + + this.$scope.isLoading = true; + this.$scope.componentFromServer = undefined; + this.$scope.selectedComponent = component; + + let onSuccess = (componentFromServer:Component):void => { + this.$scope.isLoading = false; + if (componentFromServer) { + this.$scope.componentFromServer = componentFromServer; + this.$scope.isCsarComponentExists = true; + } else { + this.$scope.componentFromServer = component; + this.$scope.isCsarComponentExists = false; + } + }; + + let onError = ():void => { + this.$scope.isLoading = false; + this.$scope.componentFromServer = component; + this.$scope.isCsarComponentExists = false; + }; + + this.onBoardingService.getComponentFromCsarUuid((<Resource>component).csarUUID).then(onSuccess, onError); + }; + + }; + + private initSortedTableScope = ():void => { + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Vendor', property: 'vendorName'}, + {title: 'Category', property: 'categories'}, + {title: 'Version', property: 'csarVersion'}, + {title: '#', property: 'importAndUpdate'} + //{title: 'Date', property: 'componentDate'} + ]; + + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + }; + + private initModalScope = ():void => { + // Enable the modal directive to close + this.$scope.modalOnboarding = this.$uibModalInstance; + }; + + private initOnboardingComponentsList = ():void => { + let onSuccess = (onboardingResponse:Array<IComponent>):void => { + initMaxVersionOfItemsInList(onboardingResponse); + + if (this.currentCsarUUID) { + //this.$scope.componentsList = this.$filter('filter')(this.$scope.componentsList, {csarUUID: this.currentCsarUUID}); + this.$scope.componentsList = this.$filter('filter')(this.$scope.componentsList, + (input):boolean => { + return input.csarUUID === this.currentCsarUUID; + } + ); + } + this.initScope(); + }; + + let onError = ():void => { + console.log("Error getting onboarding list"); + this.initScope(); + }; + + let initMaxVersionOfItemsInList = (onboardingResponse:Array<IComponent>):void => { + // Get only the latest version of each item + this.$scope.componentsList = []; + + // Get all unique items from the list + let uniqueItems:Array<any> = _.uniq(onboardingResponse, false, (item:any):void=>{ + return item.packageId; + }); + + // Loop on all the items with unique packageId + _.each(uniqueItems, (item:any):void=> { + // Find all the items that has same packageId + let ItemsFound:Array<IComponent> = _.filter(onboardingResponse, (inListItem:any):any => { + return inListItem.packageId === item.packageId; + }); + + // Loop on all the items with same packageId and find the max version. + let maxItem:any; + _.each(ItemsFound, (ItemFound:any):void=> { + if (!maxItem) { + maxItem = ItemFound; + } else if (maxItem && parseInt(maxItem.csarVersion) < parseInt(ItemFound.csarVersion)) { + maxItem = ItemFound; + } + }); + this.$scope.componentsList.push(maxItem); + }); + }; + + this.onBoardingService.getOnboardingComponents().then(onSuccess, onError); + }; +} diff --git a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view.html b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal-view.html index 246915212c..3657fad017 100644 --- a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal-view.html +++ b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal-view.html @@ -28,15 +28,17 @@ <!-- Table body --> <div class="body"> - <perfect-scrollbar suppress-scroll-x="true" scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <perfect-scrollbar suppress-scroll-x="true" scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container" id="onboarding-modal-scrollbar-container"> <!-- In case the component list is empty --> <div data-ng-if="!componentsList || componentsList.length===0" class="no-row-text"> There are no software product component to display </div> + <div infinite-scroll-disabled='allItemsDisplayed' infinite-scroll="increaseNumItemsToDisplay()" infinite-scroll-container="'#onboarding-modal-scrollbar-container'"> + <!-- Loop on components list --> - <div data-ng-repeat-start="component in componentsList | filter: searchBind | orderBy:sortBy:reverse track by $index" + <div data-ng-repeat-start="component in componentsList | filter: searchBind | orderBy:sortBy:reverse | limitTo:numberOfItemsToDisplay track by $index" class="flex-container data-row" data-ng-class="{'selected': component === selectedComponent}" data-ng-click="doSelectComponent(component);" @@ -130,7 +132,7 @@ data-tests-id="download-csar"></span> </div> <loader data-display="isLoading" relative="true" size="small"></loader> - + </div> </div> </perfect-scrollbar> diff --git a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal.less b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal.less index c745a86888..c745a86888 100644 --- a/catalog-ui/app/scripts/view-models/modals/onboarding-modal/onboarding-modal.less +++ b/catalog-ui/src/app/view-models/modals/onboarding-modal/onboarding-modal.less diff --git a/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts new file mode 100644 index 0000000000..faeaefb5e5 --- /dev/null +++ b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view-model.ts @@ -0,0 +1,125 @@ +'use strict'; +import {IUserProperties} from "app/models"; +import {MenuItemGroup, MenuItem} from "app/utils"; +import {CacheService} from "app/services"; + +export class BreadcrumbsMenuItem { + key:string; + displayText:string; +} + +export class BreadcrumbsMenu { + selectedKey:string; + menuItems:Array<BreadcrumbsMenuItem>; +} + +export class BreadcrumbsPath { + selectedKeys:Array<string>; +} + +export class VendorData { + breadcrumbs:BreadcrumbsPath; +} + +export interface IOnboardVendorViewModelScope extends ng.IScope { + vendorData:VendorData; + onVendorEvent:Function; + topNavMenuModel:Array<MenuItemGroup>; + topNavRootMenu:MenuItemGroup; + user:IUserProperties; + version:string; +} + +export class OnboardVendorViewModel { + static '$inject' = [ + '$scope', + '$q', + 'Sdc.Services.CacheService' + ]; + + private firstControlledTopNavMenu:MenuItemGroup; + + constructor(private $scope:IOnboardVendorViewModelScope, + private $q:ng.IQService, + private cacheService:CacheService) { + + this.$scope.vendorData = { + breadcrumbs: { + selectedKeys: [] + } + }; + + this.$scope.version = this.cacheService.get('version'); + + this.$scope.onVendorEvent = (eventName:string, data:any):void => { + switch (eventName) { + case 'breadcrumbsupdated': + this.handleBreadcrumbsUpdate(data); + break; + } + }; + + this.$scope.topNavMenuModel = []; + + this.$scope.user = this.cacheService.get('user'); + } + + updateBreadcrumbsPath = (selectedKeys:Array<string>):ng.IPromise<boolean> => { + let topNavMenuModel = this.$scope.topNavMenuModel; + let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); + if (startIndex === -1) { + startIndex = topNavMenuModel.length; + } + topNavMenuModel.splice(startIndex + selectedKeys.length); + this.$scope.vendorData = { + breadcrumbs: {selectedKeys: selectedKeys} + }; + + return this.$q.when(true); + }; + + handleBreadcrumbsUpdate(breadcrumbsMenus:Array<BreadcrumbsMenu>):void { + let selectedKeys = []; + let topNavMenus = breadcrumbsMenus.map((breadcrumbMenu, breadcrumbIndex) => { + let topNavMenu = new MenuItemGroup(); + topNavMenu.menuItems = breadcrumbMenu.menuItems.map(menuItem => + new MenuItem( + menuItem.displayText, + this.updateBreadcrumbsPath, + null, + null, + [selectedKeys.concat([menuItem.key])] + ) + ); + topNavMenu.selectedIndex = _.findIndex( + breadcrumbMenu.menuItems, + menuItem => menuItem.key === breadcrumbMenu.selectedKey + ); + selectedKeys.push(breadcrumbMenu.selectedKey); + return topNavMenu; + }); + + let topNavMenuModel = this.$scope.topNavMenuModel; + let len = topNavMenuModel.length; + let startIndex = topNavMenuModel.indexOf(this.firstControlledTopNavMenu); + if (startIndex === -1) { + startIndex = len; + } + topNavMenuModel.splice(startIndex, len - startIndex); + topNavMenuModel.push.apply(topNavMenuModel, topNavMenus); + this.firstControlledTopNavMenu = topNavMenus[0]; + + if (startIndex === 1 && this.$scope.topNavRootMenu == null) { + let topNavRootMenu = topNavMenuModel[0]; + let onboardItem = topNavRootMenu.menuItems[topNavRootMenu.selectedIndex]; + let originalCallback = onboardItem.callback; + onboardItem.callback = (...args) => { + let ret = this.updateBreadcrumbsPath([]); + return originalCallback && originalCallback.apply(undefined, args) || ret; + }; + this.$scope.topNavRootMenu = topNavRootMenu; + } + + this.updateBreadcrumbsPath(selectedKeys); + } +} diff --git a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor-view.html b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html index 733e2d0cc0..734fb93daf 100644 --- a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor-view.html +++ b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor-view.html @@ -11,4 +11,6 @@ <top-nav top-lvl-selected-index="2" search-bind="search.filterTerm" menu-model="topNavMenuModel" version="{{version}}" hide-search="true"></top-nav> + <ecomp-footer></ecomp-footer> + </div> diff --git a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor.less b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor.less index 2b43bbb321..4a16ca2b5b 100644 --- a/catalog-ui/app/scripts/view-models/onboard-vendor/onboard-vendor.less +++ b/catalog-ui/src/app/view-models/onboard-vendor/onboard-vendor.less @@ -83,7 +83,7 @@ &.NOT_CERTIFIED_CHECKOUT, &.NOT_CERTIFIED_CHECKIN { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2889px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2889px; width: 14px; height: 14px; @@ -92,7 +92,7 @@ &.CERTIFIED { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -3034px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -3034px; width: 14px; height: 16px; } @@ -100,7 +100,7 @@ &.READY_FOR_CERTIFICATION { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2985px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2985px; width: 14px; height: 16px; } @@ -108,7 +108,7 @@ &.CERTIFICATION_IN_PROGRESS { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -53px -2934px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -53px -2934px; width: 14px; height: 16px; } @@ -117,7 +117,7 @@ &.DISTRIBUTED, &.TBD { .i-sdc-categories-list-item-icon { - background: url('../../../styles/images/sprites/sprite-global-old.png') no-repeat -43px -3087px; + background: url('/assets/styles/images/sprites/sprite-global-old.png') no-repeat -43px -3087px; width: 24px; height: 14px; diff --git a/catalog-ui/app/scripts/view-models/preloading/preloading-view.html b/catalog-ui/src/app/view-models/preloading/preloading-view.html index c0512dd9ec..c0512dd9ec 100644 --- a/catalog-ui/app/scripts/view-models/preloading/preloading-view.html +++ b/catalog-ui/src/app/view-models/preloading/preloading-view.html diff --git a/catalog-ui/src/app/view-models/preloading/preloading-view.ts b/catalog-ui/src/app/view-models/preloading/preloading-view.ts new file mode 100644 index 0000000000..f299f2a30f --- /dev/null +++ b/catalog-ui/src/app/view-models/preloading/preloading-view.ts @@ -0,0 +1,27 @@ +'use strict'; + +interface IPreLoadingViewScope { + startZoomIn:boolean; +} + +export class PreLoadingViewModel { + + static '$inject' = ['$scope']; + + constructor(private $scope:IPreLoadingViewScope) { + this.init($scope); + } + + private init = ($scope:IPreLoadingViewScope):void => { + this.animate($('.caption1'), 'fadeInUp', 400); + this.animate($('.caption2'), 'fadeInUp', 800); + }; + + private animate = (element:any, animation:string, when:number):void => { + window.setTimeout(()=> { + element.addClass("animated " + animation); + element[0].style = "visibility: visible;"; + }, when); + }; + +} diff --git a/catalog-ui/src/app/view-models/support/support-view-model.ts b/catalog-ui/src/app/view-models/support/support-view-model.ts new file mode 100644 index 0000000000..2f43d87b18 --- /dev/null +++ b/catalog-ui/src/app/view-models/support/support-view-model.ts @@ -0,0 +1,16 @@ +'use strict'; +import {CacheService} from "app/services"; + +interface ISupportViewModelScope { + version:string; +} + +export class SupportViewModel { + + static '$inject' = ['$scope', 'Sdc.Services.CacheService']; + + constructor(private $scope:ISupportViewModelScope, + private cacheService:CacheService) { + this.$scope.version = this.cacheService.get('version'); + } +} diff --git a/catalog-ui/app/scripts/view-models/support/support-view.html b/catalog-ui/src/app/view-models/support/support-view.html index 0e6d09ddd7..88609774bb 100644 --- a/catalog-ui/app/scripts/view-models/support/support-view.html +++ b/catalog-ui/src/app/view-models/support/support-view.html @@ -3,7 +3,7 @@ <div class="w-sdc-header"> <div class="w-sdc-header-logo"> <div class="w-sdc-header-logo-icon sprite logo"></div> - <a class="w-sdc-header-logo-link" data-ui-sref="dashboard">ASDC</a> + <a class="w-sdc-header-logo-link" data-ui-sref="dashboard" translate="PROJECT_TITLE"></a> <div class="w-sdc-header-version"> v.{{version}}</div> </div> <div class="i-sdc-header-caption">Support</div> @@ -27,7 +27,5 @@ <div class="i-sdc-left-sidebar-nav-item support" data-ui-sref="support">Support</div> </div> </div> - - </div> </div> diff --git a/catalog-ui/app/scripts/view-models/support/support.less b/catalog-ui/src/app/view-models/support/support.less index 8159e38320..8159e38320 100644 --- a/catalog-ui/app/scripts/view-models/support/support.less +++ b/catalog-ui/src/app/view-models/support/support.less diff --git a/catalog-ui/app/scripts/view-models/tabs/general-tab.less b/catalog-ui/src/app/view-models/tabs/general-tab.less index a8b4f5b9be..936b3e3414 100644 --- a/catalog-ui/app/scripts/view-models/tabs/general-tab.less +++ b/catalog-ui/src/app/view-models/tabs/general-tab.less @@ -12,8 +12,7 @@ .f-color.a; .f-type._14_m; - padding: 0px 0px 15px 0px; - margin: 0px 20px 0px 20px; + padding: 0px 0px 15px 20px; border-bottom: 1px solid @main_color_o; } @@ -39,10 +38,6 @@ .expand-collapse-title { .expand-collapse-title-icon { .expand-collapse-minus-icon; - - &:hover { - .expand-collapse-minus-icon.hover; - } } } } @@ -59,10 +54,6 @@ .hand; .sprite-new; .expand-collapse-plus-icon; - &:hover { - .expand-collapse-plus-icon.hover; - } - } .expand-collapse-title-text { max-width: 225px; @@ -87,7 +78,7 @@ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - padding-left: 43px; + padding: 10px 0 0 43px; } diff --git a/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view-model.ts b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view-model.ts new file mode 100644 index 0000000000..7c505512c4 --- /dev/null +++ b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view-model.ts @@ -0,0 +1,98 @@ +'use strict'; +import {ModalsHandler} from "app/utils"; +import {PropertyModel, DisplayModule, Component, ComponentInstance, Tab, Module} from "app/models"; +import {ExpandCollapseListData} from "app/directives/utils/expand-collapse-list-header/expand-collapse-list-header"; + +export interface IHierarchyScope extends ng.IScope { + component:Component; + selectedIndex:number; + selectedModule:DisplayModule; + singleTab:Tab; + isLoading:boolean; + expandCollapseArtifactsList:ExpandCollapseListData; + expandCollapsePropertiesList:ExpandCollapseListData; + selectedInstanceId:string; + + onModuleSelected(moduleId:string, selectedIndex:number):void; + onModuleNameChanged(module:DisplayModule):void; + updateHeatName():void; + loadInstanceModules(instance:ComponentInstance):ng.IPromise<boolean>; + openEditPropertyModal(property:PropertyModel):void; +} + +export class HierarchyViewModel { + + static '$inject' = [ + '$scope', + '$q', + 'ModalsHandler' + ]; + + constructor(private $scope:IHierarchyScope, private $q:ng.IQService, private ModalsHandler:ModalsHandler) { + this.$scope.component = this.$scope.singleTab.data; + this.$scope.isLoading = false; + this.$scope.expandCollapseArtifactsList = new ExpandCollapseListData(); + this.$scope.expandCollapsePropertiesList = new ExpandCollapseListData(); + this.initScopeMethods(); + } + + private initScopeMethods():void { + + let collapseModuleData = ():void => { + this.$scope.expandCollapseArtifactsList.expandCollapse = false; + this.$scope.expandCollapsePropertiesList.expandCollapse = false; + this.$scope.expandCollapseArtifactsList.orderByField = "artifactName"; + this.$scope.expandCollapsePropertiesList.orderByField = "name"; + }; + + this.$scope.onModuleSelected = (moduleId:string, selectedIndex:number, componentInstanceId?:string):void => { + + let onSuccess = (module:DisplayModule) => { + console.log("Module Loaded: ", module); + this.$scope.selectedModule = module; + this.$scope.isLoading = false; + collapseModuleData(); + }; + + let onFailed = () => { + this.$scope.isLoading = false; + }; + + this.$scope.selectedIndex = selectedIndex; + if (!this.$scope.selectedModule || (this.$scope.selectedModule && this.$scope.selectedModule.uniqueId != moduleId)) { + this.$scope.isLoading = true; + if (this.$scope.component.isService()) { + this.$scope.selectedInstanceId = componentInstanceId; + this.$scope.component.getModuleInstanceForDisplay(componentInstanceId, moduleId).then(onSuccess, onFailed); + } else { + this.$scope.component.getModuleForDisplay(moduleId).then(onSuccess, onFailed); + } + } + }; + + this.$scope.updateHeatName = () => { + this.$scope.isLoading = true; + + let originalName:string = this.$scope.selectedModule.name; + + let onSuccess = (module:Module) => { + console.log("Module name updated:", module.name); + this.$scope.selectedModule.name = module.name; + this.$scope.isLoading = false; + }; + + let onFailed = () => { + this.$scope.isLoading = false; + this.$scope.selectedModule.name = originalName; + }; + + this.$scope.selectedModule.updateName(); + this.$scope.component.updateGroupMetadata(new DisplayModule(this.$scope.selectedModule)).then(onSuccess, onFailed); + }; + + this.$scope.openEditPropertyModal = (property:PropertyModel):void => { + this.ModalsHandler.openEditModulePropertyModal(property, this.$scope.component, this.$scope.selectedModule).then(() => { + }); + } + } +} diff --git a/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view.html b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view.html new file mode 100644 index 0000000000..9eaa3a0f76 --- /dev/null +++ b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy-view.html @@ -0,0 +1,107 @@ +<div class="sdc-general-tab hierarchy-tab" ng-class=""> + <loader data-display="isLoading" relative="true" size="medium"></loader> + <div class="sdc-general-tab-title" data-tests-id="tab-header" translate="DEPLOYMENT_TAB_TITLE"></div> + + <div class="resizable-container"> + <div data-ng-if="!component.isService()"class="resizable-section"> + + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" + class="general-tab-scrollbar-container"> + <div class="sdc-general-tab-sub-title" data-tests-id="tab-sub-header">{{component.name}}</div> + <expand-collapse expanded-selector=".hierarchy-module-member-list.{{$index}}" + class="general-tab-expand-collapse" is-close-on-init="true" + data-tests-id="hierarchy-module-{{$index}}" + data-ng-repeat-start="module in component.groups"> + <div class="expand-collapse-title first-level" data-tests-id="hierarchy-module-{{$index}}-title" ng-class="{'selected': selectedIndex === $index}" data-ng-click="onModuleSelected(module.uniqueId, $index)"> + <div class="expand-collapse-title-icon"></div> + <span class="expand-collapse-title-text" data-ng-bind="module.name" tooltips + tooltip-content="{{module.name}}"></span> + + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="hierarchy-module-member-list {{$index}}"> + <div ng-repeat="(memberName, value) in ::module.members track by $index"> + <div class="expand-collapse-sub-title" tooltips tooltip-content="{{memberName}}">{{memberName}}</div> + </div> + </div> + </perfect-scrollbar> + </div> + <div data-ng-if="component.isService()"class="resizable-section"> + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" + class="general-tab-scrollbar-container"> + <expand-collapse expanded-selector=".hierarchy-modules-list.{{$index}}" + class="general-tab-expand-collapse" is-close-on-init="true" + data-tests-id="hierarchy-instance-{{$index}}" + + data-ng-repeat-start="instance in component.componentInstances"> + <div class="expand-collapse-title first-level" data-tests-id="hierarchy-instance-{{$index}}-title"> + <div class="expand-collapse-title-icon"></div> + <span class="expand-collapse-title-text" data-ng-bind="instance.name" tooltips + tooltip-content="{{instance.name}}"></span> + + </div> + </expand-collapse> + <!--TODO: Rachel : --> + <div data-ng-repeat-end="" class="hierarchy-modules-list {{$index}}"> + <expand-collapse expanded-selector=".outer-index-{{$parent.$index}}.hierarchy-module-member-list.{{$index}}" + class="general-tab-expand-collapse" is-close-on-init="true" + data-tests-id="hierarchy-module-{{$index}}" + data-ng-repeat-start="module in instance.groupInstances"> + <div class="expand-collapse-title second-level" data-tests-id="hierarchy-module-{{$index}}-title" ng-class="{'selected': selectedIndex === $index && selectedInstanceId === instance.uniqueId}" data-ng-click="onModuleSelected(module.uniqueId, $index, instance.uniqueId)"> + <div class="expand-collapse-title-icon"></div> + <span class="expand-collapse-title-text" data-ng-bind="module.name" tooltips tooltip-content="{{module.name}}"></span> + + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="outer-index-{{$parent.$index}} hierarchy-module-member-list {{$index}}"> + <div ng-repeat="(memberName, value) in ::module.members track by $index"> + <div class="expand-collapse-sub-title" tooltips tooltip-content="{{memberName}}">{{memberName}}</div> + </div> + </div> + </div> + </perfect-scrollbar> + </div> + + <div resizable r-directions="['top']" r-flex="true" ng-if="selectedModule" class="resizable-section module-data-container" data-tests-id="selected-module-data"> + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" + class="general-tab-scrollbar-container"> + <div class="module-data"> + <div> + <div class="module-name module-text-overflow" data-tests-id="selected-module-name" tooltips tooltip-content="{{selectedModule.name}}">{{selectedModule.name}}</div> + <div class="edit-name-container" data-ng-if="!component.isService()"> + <edit-name-popover header="Edit Module Name" direction="auto top" module="selectedModule" on-save="updateHeatName()" ng-class="{'disabled': isViewOnly}" class="sdc-edit-icon" data-tests-id="edit-name-popover-icon"></edit-name-popover> + </div> + </div> + <div class="" data-tests-id="selected-module-group-uuid" tooltips tooltip-content="{{selectedModule.groupUUID}}"><span class="bold">Module ID:</span><br><span class="small-font">{{selectedModule.groupUUID}}</span></div> + <div class="" data-tests-id="selected-module-group-customization-uuid" data-ng-if="component.isService() && isViewOnly" tooltips tooltip-content="{{selectedModule.customizationUUID}}"><span class="bold">Customization ID:</span ><br><span class="small-font">{{selectedModule.customizationUUID}}</span></div> + <div class="" data-tests-id="selected-module-group-invariant-uuid" tooltips tooltip-content="{{selectedModule.invariantUUID}}"><span class="bold">Invariant UUID:</span><span class="small-font">{{selectedModule.invariantUUID}}</span></div> + <div data-tests-id="selected-module-version"><span class="bold">Version:</span> {{selectedModule.version}}</div> + <div data-tests-id="selected-module-is-base"><span class="bold">IsBase:</span> {{selectedModule.isBase}}</div> + + </div> + <expand-collapse-list-header title="Properties" expand-collapse-list-data="expandCollapsePropertiesList"></expand-collapse-list-header> + <div ng-repeat="property in selectedModule.properties | filter: expandCollapsePropertiesList.filter | orderBy:expandCollapsePropertiesList.orderByField track by $index" data-ng-if="expandCollapsePropertiesList.expandCollapse"> + <div class="list-item property-data" data-ng-class="{'last':$last}"> + <div class="property-name module-text-overflow" data-tests-id="selected-module-property-name"> + <span tooltips tooltip-content="{{property.name}}" + data-ng-class="{'hand': !isViewOnly}" + data-ng-click="!isViewOnly && openEditPropertyModal(property)">{{property.name}}</span> + </div> + <div class="module-text-overflow property-info" data-tests-id="selected-module-property-type"> Type: {{property.type}}</div> + <div class="module-text-overflow property-info" data-tests-id="selected-module-property-schema-type">Value: {{property.value}}</div> + </div> + </div> + <expand-collapse-list-header title="Artifacts" expand-collapse-list-data="expandCollapseArtifactsList"></expand-collapse-list-header> + <div ng-repeat="artifact in selectedModule.artifacts| filter: expandCollapseArtifactsList.filter | orderBy:expandCollapseArtifactsList.orderByField track by $index" data-ng-if="expandCollapseArtifactsList.expandCollapse"> + <div class="list-item artifact-data" data-ng-class="{'last':$last}"> + <div class="artifact-name module-text-overflow" data-tests-id="selected-module-artifact-name" tooltips tooltip-content="{{artifact.artifactName}}">{{artifact.artifactName}}</div> + <div class="module-text-overflow" tooltips data-tests-id="selected-module-artifact-uuid" tooltip-content="{{artifact.artifactUUID}}">UUID: {{artifact.artifactUUID}}</div> + <div data-tests-id="selected-module-artifact-version">Version: {{artifact.artifactVersion}}</div> + </div> + </div> + </perfect-scrollbar> + </div> + </div> +</div> diff --git a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy.less b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy.less index 5e8572678d..dee0eeb38b 100644 --- a/catalog-ui/app/scripts/view-models/tabs/hierarchy/hierarchy.less +++ b/catalog-ui/src/app/view-models/tabs/hierarchy/hierarchy.less @@ -1,5 +1,5 @@ .hierarchy-tab{ - + width: 100%; .hierarchy-module-list-container{ padding: 0px 20px 0px 20px; } @@ -23,35 +23,65 @@ .f-color.a; padding: 10px 0px 10px 0px; margin: 0px 20px 0px 20px; - border-bottom: 1px solid rgba(0, 159, 219, 0.6); + //border-bottom: 1px solid rgba(0, 159, 219, 0.6); + + .small-font{ + font-size: 12px; + } + } + + .list-item{ + padding: 10px 0px 10px 0px; + margin: 0px 20px 0px 20px; + &:not(.last){ + border-bottom: 1px solid rgba(0, 159, 219, 0.6); + } } .artifact-data{ .selectable; .f-type._12_r; .f-color.m; - - padding: 10px 0px 10px 0px; - margin: 0px 20px 0px 20px; - border-bottom: 1px solid rgba(0, 159, 219, 0.6); .artifact-name { .f-type._14_r; font-weight: bold; } } + .property-data{ + .property-name{ + width: 100%; + .f-type._14_m; + font-weight: 400; + color: @main_color_a; + } + .property-info{ + color: @func_color_s; + .f-type._14_r; + width: 100%; + } + } + .module-text-overflow { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; - display: inline-block; + //display: inline-block; } } + .hierarchy-modules-list{ + .expand-collapse-title{ + .expand-collapse-title-text{ + max-width: 202px; + } + } + } .hierarchy-module-member-list { overflow: hidden; + background-color: @main_color_p; } .edit-name-container { diff --git a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.html b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.html index 6e478fc471..6e478fc471 100644 --- a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.html +++ b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.html diff --git a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.less b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.less index 71648a4f86..30fa4f7e8b 100644 --- a/catalog-ui/app/scripts/view-models/tutorial-end/tutorial-end.less +++ b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.less @@ -11,7 +11,7 @@ display: flex; align-items: center; - background-image: url('../../../styles/images/welcome.png'); + background-image: url('/assets/styles/images/welcome.png'); background-repeat: no-repeat; background-position: bottom left; diff --git a/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.ts b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.ts new file mode 100644 index 0000000000..1787cd5937 --- /dev/null +++ b/catalog-ui/src/app/view-models/tutorial-end/tutorial-end.ts @@ -0,0 +1,20 @@ +'use strict'; + +interface ITutorialEndViewModelScope extends ng.IScope { +} + +export class TutorialEndViewModel { + + static '$inject' = [ + '$scope' + ]; + + constructor(private $scope:ITutorialEndViewModelScope) { + this.init(); + } + + private init = ():void => { + + } + +} diff --git a/catalog-ui/src/app/view-models/welcome/welcome-view.html b/catalog-ui/src/app/view-models/welcome/welcome-view.html new file mode 100644 index 0000000000..18ca4d51cd --- /dev/null +++ b/catalog-ui/src/app/view-models/welcome/welcome-view.html @@ -0,0 +1,9 @@ +<div class="sdc-welcome-new-page"> + <div data-ng-click="onCloseButtonClick()" class="sdc-welcome-close"></div> + <div class="sdc-welcome-wrapper"> + <div class="sdc-welcome-cover"></div> + <div class="sdc-welcome-main"> + <h1>Welcome to SDC</h1> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/view-models/welcome/welcome-view.ts b/catalog-ui/src/app/view-models/welcome/welcome-view.ts new file mode 100644 index 0000000000..154a70c301 --- /dev/null +++ b/catalog-ui/src/app/view-models/welcome/welcome-view.ts @@ -0,0 +1,57 @@ +'use strict'; + +export interface IWelcomeViewMode { + onCloseButtonClick():void; +} + +export class WelcomeViewModel { + + firstLoad:boolean = true; + alreadyAnimated:Array<number> = []; + + static '$inject' = [ + '$scope', + '$state' + ]; + + constructor(private $scope:IWelcomeViewMode, + private $state:ng.ui.IStateService + ) { + this.init(); + this.initScope(); + window.setTimeout(():void => { + this.loadImages(():void=> { + window.setTimeout(():void =>{ + $(".sdc-welcome-new-page").addClass("animated fadeIn"); + },1000); + }); + },0); + } + + private initScope = ():void => { + this.$scope.onCloseButtonClick = ():void => { + this.$state.go("dashboard", {}); + }; + }; + + private init = ():void => { + let viewModelsHtmlBasePath:string = 'src/app/view-models/'; + $('body').keyup((e):void=> { + if (e.keyCode == 27) { // escape key maps to keycode `27` + this.$state.go('dashboard'); + } + }); + }; + + private loadImages = (callback:Function):void => { + let src = $('.sdc-welcome-wrapper').css('background-image'); + let url = src.match(/\((.*?)\)/)[1].replace(/('|")/g,''); + + let img = new Image(); + img.onload = function() { + callback(); + }; + img.src = url; + }; + +} diff --git a/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view-model.ts b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view-model.ts new file mode 100644 index 0000000000..61a83c88f7 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view-model.ts @@ -0,0 +1,29 @@ +'use strict'; + +export interface IConformanceLevelModalModelScope { + footerButtons:Array<any>; + modalInstance:ng.ui.bootstrap.IModalServiceInstance; +} + +export class ConformanceLevelModalViewModel { + + static '$inject' = ['$scope', '$uibModalInstance']; + + constructor(private $scope:IConformanceLevelModalModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance) { + + this.initScope(); + } + + private initScope = ():void => { + + this.$scope.modalInstance = this.$uibModalInstance; + + this.$scope.footerButtons = [ + {'name': 'Continue', 'css': 'grey', 'callback': this.$uibModalInstance.close}, + {'name': 'Reject', 'css': 'blue', 'callback': this.$uibModalInstance.dismiss} + ]; + + }; + +} diff --git a/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view.html b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view.html new file mode 100644 index 0000000000..3577e4d77b --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal-view.html @@ -0,0 +1,22 @@ +<sdc-modal modal="modalInstance" + type="classic" + class="w-sdc-modal modal-type-alert conformance-level-modal" + header="Warning" + buttons="footerButtons" + show-close-button="false"> + + <perfect-scrollbar include-padding="true"> + <div class="w-sdc-modal-body-content" data-tests-id="message"> + <p> + You are about to distribute a service with models and artifacts created with an <b>older version of the platform</b>. + For such service, new properties, metadata and requirements needed by ECOMP components will not be available. + </p><p> + It is highly recommended that you upgrade the service models and artifacts. + </p><p> + Click "Continue" if you need to distribute the current service version.<br /> + Click "Reject" if you need to stop the distribution and manually upgrade the service. + </p> + </div> + </perfect-scrollbar> + +</sdc-modal> diff --git a/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal.less b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal.less new file mode 100644 index 0000000000..7f195ade83 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/conformance-level-modal/conformance-level-modal.less @@ -0,0 +1,3 @@ +.conformance-level-modal{ + +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.html b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.html index 23c08f6ec6..23c08f6ec6 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.html diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.less b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.less index 61bb3e9f01..61bb3e9f01 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/activity-log/activity-log.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts new file mode 100644 index 0000000000..ed583dc4c0 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/activity-log/activity-log.ts @@ -0,0 +1,103 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {Activity} from "app/models"; +import {ActivityLogService} from "app/services"; + +export interface IActivityLogViewModelScope extends IWorkspaceViewModelScope { + activityDateArray:Array<any>; //this is in order to sort the dates + activityLog:Array<Activity>; + preVersion:string; + + tableHeadersList:Array<any>; + reverse:boolean; + sortBy:string; + searchBind:string; + + getActivityLog(uniqueId:string):void; + onVersionChanged(version:any):void; + parseAction(action:string):string; + sort(sortBy:string):void; +} + +export class ActivityLogViewModel { + + static '$inject' = [ + '$scope', + '$state', + 'Sdc.Services.ActivityLogService' + ]; + + constructor(private $scope:IActivityLogViewModelScope, + private $state:ng.ui.IStateService, + private activityLogService:ActivityLogService) { + + this.initScope(); + this.$scope.setValidState(true); + this.initSortedTableScope(); + this.$scope.updateSelectedMenuItem(); + + // Set default sorting + this.$scope.sortBy = 'logDate'; + } + + private initScope():void { + + this.$scope.preVersion = this.$scope.component.version; + + this.$scope.onVersionChanged = (version:any):void => { + if (version.versionNumber != this.$scope.component.version) { + this.$scope.isLoading = true; + this.$scope.getActivityLog(version.versionId); + } + }; + + this.$scope.getActivityLog = (uniqueId:any):void => { + + let onError = (response) => { + this.$scope.isLoading = false; + console.info('onFaild', response); + + }; + + let onSuccess = (response:Array<Activity>) => { + this.$scope.activityLog = _.sortBy(response, function (o) { + return o.TIMESTAMP; + }); //response; // + this.$scope.isLoading = false; + }; + + this.$scope.isLoading = true; + if (this.$scope.component.isResource()) { + this.activityLogService.getActivityLogService('resources', uniqueId).then(onSuccess, onError); + } + if (this.$scope.component.isService()) { + this.activityLogService.getActivityLogService('services', uniqueId).then(onSuccess, onError); + } + + }; + + if (!this.$scope.activityLog || this.$scope.preVersion != this.$scope.component.version) { + this.$scope.getActivityLog(this.$scope.component.uniqueId); + } + + this.$scope.parseAction = (action:string) => { + return action ? action.split(/(?=[A-Z])/).join(' ') : ''; + }; + + } + + private initSortedTableScope = ():void => { + this.$scope.tableHeadersList = [ + {title: 'Date', property: 'logDate'}, + {title: 'Action', property: 'logAction'}, + {title: 'Comment', property: 'logComment'}, + {title: 'Username', property: 'logUsername'}, + {title: 'Status', property: 'logStatus'} + ]; + + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + }; +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts new file mode 100644 index 0000000000..d8a60444be --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view-model.ts @@ -0,0 +1,80 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {Component, AttributeModel} from "app/models"; +import {ModalsHandler} from "app/utils"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; + +interface IAttributesViewModelScope extends IWorkspaceViewModelScope { + tableHeadersList:Array<any>; + reverse:boolean; + sortBy:string; + + addOrUpdateAttribute(attribute?:AttributeModel):void; + delete(attribute:AttributeModel):void; + sort(sortBy:string):void; +} + +export class AttributesViewModel { + + static '$inject' = [ + '$scope', + '$filter', + '$uibModal', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + + constructor(private $scope:IAttributesViewModelScope, + private $filter:ng.IFilterService, + private $uibModal:ng.ui.bootstrap.IModalService, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2: ComponentServiceNg2) { + + this.initComponentAttributes(); + this.$scope.updateSelectedMenuItem(); + } + + private initComponentAttributes = () => { + if(this.$scope.component.attributes) { + this.initScope(); + } else { + this.ComponentServiceNg2.getComponentAttributes(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.attributes = response.attributes; + this.initScope(); + }); + } + } + + + private initScope = ():void => { + + this.$scope.sortBy = 'name'; + this.$scope.reverse = false; + this.$scope.setValidState(true); + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Type', property: 'type'}, + {title: 'Default Value', property: 'defaultValue'} + ]; + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + this.$scope.addOrUpdateAttribute = (attribute?:AttributeModel):void => { + this.ModalsHandler.openEditAttributeModal(attribute ? attribute : new AttributeModel(), this.$scope.component); + }; + + this.$scope.delete = (attribute:AttributeModel):void => { + + let onOk = ():void => { + this.$scope.component.deleteAttribute(attribute.uniqueId); + }; + let title:string = this.$filter('translate')("ATTRIBUTE_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("ATTRIBUTE_VIEW_DELETE_MODAL_TEXT", "{'name': '" + attribute.name + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes-view.html b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view.html index 59ba933a0a..59ba933a0a 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes-view.html diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes.less b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes.less index ffd28afce4..ffd28afce4 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/attributes/attributes.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/attributes/attributes.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts new file mode 100644 index 0000000000..e2d95280c8 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view-model.ts @@ -0,0 +1,242 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +'use strict'; +import {Component, Product, ComponentInstance, IAppMenu} from "app/models"; +import {SharingService, CacheService, EventListenerService, LeftPaletteLoaderService} from "app/services"; +import {ModalsHandler, GRAPH_EVENTS, ComponentFactory, ChangeLifecycleStateHandler, MenuHandler} from "app/utils"; +import {IWorkspaceViewModelScope} from "../../workspace-view-model"; +import {ComponentServiceNg2} from "app/ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "app/ng2/services/responses/component-generic-response"; + +export interface ICompositionViewModelScope extends IWorkspaceViewModelScope { + + currentComponent:Component; + selectedComponent:Component; + isLoading:boolean; + graphApi:any; + sharingService:SharingService; + sdcMenu:IAppMenu; + version:string; + isViewOnly:boolean; + isLoadingRightPanel:boolean; + onComponentInstanceVersionChange(component:Component); + isComponentInstanceSelected():boolean; + updateSelectedComponent():void + openUpdateModal(); + deleteSelectedComponentInstance():void; + onBackgroundClick():void; + setSelectedInstance(componentInstance:ComponentInstance):void; + printScreen():void; + + cacheComponentsInstancesFullData:Component; +} + +export class CompositionViewModel { + + static '$inject' = [ + '$scope', + '$log', + 'sdcMenu', + 'MenuHandler', + '$uibModal', + '$state', + 'Sdc.Services.SharingService', + '$filter', + 'Sdc.Services.CacheService', + 'ComponentFactory', + 'ChangeLifecycleStateHandler', + 'LeftPaletteLoaderService', + 'ModalsHandler', + 'EventListenerService', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:ICompositionViewModelScope, + private $log:ng.ILogService, + private sdcMenu:IAppMenu, + private MenuHandler:MenuHandler, + private $uibModal:ng.ui.bootstrap.IModalService, + private $state:ng.ui.IStateService, + private sharingService:SharingService, + private $filter:ng.IFilterService, + private cacheService:CacheService, + private ComponentFactory:ComponentFactory, + private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler, + private LeftPaletteLoaderService:LeftPaletteLoaderService, + private ModalsHandler:ModalsHandler, + private eventListenerService:EventListenerService, + private ComponentServiceNg2: ComponentServiceNg2) { + + this.$scope.setValidState(true); + this.initScope(); + this.initGraphData(); + this.$scope.updateSelectedMenuItem(); + this.registerGraphEvents(this.$scope); + } + + + private initGraphData = ():void => { + if(!this.$scope.component.componentInstances || !this.$scope.component.componentInstancesRelations ) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentInstancesAndRelation(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.componentInstances = response.componentInstances; + this.$scope.component.componentInstancesRelations = response.componentInstancesRelations; + this.$scope.isLoading = false; + this.initComponent(); + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_COMPOSITION_GRAPH_DATA_LOADED); + }); + } else { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_COMPOSITION_GRAPH_DATA_LOADED); + } + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_COMPOSITION_GRAPH_DATA_LOADED); + }; + + + private cacheComponentsInstancesFullData:Array<Component>; + + private initComponent = ():void => { + + this.$scope.currentComponent = this.$scope.component; + this.$scope.selectedComponent = this.$scope.currentComponent; + this.updateUuidMap(); + this.$scope.isViewOnly = this.$scope.isViewMode(); + }; + private registerGraphEvents = (scope:ICompositionViewModelScope):void => { + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_NODE_SELECTED, scope.setSelectedInstance); + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, scope.onBackgroundClick); + + }; + + private openUpdateComponentInstanceNameModal = ():void => { + this.ModalsHandler.openUpdateComponentInstanceNameModal(this.$scope.currentComponent).then(()=> { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_COMPONENT_INSTANCE_NAME_CHANGED, this.$scope.currentComponent.selectedInstance); + + }); + }; + + private removeSelectedComponentInstance = ():void => { + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DELETE_MULTIPLE_COMPONENTS); + }; + + private updateUuidMap = ():void => { + /** + * In case user press F5, the page is refreshed and this.sharingService.currentEntity will be undefined, + * but after loadService or loadResource this.sharingService.currentEntity will be defined. + * Need to update the uuidMap with the new resource or service. + */ + this.sharingService.addUuidValue(this.$scope.currentComponent.uniqueId, this.$scope.currentComponent.uuid); + }; + + private initScope = ():void => { + + this.$scope.sharingService = this.sharingService; + this.$scope.sdcMenu = this.sdcMenu; + this.$scope.isLoading = false; + this.$scope.isLoadingRightPanel = false; + this.$scope.graphApi = {}; + this.$scope.version = this.cacheService.get('version'); + this.initComponent(); + + this.cacheComponentsInstancesFullData = new Array<Component>(); + + this.$scope.isComponentInstanceSelected = ():boolean => { + return this.$scope.currentComponent && this.$scope.currentComponent.selectedInstance != undefined && this.$scope.currentComponent.selectedInstance != null; + }; + + this.$scope.updateSelectedComponent = ():void => { + if (this.$scope.currentComponent.selectedInstance) { + + let componentParent = _.find(this.cacheComponentsInstancesFullData, (component) => { + return component.uniqueId === this.$scope.currentComponent.selectedInstance.componentUid; + }); + if (componentParent) { + this.$scope.selectedComponent = componentParent; + } + else { + try { + let onSuccess = (component:Component) => { + this.$scope.isLoadingRightPanel = false; + this.$scope.selectedComponent = component; + this.cacheComponentsInstancesFullData.push(component); + }; + let onError = (component:Component) => { + console.log("Error updating selected component"); + this.$scope.isLoadingRightPanel = false; + }; + this.ComponentFactory.getComponentFromServer(this.$scope.currentComponent.selectedInstance.originType, this.$scope.currentComponent.selectedInstance.componentUid).then(onSuccess, onError); + } catch (e) { + console.log("Error updating selected component", e); + this.$scope.isLoadingRightPanel = false; + } + } + } + else { + + this.$scope.selectedComponent = this.$scope.currentComponent; + } + }; + + this.$scope.setSelectedInstance = (selectedComponent:ComponentInstance):void => { + + this.$log.debug('composition-view-model::onNodeSelected:: with id: ' + selectedComponent.uniqueId); + this.$scope.currentComponent.setSelectedInstance(selectedComponent); + this.$scope.updateSelectedComponent(); + + if (this.$state.current.name === 'workspace.composition.api') { + this.$state.go('workspace.composition.details'); + } + if (this.$state.current.name === 'workspace.composition.relations' && this.$scope.currentComponent.isProduct()) { + this.$state.go('workspace.composition.details'); + } + }; + + this.$scope.onBackgroundClick = ():void => { + this.$scope.currentComponent.selectedInstance = null; + this.$scope.selectedComponent = this.$scope.currentComponent; + + if (this.$state.current.name === 'workspace.composition.api') { + this.$state.go('workspace.composition.details'); + } + }; + + this.$scope.openUpdateModal = ():void => { + this.openUpdateComponentInstanceNameModal(); + }; + + this.$scope.deleteSelectedComponentInstance = ():void => { + let state = "deleteInstance"; + let onOk = ():void => { + this.removeSelectedComponentInstance(); + //this.$scope.graphApi.deleteSelectedNodes(); + }; + let title:string = this.$scope.sdcMenu.alertMessages[state].title; + let message:string = this.$scope.sdcMenu.alertMessages[state].message.format([this.$scope.currentComponent.selectedInstance.name]); + this.ModalsHandler.openAlertModal(title, message).then(onOk); + }; + + this.$scope.onComponentInstanceVersionChange = (component:Product):void => { + this.$scope.currentComponent = component; + this.$scope.setComponent(this.$scope.currentComponent); + this.$scope.updateSelectedComponent(); + } + + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view.html index 4efc74c31b..761ae53909 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition-view.html @@ -1,17 +1,12 @@ <div class="workspace-composition"> <loader data-display="isLoading"></loader> - <div class="w-sdc-designer-canvas" data-ng-class="{sidebaractive: displayDesignerRightSidebar}" > - <palette components="leftPanelComponents" - current-component="currentComponent" + <div class="w-sdc-designer-canvas" data-ng-class="{sidebaractive: displayDesignerRightSidebar}"> + <palette current-component="currentComponent" is-view-only="isViewOnly" is-loading="isLoading"></palette> - <composition-graph component="currentComponent" is-view-only="isViewOnly"></composition-graph> - <!--<graph-creator left-panel-components="leftPanelComponents"--> - <!--data-tests-id="canvas"--> - <!--on-instance-selected="setSelectedInstance(componentInstance)"--> - <!--on-background-click="onBackgroundClick()" current-component="currentComponent"--> - <!--api="graphApi" is-view-only="isViewOnly" is-loading="isLoading"></graph-creator>--> + <composition-graph component="currentComponent" data-tests-id="canvas" + is-view-only="isViewOnly"></composition-graph> </div> <div class="w-sdc-designer-sidebar-toggle" data-ng-class="{'active': displayDesignerRightSidebar}" @@ -50,14 +45,15 @@ <div class="w-sdc-designer-sidebar-tabs"> <button class="i-sdc-designer-sidebar-tab" data-ui-sref-active="active" data-ui-sref="workspace.composition.details" - tooltips tooltip-class="tooltip-custom tab-tooltip" tooltip-content="Information"> + tooltips tooltip-class="tooltip-custom tab-tooltip" tooltip-content="Information" + data-tests-id="information-tab"> <div class="i-sdc-designer-sidebar-tab-icon sprite-new info"></div> </button> - <button class="i-sdc-designer-sidebar-tab" data-ui-sref-active="active" - ui-sref="workspace.composition.structure" - tooltips tooltip-class="tooltip-custom tab-tooltip" tooltip-content="Composition"> - <div class="i-sdc-designer-sidebar-tab-icon sprite-new structure"></div> - </button> + <!--<button class="i-sdc-designer-sidebar-tab" data-ui-sref-active="active"--> + <!--ui-sref="workspace.composition.structure"--> + <!--tooltips tooltip-class="tooltip-custom tab-tooltip" tooltip-content="Composition">--> + <!--<div class="i-sdc-designer-sidebar-tab-icon sprite-new structure"></div>--> + <!--</button>--> <button class="i-sdc-designer-sidebar-tab" data-ui-sref-active="active" data-ui-sref="workspace.composition.deployment" tooltips tooltip-class="tooltip-custom tab-tooltip" tooltip-content="Deployment Artifacts" diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition.less b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition.less index 4c4c0a87a5..501805be3f 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/composition.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/composition.less @@ -1,24 +1,25 @@ .composition{ .sdc-workspace-container{ - .w-sdc-main-container{ - .w-sdc-main-right-container{ - left:0; - .sdc-workspace-top-bar { - padding-left: 295px; - .not-latest{ - left: 270px; - } - } - .w-sdc-main-container-body-content{ - padding: 0 0 0 247px; + .w-sdc-main-container{ + .w-sdc-main-right-container{ + left:0; + //overflow-y: scroll; + .sdc-workspace-top-bar { + padding-left: 295px; + .not-latest{ + left: 270px; } + } + .w-sdc-main-container-body-content{ + padding: 0 0 0 247px; + } - > div:first-child{ - padding: 0; - } + > div:first-child{ + padding: 0; } } + } } } @@ -67,7 +68,7 @@ .w-sdc-designer-sidebar { background-color:@main_color_p ; .noselect; - bottom: 0; + bottom: @footer_height; position: fixed; right: -302px; width: 302px; @@ -146,7 +147,7 @@ height: 36px; padding-top: 9px; text-align: center; - width: 50px; + width: 60px; .hand; &:focus { @@ -156,7 +157,7 @@ /* .disabled; */ } &.active, &:hover:enabled { - background-color: @tlv_color_u; + background-color: @tlv_color_u; .i-sdc-designer-sidebar-tab-icon { opacity: 1; @@ -173,7 +174,7 @@ .i-sdc-designer-sidebar-tab-icon { margin-top: 5px ; - // opacity: .4; + // opacity: .4; } .w-sdc-designer-sidebar-tab-content { @@ -184,8 +185,9 @@ .w-sdc-designer-sidebar-tab-content-view { position: absolute; top: 156px; - bottom: 0px; + bottom: 0; width: 100%; + padding-bottom: 10px; } @@ -395,6 +397,13 @@ margin-top: 65px; } + &.update-env { + background-color: transparent; + border: 0; + right: 15px; + margin-top: 65px; + } + &.attach { background-color: transparent; border: 0; @@ -487,7 +496,7 @@ } .w-scd-diagram-container { - // left: 240px; + // left: 240px; //right: 300px; } @@ -783,10 +792,10 @@ box-shadow: 0px 2px 2px 0px rgba(24, 24, 25, 0.1); width: 91px; -/* &.vl-type-select{ - width: 173px; - } -*/ + /* &.vl-type-select{ + width: 173px; + } + */ h3 { color: @func_color_s; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts new file mode 100644 index 0000000000..0ac5fd0799 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view-model.ts @@ -0,0 +1,301 @@ +'use strict'; +import { + ArtifactModel, + Service, + IAppConfigurtaion, + Resource, + Component, + ComponentInstance, + ArtifactGroupModel, + IFileDownload +} from "app/models"; +import {ICompositionViewModelScope} from "../../composition-view-model"; +import {ArtifactsUtils, ModalsHandler, ArtifactGroupType} from "app/utils"; +import {GRAPH_EVENTS} from "app/utils/constants"; +import {EventListenerService} from "app/services/event-listener-service"; + +export interface IArtifactsViewModelScope extends ICompositionViewModelScope { + artifacts:Array<ArtifactModel>; + artifactType:string; + downloadFile:IFileDownload; + isLoading:boolean; + + getTitle():string; + addOrUpdate(artifact:ArtifactModel):void; + delete(artifact:ArtifactModel):void; + download(artifact:ArtifactModel):void; + openEditEnvParametersModal(artifact:ArtifactModel):void; + getEnvArtifact(heatArtifact:ArtifactModel):any; + getEnvArtifactName(artifact:ArtifactModel):string; + isLicenseArtifact(artifact:ArtifactModel):boolean; + isVFiArtifact(artifact:ArtifactModel):boolean; +} + +export class ResourceArtifactsViewModel { + + static '$inject' = [ + '$scope', + '$filter', + '$state', + 'sdcConfig', + 'ArtifactsUtils', + 'ModalsHandler', + '$q', + 'EventListenerService' + ]; + + constructor(private $scope:IArtifactsViewModelScope, + private $filter:ng.IFilterService, + private $state:any, + private sdcConfig:IAppConfigurtaion, + private artifactsUtils:ArtifactsUtils, + private ModalsHandler:ModalsHandler, + private $q:ng.IQService, + private eventListenerService: EventListenerService) { + + this.initScope(); + } + + + private initArtifactArr = (artifactType:string):void => { + let artifacts:Array<ArtifactModel> = []; + + if (this.$scope.selectedComponent) { + if ('interface' == artifactType) { + let interfaces = this.$scope.currentComponent.interfaces; + if (interfaces && interfaces.standard && interfaces.standard.operations) { + + angular.forEach(interfaces.standard.operations, (operation:any, interfaceName:string):void => { + let item:ArtifactModel = <ArtifactModel>{}; + if (operation.implementation) { + item = <ArtifactModel> operation.implementation; + } + item.artifactDisplayName = interfaceName; + item.artifactLabel = interfaceName; + item.mandatory = false; + artifacts.push(item); + }); + } + } else { + //init normal artifacts, deployment or api artifacts + let artifactsObj:ArtifactGroupModel; + switch (artifactType) { + case "api": + artifactsObj = (<Service>this.$scope.currentComponent).serviceApiArtifacts; + break; + case "deployment": + if (!this.$scope.isComponentInstanceSelected()) { + artifactsObj = this.$scope.currentComponent.deploymentArtifacts; + } else { + artifactsObj = this.$scope.currentComponent.selectedInstance.deploymentArtifacts; + } + break; + default: + //artifactsObj = this.$scope.selectedComponent.artifacts; + if (!this.$scope.isComponentInstanceSelected()) { + artifactsObj = this.$scope.currentComponent.artifacts; + } else { + artifactsObj = this.$scope.currentComponent.selectedInstance.artifacts; + } + break; + } + _.forEach(artifactsObj, (artifact:ArtifactModel, key) => { + artifacts.push(artifact); + }); + } + } + this.$scope.artifacts = artifacts; + }; + + + private convertToArtifactUrl = (artifactType:string):string => { + + switch (artifactType) { + case 'deployment': + return 'DEPLOYMENT'; + case 'api': + return 'SERVICE_API'; + default: + return 'INFORMATIONAL'; + } + + } + + private loadComponentArtifactIfNeeded = (forceLoad?: boolean) => { + + let onGetComponentArtifactsSuccess = (artifacts:ArtifactGroupModel)=> { + switch (this.$scope.artifactType) { + case 'deployment': + this.$scope.currentComponent.deploymentArtifacts = artifacts; + break; + case 'api': + (<Service>this.$scope.currentComponent).serviceApiArtifacts = artifacts; + break; + default: + this.$scope.currentComponent.artifacts = artifacts; + break; + } + this.$scope.isLoading = false; + this.initArtifactArr(this.$scope.artifactType); + } + + let onError = ()=> { + this.$scope.isLoading = false; + }; + + switch (this.$scope.artifactType) { + case 'deployment': + if(forceLoad || !this.$scope.currentComponent.deploymentArtifacts) { + this.$scope.component.getArtifactByGroupType(this.convertToArtifactUrl(this.$scope.artifactType)).then(onGetComponentArtifactsSuccess, onError); + } else { + this.initArtifactArr(this.$scope.artifactType); + } + + break; + case 'api': + if(!(<Service>this.$scope.currentComponent).serviceApiArtifacts) { + this.$scope.component.getArtifactByGroupType(this.convertToArtifactUrl(this.$scope.artifactType)).then(onGetComponentArtifactsSuccess, onError); + } else { + this.initArtifactArr(this.$scope.artifactType); + } + break; + default: + if(!this.$scope.currentComponent.artifacts) { + this.$scope.component.getArtifactByGroupType(this.convertToArtifactUrl(this.$scope.artifactType)).then(onGetComponentArtifactsSuccess, onError); + } else { + this.initArtifactArr(this.$scope.artifactType); + } + break; + } + } + private loadArtifacts = (forceLoad?: boolean):void => { + + let onGetInstanceArtifactsSuccess = (artifacts:ArtifactGroupModel)=> { + switch (this.$scope.artifactType) { + case 'deployment': + this.$scope.currentComponent.selectedInstance.deploymentArtifacts = artifacts; + break; + default: + this.$scope.currentComponent.selectedInstance.artifacts = artifacts; + break; + } + this.loadComponentArtifactIfNeeded(); + }; + + let onError = ()=> { + this.$scope.isLoading = false; + }; + + this.$scope.isLoading = true; + if (this.$scope.isComponentInstanceSelected()) { + this.$scope.component.getComponentInstanceArtifactsByGroupType(this.$scope.component.selectedInstance.uniqueId, this.convertToArtifactUrl(this.$scope.artifactType)).then(onGetInstanceArtifactsSuccess, onError); + } else { + this.loadComponentArtifactIfNeeded(forceLoad); + } + } + + private updateArtifactsIfNeeded = ():void => { + if (this.$scope.artifactType === "deployment") { + this.loadArtifacts(true); + } else { + this.initArtifactArr(this.$scope.artifactType); + } + }; + + private openEditArtifactModal = (artifact:ArtifactModel):void => { + this.ModalsHandler.openArtifactModal(artifact, this.$scope.currentComponent).then(():void => { + this.updateArtifactsIfNeeded(); + }); + }; + + private initScope = ():void => { + + this.$scope.isLoading = false; + this.$scope.artifactType = this.artifactsUtils.getArtifactTypeByState(this.$state.current.name); + this.loadArtifacts(); + this.$scope.getTitle = ():string => { + return this.artifactsUtils.getTitle(this.$scope.artifactType, this.$scope.currentComponent); + }; + + this.$scope.isVFiArtifact = (artifact:ArtifactModel):boolean=> { + if (artifact.artifactGroupType === ArtifactGroupType.INFORMATION) {//fix DE256847 + return this.$scope.currentComponent.artifacts && (!this.$scope.currentComponent.artifacts[artifact.artifactLabel] || !this.$scope.currentComponent.artifacts[artifact.artifactLabel].artifactName); + } + return this.$scope.currentComponent.deploymentArtifacts && (!this.$scope.currentComponent.deploymentArtifacts[artifact.artifactLabel]);//fix DE251314 + }; + + this.$scope.addOrUpdate = (artifact:ArtifactModel):void => { + this.artifactsUtils.setArtifactType(artifact, this.$scope.artifactType); + let artifactCopy = new ArtifactModel(artifact); + this.openEditArtifactModal(artifactCopy); + }; + + + this.$scope.delete = (artifact:ArtifactModel):void => { + + let onOk = ():void => { + this.$scope.isLoading = true; + this.artifactsUtils.removeArtifact(artifact, this.$scope.artifacts); + + let success = (responseArtifact:ArtifactModel):void => { + this.initArtifactArr(this.$scope.artifactType); + this.$scope.isLoading = false; + }; + + let error = (error:any):void => { + console.log('Delete artifact returned error:', error); + this.initArtifactArr(this.$scope.artifactType); + this.$scope.isLoading = false; + }; + if (this.$scope.isComponentInstanceSelected()) { + this.$scope.currentComponent.deleteInstanceArtifact(artifact.uniqueId, artifact.artifactLabel).then(success, error); + } else { + this.$scope.currentComponent.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(success, error);//TODO simulate error (make sure error returns) + } + }; + let title:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + + + this.$scope.getEnvArtifact = (heatArtifact:ArtifactModel):any=> { + return _.find(this.$scope.artifacts, (item:ArtifactModel)=> { + return item.generatedFromId === heatArtifact.uniqueId; + }); + }; + + this.$scope.getEnvArtifactName = (artifact:ArtifactModel):string => { + let envArtifact = this.$scope.getEnvArtifact(artifact); + if (envArtifact) { + return envArtifact.artifactDisplayName; + } + }; + + this.$scope.isLicenseArtifact = (artifact:ArtifactModel):boolean => { + let isLicense:boolean = false; + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { + isLicense = this.artifactsUtils.isLicenseType(artifact.artifactType); + } + + return isLicense; + }; + + this.$scope.openEditEnvParametersModal = (artifact:ArtifactModel):void => { + this.ModalsHandler.openEditEnvParametersModal(artifact, this.$scope.currentComponent).then(()=> { + this.updateArtifactsIfNeeded(); + }, ()=> { + // ERROR + }); + }; + + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_NODE_SELECTED, this.loadArtifacts); + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, this.loadArtifacts); + + this.$scope.$on('$destroy', () => { + + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_NODE_SELECTED, this.loadArtifacts); + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, this.loadArtifacts); + }); + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html index 8c0138964f..b0d81b3437 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts-view.html @@ -6,26 +6,29 @@ <div class="w-sdc-designer-sidebar-section-title-icon"></div> </expand-collapse> - <div class="w-sdc-designer-sidebar-section-content" data-ng-hide="'deployment' == artifactType && !selectedComponent.isComplex()"> + <div class="w-sdc-designer-sidebar-section-content"> <div class="i-sdc-designer-sidebar-section-content-item"> <div class="i-sdc-designer-sidebar-section-content-item-artifact" - data-ng-repeat="artifact in artifacts | orderBy: ['-mandatory', 'artifactDisplayName'] track by $index" data-ng-if="!isComponentInstanceSelected() || (isVFiArtifact(artifact)|| artifact.esId) && 'HEAT_ENV' !== artifact.artifactType"> - <span data-ng-if="isComponentInstanceSelected() && artifact.heatParameters.length" class="i-sdc-designer-sidebar-section-content-item-file-link"></span> + data-ng-repeat="artifact in artifacts | orderBy: ['-mandatory', 'artifactDisplayName'] track by $index" + data-ng-if="(!isComponentInstanceSelected() || isVFiArtifact(artifact)|| artifact.esId) && 'HEAT_ENV' !== artifact.artifactType" + data-tests-id="artifact-item-{{artifact.artifactDisplayName}}"> + <span data-ng-if="artifact.heatParameters.length" class="i-sdc-designer-sidebar-section-content-item-file-link"></span> <div class="i-sdc-designer-sidebar-section-content-item-artifact-details" data-ng-class="{'heat':artifact.isHEAT() && artifact.heatParameters.length}"> - <div class="i-sdc-designer-sidebar-section-content-item-artifact-filename" data-tests-id="artifactName" - data-ng-class="{'hand enabled':!isComponentInstanceSelected() && artifact.heatParameters.length && !isViewMode()}" + <div class="i-sdc-designer-sidebar-section-content-item-artifact-filename" data-tests-id="artifactName-{{artifact.artifactDisplayName}}" data-ng-bind="artifact.artifactName" tooltips tooltip-content="{{artifact.artifactName}}" - data-ng-click="!isViewMode() && !isComponentInstanceSelected() && artifact.heatParameters.length && openEditEnvParametersModal(artifact)" data-ng-if="artifact.artifactName"></div> + data-ng-if="artifact.artifactName"></div> <div> <span class="i-sdc-designer-sidebar-section-content-item-artifact-details-name" data-tests-id="artifact_Display_Name-{{artifact.artifactDisplayName}}" - data-ng-class="{'hand enabled': (!isComponentInstanceSelected()||isVFiArtifact(artifact)) && !isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)}" + data-ng-class="{'hand enabled': (isVFiArtifact(artifact)) && !isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)}" data-ng-bind="artifact.artifactDisplayName" data-ng-click="!isViewMode() && !isLoading && (!isComponentInstanceSelected()||isVFiArtifact(artifact)) && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact) && addOrUpdate(artifact)" tooltips tooltip-content="{{artifact.artifactDisplayName}}"></span> - <div class="i-sdc-designer-sidebar-section-content-item-artifact-heat-env" ng-if="isComponentInstanceSelected() && artifact.heatParameters.length"> - <span class="enabled" data-ng-bind="getEnvArtifactName(artifact)" data-ng-click="!isViewMode() && addOrUpdate(getEnvArtifact(artifact))"></span> - <download-artifact class="i-sdc-designer-sidebar-section-content-item-button download-env sprite e-sdc-small-download hand" artifact="getEnvArtifact(artifact)" - component="currentComponent" instance="true" - data-tests-id="download"></download-artifact> + <div class="i-sdc-designer-sidebar-section-content-item-artifact-heat-env" ng-if="artifact.heatParameters.length"> + <span data-ng-bind="getEnvArtifactName(artifact)"data-tests-id="heat_env_{{artifact.artifactDisplayName}}"></span> + <button class="i-sdc-designer-sidebar-section-content-item-button update-env sprite e-sdc-small-icon-pencil" data-tests-id="edit_{{artifact.artifactDisplayName}}" + data-ng-if="!isViewMode()" data-ng-click="addOrUpdate(getEnvArtifact(artifact))"></button> + <download-artifact class="i-sdc-designer-sidebar-section-content-item-button download-env sprite e-sdc-small-download hand" artifact="getEnvArtifact(artifact)" + component="currentComponent" instance="isComponentInstanceSelected()" + data-tests-id="download_env_{{artifact.artifactDisplayName}}"></download-artifact> </div> </div> @@ -34,14 +37,23 @@ </div> </div> <button ng-if="!isViewMode() && artifact.esId && (!isComponentInstanceSelected()||isVFiArtifact(artifact)) && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)" class="i-sdc-designer-sidebar-section-content-item-button delete sprite e-sdc-small-icon-delete" - data-tests-id="delete" data-ng-click="delete(artifact)" type="button"></button> - <button ng-if="!isViewMode() && isComponentInstanceSelected() && (getEnvArtifact(artifact)).heatParameters.length" + data-tests-id="delete_{{artifact.artifactDisplayName}}" data-ng-click="delete(artifact)" type="button"></button> + <button ng-if="!isViewMode() && artifact.isHEAT() && isComponentInstanceSelected() && artifact.heatParameters.length" class="i-sdc-designer-sidebar-section-content-item-button attach sprite e-sdc-small-icon-pad" - data-ng-click="openEditEnvParametersModal(getEnvArtifact(artifact))" type="button"></button> + data-ng-click="openEditEnvParametersModal(getEnvArtifact(artifact))" type="button" + data-tests-id="edit-parameters-of-{{artifact.artifactDisplayName}}"></button> + <!--need to remove this button --> + <button ng-if="!isViewMode() && artifact.isHEAT() && !isComponentInstanceSelected() && artifact.heatParameters.length" + class="i-sdc-designer-sidebar-section-content-item-button attach sprite e-sdc-small-icon-pad" + data-ng-click="openEditEnvParametersModal(artifact)" type="button" + data-tests-id="edit-parameters-of-{{artifact.artifactDisplayName}}"></button> + <download-artifact ng-if="artifact.esId && 'deployment' != artifactType" class="i-sdc-designer-sidebar-section-content-item-button download sprite e-sdc-small-download hand" - artifact="artifact" component="selectedComponent" data-tests-id="download"></download-artifact> + artifact="artifact" component="currentComponent" data-tests-id="download-{{artifact.artifactDisplayName}}" instance="isComponentInstanceSelected()"></download-artifact> <download-artifact ng-if="artifact.esId && 'deployment' == artifactType" class="i-sdc-designer-sidebar-section-content-item-button download sprite e-sdc-small-download hand" - artifact="artifact" component="currentComponent" instance="isComponentInstanceSelected()" data-tests-id="download"></download-artifact> + artifact="artifact" component="currentComponent" instance="isComponentInstanceSelected()" data-tests-id="download_{{artifact.artifactDisplayName}}" + show-loader="artifact.isHEAT()" + download-icon-class="i-sdc-designer-sidebar-section-content-item-button download sprite e-sdc-small-download hand"></download-artifact> <button ng-if="!isViewMode() && !artifact.esId && artifactType==='deployment' && !isComponentInstanceSelected() && !artifact.isThirdParty()" class="i-sdc-designer-sidebar-section-content-item-button attach sprite e-sdc-small-icon-upload" data-ng-click="addOrUpdate(artifact)" type="button" data-tests-id="add_Artifact"></button> </div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less index 5726ca66fc..7c8b8315d9 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less @@ -99,7 +99,7 @@ position: relative; // line-height: 36px; min-height: 61px; - cursor: default; + //cursor: default; display: flex; align-items: center; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts new file mode 100644 index 0000000000..a81bb9176e --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details-view-model.ts @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +'use strict'; +import {Component} from "app/models"; +import {GRAPH_EVENTS} from "app/utils"; +import {LeftPaletteLoaderService, EventListenerService} from "app/services"; +import {ICompositionViewModelScope} from "../../composition-view-model"; +import {LeftPaletteComponent} from "../../../../../../models/components/displayComponent"; + +export interface IEditResourceVersion { + allVersions:any; + changeVersion:string; +} + +interface IDetailsViewModelScope extends ICompositionViewModelScope { + isLoading:boolean; + $parent:ICompositionViewModelScope; + expandedSection:Array<string>; + editForm:ng.IFormController; + editResourceVersion:IEditResourceVersion; + + changeResourceVersion():void; +} + +export class DetailsViewModel { + + static '$inject' = [ + '$scope', + 'LeftPaletteLoaderService', + 'EventListenerService' + + ]; + + constructor(private $scope:IDetailsViewModelScope, + private LeftPaletteLoaderService:LeftPaletteLoaderService, + private eventListenerService:EventListenerService) { + this.initScope(); + } + + private clearSelectedVersion = ():void => { + this.$scope.editResourceVersion = { + allVersions: {}, + changeVersion: null + }; + }; + + private versioning:Function = (versionNumber:string):string => { + let version:Array<string> = versionNumber.split('.'); + return '00000000'.slice(version[0].length) + version[0] + '.' + '00000000'.slice(version[1].length) + version[1]; + }; + + private initEditResourceVersion = ():void => { + this.clearSelectedVersion(); + this.$scope.editResourceVersion.allVersions[this.$scope.currentComponent.selectedInstance.componentVersion] = this.$scope.currentComponent.selectedInstance.componentUid; + _.merge(this.$scope.editResourceVersion.allVersions, angular.copy(this.$scope.selectedComponent.allVersions)); + let sorted:any = _.sortBy(_.toPairs(this.$scope.editResourceVersion.allVersions), (item)=> { + return this.versioning(item[0]); + }); + this.clearSelectedVersion(); + _.forEach(sorted, (item)=> { + this.$scope.editResourceVersion.allVersions[item[0]] = item[1]; + }); + + let highestVersion = _.last(Object.keys(this.$scope.selectedComponent.allVersions)); + + if (parseFloat(highestVersion) % 1) { //if highest is minor, make sure it is the latest checked in - + let latestVersionComponent:LeftPaletteComponent = _.find(this.LeftPaletteLoaderService.getLeftPanelComponentsForDisplay(this.$scope.currentComponent.componentType), (component:LeftPaletteComponent) => { //latest checked in + return (component.systemName === this.$scope.selectedComponent.systemName + || component.uuid === this.$scope.selectedComponent.uuid); + }); + let latestVersion:string = latestVersionComponent ? latestVersionComponent.version : highestVersion; + + if (highestVersion != latestVersion) { //highest is checked out - remove from options + this.$scope.editResourceVersion.allVersions = _.omit(this.$scope.editResourceVersion.allVersions, highestVersion); + } + } + this.$scope.editResourceVersion.changeVersion = this.$scope.currentComponent.selectedInstance.componentVersion; + }; + + private initScope = ():void => { + this.$scope.isLoading = false; + this.$scope.$parent.isLoading = false; + this.$scope.expandedSection = ['general', 'tags']; + //this.clearSelectedVersion(); + + this.$scope.$watch('selectedComponent', (component:Component) => { + if (this.$scope.isComponentInstanceSelected()) { + this.initEditResourceVersion(); + } + }); + + this.$scope.changeResourceVersion = ():void => { + this.$scope.isLoading = true; + this.$scope.$parent.isLoading = true; + + let onSuccess = (component:Component)=> { + this.$scope.isLoading = false; + this.$scope.$parent.isLoading = false; + this.$scope.onComponentInstanceVersionChange(component); + + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_VERSION_CHANGED, this.$scope.currentComponent); + }; + + let onFailed = (error:any)=> { + this.$scope.isLoading = false; + this.$scope.$parent.isLoading = false; + console.log(error); + }; + + let componentUid:string = this.$scope.editResourceVersion.allVersions[this.$scope.editResourceVersion.changeVersion]; + this.$scope.currentComponent.changeComponentInstanceVersion(componentUid).then(onSuccess, onFailed); + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details-view.html index 6ae462760c..70dc58075a 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details-view.html @@ -26,7 +26,7 @@ data-ng-if="!isComponentInstanceSelected() || selectedComponent.isVl()" data-tests-id="rightTab_version" data-ng-bind="selectedComponent.version"></span> <ng-form name="editForm" data-ng-if="isComponentInstanceSelected() && !selectedComponent.isVl()"> - <select data-ng-model="editResourceVersion.changeVersion" name="changeVersion" data-ng-disabled="$parent.isViewOnly" + <select data-ng-model="editResourceVersion.changeVersion" name="changeVersion" data-tests-id="changeVersion" data-ng-disabled="$parent.isViewOnly" class="i-sdc-designer-sidebar-section-content-item-value i-sdc-form-select" data-ng-class="{'minor': (editResourceVersion.changeVersion)%1}" data-ng-change="changeResourceVersion()"> @@ -80,7 +80,12 @@ <div class="i-sdc-designer-sidebar-section-content-item"> <span class="i-sdc-designer-sidebar-section-content-item-label" translate="GENERAL_LABEL_CONTACT_ID"></span> <span class="i-sdc-designer-sidebar-section-content-item-value" data-ng-bind="selectedComponent.contactId" - data-tests-id="rightTab_userId"></span> + data-tests-id="rightTab_contactId"></span> + </div> + <div class="i-sdc-designer-sidebar-section-content-item" data-ng-if="isViewMode() && currentComponent.isService() && selectedComponent.isResource()"> + <span class="i-sdc-designer-sidebar-section-content-item-label">Resource Customization UUID:</span><br> + <span class="customization-uuid selectable" data-ng-bind="currentComponent.selectedInstance.customizationUUID" + data-tests-id="rightTab_customizationModuleUUID"></span><br> </div> <div class="i-sdc-designer-sidebar-section-content-item description"> <span class="i-sdc-designer-sidebar-section-content-item-label">Description: @@ -118,6 +123,8 @@ <div class="w-sdc-designer-sidebar-section-content tags"> <div class="i-sdc-designer-sidebar-section-content-item"> + <span class="i-sdc-designer-sidebar-section-content-item-tag" data-ng-if="selectedComponent.tags.indexOf(selectedComponent.name)===-1" data-ng-bind="selectedComponent.name" + data-tests-id="rightTab_tag" tooltips tooltip-content="{{selectedComponent.name}}"></span> <span class="i-sdc-designer-sidebar-section-content-item-tag" data-ng-repeat="tag in selectedComponent.tags track by $index" data-ng-bind="tag" data-tests-id="rightTab_tag" tooltips tooltip-content="{{tag}}"></span> </div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details.less b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details.less index e88e130379..841ab3aa49 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/details/details.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/details/details.less @@ -59,6 +59,10 @@ font-weight: normal; } + .customization-uuid{ + .f-type._12_m; + } + .w-sdc-designer-sidebar-section.tags { .i-sdc-designer-sidebar-section-content-item { white-space: normal; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts new file mode 100644 index 0000000000..84769d7a62 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view-model.ts @@ -0,0 +1,217 @@ +'use strict'; +import { + AttributeModel, + AttributesGroup, + Component, + ComponentInstance, + PropertyModel, + PropertiesGroup +} from "app/models"; +import {ICompositionViewModelScope} from "../../composition-view-model"; +import {ModalsHandler} from "app/utils"; +import {ComponentServiceNg2} from "app/ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "app/ng2/services/responses/component-generic-response"; + +interface IResourcePropertiesAndAttributesViewModelScope extends ICompositionViewModelScope { + properties:PropertiesGroup; + attributes:AttributesGroup; + propertiesMessage:string; + groupPropertiesByInstance:boolean; + showGroupsOfInstanceProperties:Array<boolean>; + addProperty():void; + updateProperty(property:PropertyModel):void; + deleteProperty(property:PropertyModel):void; + viewAttribute(attribute:AttributeModel):void; + groupNameByKey(key:string):string; + isPropertyOwner():boolean; + getComponentInstanceNameFromInstanceByKey(key:string):string; +} + +export class ResourcePropertiesViewModel { + + static '$inject' = [ + '$scope', + '$filter', + '$uibModal', + 'ModalsHandler', + 'ComponentServiceNg2' + + ]; + + + constructor(private $scope:IResourcePropertiesAndAttributesViewModelScope, + private $filter:ng.IFilterService, + private $uibModal:ng.ui.bootstrap.IModalService, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2:ComponentServiceNg2) { + + this.getComponentInstancesPropertiesAndAttributes(); + } + + private initComponentProperties = ():void => { + let result:PropertiesGroup = {}; + + if (this.$scope.selectedComponent) { + this.$scope.propertiesMessage = undefined; + this.$scope.groupPropertiesByInstance = false; + if (this.$scope.isComponentInstanceSelected()) { + if (this.$scope.currentComponent.selectedInstance.originType === 'VF') { + this.$scope.groupPropertiesByInstance = true; + } + result[this.$scope.currentComponent.selectedInstance.uniqueId] = this.$scope.currentComponent.componentInstancesProperties[this.$scope.currentComponent.selectedInstance.uniqueId]; + } else if (this.$scope.currentComponent.isService()) { + // Temporally fix to hide properties for service (UI stack when there are many properties) + result = this.$scope.currentComponent.componentInstancesProperties; + this.$scope.propertiesMessage = "Note: properties for service are disabled"; + } else { + let key = this.$scope.selectedComponent.uniqueId; + result[key] = Array<PropertyModel>(); + let derived = Array<PropertyModel>(); + _.forEach(this.$scope.selectedComponent.properties, (property:PropertyModel) => { + if (key == property.parentUniqueId) { + result[key].push(property); + } else { + property.readonly = true; + derived.push(property); + } + }); + if (derived.length) { + result['derived'] = derived; + } + } + this.$scope.properties = result; + } + }; + + + private initComponentAttributes = ():void => { + let result:AttributesGroup = {}; + + if (this.$scope.selectedComponent) { + if (this.$scope.isComponentInstanceSelected()) { + result[this.$scope.currentComponent.selectedInstance.uniqueId] = this.$scope.currentComponent.componentInstancesAttributes[this.$scope.currentComponent.selectedInstance.uniqueId]; + } else if (this.$scope.currentComponent.isService()) { + result = this.$scope.currentComponent.componentInstancesAttributes; + } + this.$scope.attributes = result; + } + }; + + /** + * This function is checking if the component is the value owner of the current property + * in order to notify the edit property modal which fields to disable + */ + private isPropertyValueOwner = ():boolean => { + return this.$scope.currentComponent.isService() || !!this.$scope.currentComponent.selectedInstance; + }; + + /** + * The function opens the edit property modal. + * It checks if the property is from the VF or from one of it's resource instances and sends the needed property list. + * For create property reasons an empty array is transferd + * + * @param property the wanted property to edit/create + */ + private openEditPropertyModal = (property:PropertyModel):void => { + this.ModalsHandler.openEditPropertyModal(property, + this.$scope.component, + (this.$scope.isPropertyOwner() ? + this.$scope.properties[property.parentUniqueId] : + this.$scope.properties[property.resourceInstanceUniqueId]) || [], + this.isPropertyValueOwner()).then(() => { + }); + }; + + private openAttributeModal = (atrribute:AttributeModel):void => { + + let modalOptions:ng.ui.bootstrap.IModalSettings = { + template: 'app/view-models/forms/attribute-form/attribute-form-view.html', + controller: 'Sdc.ViewModels.AttributeFormViewModel', + size: 'sdc-md', + backdrop: 'static', + keyboard: false, + resolve: { + attribute: ():AttributeModel => { + return atrribute; + }, + component: ():Component => { + return this.$scope.currentComponent; + } + } + }; + this.$uibModal.open(modalOptions); + }; + + private getComponentInstancesPropertiesAndAttributes = () => { + + this.ComponentServiceNg2.getComponentInstanceAttributesAndProperties(this.$scope.currentComponent).subscribe((genericResponse:ComponentGenericResponse) => { + this.$scope.currentComponent.componentInstancesAttributes = genericResponse.componentInstancesAttributes; + this.$scope.currentComponent.componentInstancesProperties = genericResponse.componentInstancesProperties; + this.initScope(); + }); + }; + + private initScope = ():void => { + + + this.initComponentProperties(); + this.initComponentAttributes(); + + this.$scope.$watchCollection('currentComponent.properties', (newData:any):void => { + this.initComponentProperties(); + }); + + this.$scope.$watch('currentComponent.selectedInstance', (newInstance:ComponentInstance):void => { + if (angular.isDefined(newInstance)) { + this.initComponentProperties(); + this.initComponentAttributes(); + + } + }); + + this.$scope.isPropertyOwner = ():boolean => { + return this.$scope.currentComponent && this.$scope.currentComponent.isResource() && !this.$scope.isComponentInstanceSelected(); + }; + + this.$scope.updateProperty = (property:PropertyModel):void => { + this.openEditPropertyModal(property); + }; + + this.$scope.deleteProperty = (property:PropertyModel):void => { + + let onOk = ():void => { + this.$scope.currentComponent.deleteProperty(property.uniqueId); + }; + + let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + + this.$scope.viewAttribute = (attribute:AttributeModel):void => { + this.openAttributeModal(attribute); + }; + + this.$scope.groupNameByKey = (key:string):string => { + switch (key) { + case 'derived': + return "Derived"; + + case this.$scope.currentComponent.uniqueId: + return this.$filter("resourceName")(this.$scope.currentComponent.name); + + default: + return this.$filter("resourceName")((_.find(this.$scope.currentComponent.componentInstances, {uniqueId: key})).name); + } + }; + + this.$scope.getComponentInstanceNameFromInstanceByKey = (key:string):string => { + let instanceName:string = ""; + if (key !== undefined && this.$scope.selectedComponent.uniqueId == this.$scope.currentComponent.selectedInstance.componentUid) { + instanceName = this.$filter("resourceName")((_.find(this.$scope.selectedComponent.componentInstances, {uniqueId: key})).name); + } + return instanceName; + }; + + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html index 3022ee6e90..6df8b6a4d6 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties-view.html @@ -1,4 +1,5 @@ -<perfect-scrollbar class="w-sdc-designer-sidebar-tab-content properties"> +<perfect-scrollbar class="w-sdc-designer-sidebar-tab-content properties" id="main-scroll"> + <div class="w-sdc-designer-sidebar-section"> <!--expand-collapse data-ng-if="isPropertyOwner() && !currentComponent.properties.length" expanded-selector=".w-sdc-composition-sidebar-section-content.{{currentComponent.name}}" @@ -7,52 +8,87 @@ data-ng-bind="(currentComponent.name | resourceName)+ ' Properties'"></span> <div class="w-sdc-composition-sidebar-section-title-icon"></div> </expand-collapse--> - - <!--properties--> <expand-collapse data-ng-repeat-start="(key, group) in properties" - expanded-selector=".w-sdc-designer-sidebar-section-content.properties.{{$index}}" class="w-sdc-designer-sidebar-section-title"> - <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="groupNameByKey(key) + ' Properties'" - tooltips tooltip-content="{{groupNameByKey(key)}} Properties"></span> - <div class="w-sdc-designer-sidebar-section-title-icon"></div> + expanded-selector=".w-sdc-designer-sidebar-section-content.properties.{{$index}}"> + <div class="first-level"> + <div class="expand-collapse-title-icon"></div> + <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="groupNameByKey(key) + ' Properties'" + tooltips tooltip-content="{{groupNameByKey(key)}} Properties" + data-tests-id="vfi-properties"></span> + </div> </expand-collapse> <div data-ng-repeat-end="" class="w-sdc-designer-sidebar-section-content properties {{$index}}"> <!--data-ng-show="isShowDetailsSection" --> - <div class="i-sdc-designer-sidebar-section-content-item"> + <div class="i-sdc-designer-sidebar-section-content-item" data-ng-if="!groupPropertiesByInstance"> <div class="i-sdc-designer-sidebar-section-content-item-property-and-attribute" data-tests-id="propertyRow" data-ng-repeat="property in group | orderBy: 'name' track by $index"> <div> <span class="i-sdc-designer-sidebar-section-content-item-property-and-attribute-label" data-ng-class="{'hand enabled': !$parent.isViewOnly}" tooltips tooltip-content="{{property.name}}" - data-ng-click="!$parent.isViewOnly && updateProperty(property)">{{property.name}}</span> + data-ng-click="!$parent.isViewOnly && updateProperty(property)" + data-tests-id="{{property.name}}">{{property.name}}</span> </div> <div> <span class="i-sdc-designer-sidebar-section-content-item-property-value" data-ng-if="isPropertyOwner()" tooltips tooltip-content="{{property.defaultValue}}">{{property.defaultValue}}</span> <span class="i-sdc-designer-sidebar-section-content-item-property-value" data-ng-if="!isPropertyOwner()" - tooltips tooltip-content="{{property.value}}">{{property.value}}</span> + tooltips tooltip-content="{{property.value}}" + data-tests-id="value_{{property.name}}">{{property.value}}</span> </div> <button class="i-sdc-designer-sidebar-section-content-item-button delete sprite e-sdc-small-icon-delete" data-ng-if="!$parent.isViewOnly&&(isPropertyOwner() && !property.readonly)" data-ng-click="deleteProperty(property)" type="button"></button> </div> </div> - - </div> - <div class="w-sdc-designer-sidebar-section-footer"> - <button class="w-sdc-designer-sidebar-section-footer-action tlv-btn blue" data-ng-click="addProperty()" type="button" data-ng-if="!$parent.isViewOnly && isPropertyOwner()"> - Add Property - </button> + <div class="i-sdc-designer-sidebar-section-content-item" data-ng-if="groupPropertiesByInstance"> + <div data-ng-repeat-start="(instancesIds , InstanceProperties) in (group | groupBy:'path')" + class="vfci-properties-group" + data-ng-click="showGroupsOfInstanceProperties[$index]=!showGroupsOfInstanceProperties[$index]" + data-ng-class="{'expanded':showGroupsOfInstanceProperties[$index]}"> + <div class="second-level"> + <div class="expand-collapse-title-icon"></div> + <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="getComponentInstanceNameFromInstanceByKey(InstanceProperties[0].path[1]) + ' Properties'" + tooltips tooltip-content="{{getComponentInstanceNameFromInstanceByKey(InstanceProperties[0].path[1])}} Properties" + data-tests-id="vfci-properties"></span> + </div> + </div> + <div data-ng-repeat-end="" class="w-sdc-designer-sidebar-section-content instance-properties {{$index}}" data-ng-if="showGroupsOfInstanceProperties[$index]"> + <div class="i-sdc-designer-sidebar-section-content-item"> + <div class="i-sdc-designer-sidebar-section-content-item-property-and-attribute" data-tests-id="propertyRow" + data-ng-repeat="instanceProperty in InstanceProperties | orderBy: 'name'"> + <div> + <span class="i-sdc-designer-sidebar-section-content-item-property-and-attribute-label" + data-ng-class="{'hand enabled': !$parent.isViewOnly}" + tooltips tooltip-content="{{instanceProperty.name}}" + data-tests-id="vfci-property">{{instanceProperty.name}}</span> + </div> + <div> + <span class="i-sdc-designer-sidebar-section-content-item-property-value" + tooltips tooltip-content="{{instanceProperty.value === undefined ? instanceProperty.defaultValue : instanceProperty.value}}"> + {{instanceProperty.value === undefined ? instanceProperty.defaultValue : instanceProperty.value}}</span> + </div> + </div> + </div> + </div> + </div> + <!--<div class="w-sdc-designer-sidebar-section-footer" data-ng-if="(!$parent.isViewOnly && isPropertyOwner()) || showAddPropertyButton">--> + <!--<button class="w-sdc-designer-sidebar-section-footer-action tlv-btn blue" data-tests-id="addGrey" data-ng-click="addProperty()" type="button">--> + <!--Add Property--> + <!--</button>--> + <!--</div>--> </div> <!--attributes--> <expand-collapse data-ng-repeat-start="(key, group) in attributes" - expanded-selector=".w-sdc-designer-sidebar-section-content.attributes.{{$index}}" class="w-sdc-designer-sidebar-section-title"> - <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="groupNameByKey(key) + ' Attributes'" - tooltips tooltip-content="{{groupNameByKey(key)}} Attributes"></span> - <div class="w-sdc-designer-sidebar-section-title-icon"></div> + expanded-selector=".w-sdc-designer-sidebar-section-content.attributes.{{$index}}"> + <div class="first-level"> + <div class="expand-collapse-title-icon"></div> + <span class="w-sdc-designer-sidebar-section-title-text" data-ng-bind="groupNameByKey(key) + ' Attributes'" + tooltips tooltip-content="{{groupNameByKey(key)}} Attributes"></span> + </div> </expand-collapse> <div data-ng-repeat-end="" class="w-sdc-designer-sidebar-section-content attributes {{$index}}"> <!--data-ng-show="isShowDetailsSection" --> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less index 2ad87b9fca..41a90bff9d 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less @@ -13,4 +13,26 @@ .s_14_m; padding: 20px 20px; } + + .vfci-properties-group{ + background-color: @func_color_r; + } + + .expand-collapse-title-icon{ + .hand; + .sprite-new; + .expand-collapse-plus-icon; + vertical-align: middle; + margin: 0 6px; + } + + .expanded { + .expand-collapse-title-icon { + .expand-collapse-minus-icon; + } + } + + .w-sdc-designer-sidebar-section-title-text{ + vertical-align: middle; + } } diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts new file mode 100644 index 0000000000..325f250ebe --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view-model.ts @@ -0,0 +1,156 @@ +'use strict'; +import {ICompositionViewModelScope} from "../../composition-view-model"; +import {CapabilitiesGroup, Requirement, RequirementsGroup} from "app/models"; +import {ComponentServiceNg2} from "app/ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "app/ng2/services/responses/component-generic-response"; +import {GRAPH_EVENTS} from "app/utils"; +import {EventListenerService} from "app/services"; +import {ComponentInstance, Capability} from "app/models"; + +interface IRelationsViewModelScope extends ICompositionViewModelScope { + isLoading:boolean; + $parent:ICompositionViewModelScope; + getRelation(requirement:any):any; + capabilities:Array<Capability>; + requirements:Array<Requirement>; + + //for complex components + capabilitiesInstancesMap:InstanceCapabilitiesMap; + requirementsInstancesMap:InstanceRequirementsMap; +} +export class InstanceCapabilitiesMap { + [key:string]:Array<Capability>; +} + +export class InstanceRequirementsMap { + [key:string]:Array<Requirement>; +} + +export class RelationsViewModel { + + static '$inject' = [ + '$scope', + '$filter', + 'ComponentServiceNg2', + 'EventListenerService' + ]; + + constructor(private $scope:IRelationsViewModelScope, + private $filter:ng.IFilterService, + private ComponentServiceNg2:ComponentServiceNg2, + private eventListenerService:EventListenerService) { + this.initScope(); + } + + private loadComplexComponentData = () => { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getCapabilitiesAndRequirements(this.$scope.currentComponent.componentType, this.$scope.currentComponent.uniqueId).subscribe((response:ComponentGenericResponse) => { + this.$scope.currentComponent.capabilities = response.capabilities; + this.$scope.currentComponent.requirements = response.requirements; + this.setScopeCapabilitiesRequirements(this.$scope.currentComponent.capabilities, this.$scope.currentComponent.requirements); + this.initInstancesMap(); + this.$scope.isLoading = false; + }); + } + + + private extractValuesFromMap = (map:CapabilitiesGroup | RequirementsGroup):Array<any> => { + let values = []; + _.forEach(map, (capabilitiesOrRequirements:Array<Capability> | Array<Requirement>, key) => { + values = values.concat(capabilitiesOrRequirements) + } + ); + return values; + } + + private setScopeCapabilitiesRequirements = (capabilities:CapabilitiesGroup, requirements:RequirementsGroup) => { + this.$scope.capabilities = this.extractValuesFromMap(capabilities); + this.$scope.requirements = this.extractValuesFromMap(requirements); + } + + + private initInstancesMap = ():void => { + + this.$scope.capabilitiesInstancesMap = new InstanceCapabilitiesMap(); + _.forEach(this.$scope.capabilities, (capability:Capability) => { + if (this.$scope.capabilitiesInstancesMap[capability.ownerName]) { + this.$scope.capabilitiesInstancesMap[capability.ownerName] = this.$scope.capabilitiesInstancesMap[capability.ownerName].concat(capability); + } else { + this.$scope.capabilitiesInstancesMap[capability.ownerName] = new Array<Capability>(capability); + } + }); + + this.$scope.requirementsInstancesMap = new InstanceRequirementsMap(); + _.forEach(this.$scope.requirements, (requirement:Requirement) => { + if (this.$scope.requirementsInstancesMap[requirement.ownerName]) { + this.$scope.requirementsInstancesMap[requirement.ownerName] = this.$scope.requirementsInstancesMap[requirement.ownerName].concat(requirement); + } else { + this.$scope.requirementsInstancesMap[requirement.ownerName] = new Array<Requirement>(requirement); + } + }); + } + + private initRequirementsAndCapabilities = (needUpdate?: boolean) => { + + // if instance selected, we take the requirement and capabilities of the instance - always exist because we load them with the graph + if (this.$scope.isComponentInstanceSelected()) { + this.$scope.isLoading = false; + this.setScopeCapabilitiesRequirements(this.$scope.currentComponent.selectedInstance.capabilities, this.$scope.currentComponent.selectedInstance.requirements); + if (this.$scope.currentComponent.selectedInstance.originType === 'VF') { + this.initInstancesMap(); + } + } else { + // if instance not selected, we take the requirement and capabilities of the VF/SERVICE, if not exist we call api + if (needUpdate || !this.$scope.currentComponent.capabilities || !this.$scope.currentComponent.requirements) { + this.loadComplexComponentData(); + + } else { + this.$scope.isLoading = false; + this.setScopeCapabilitiesRequirements(this.$scope.currentComponent.capabilities, this.$scope.currentComponent.requirements); + this.initInstancesMap(); + } + } + } + + private updateRequirementCapabilities = () => { + if (!this.$scope.isComponentInstanceSelected()) { + this.loadComplexComponentData(); + } + } + + private initEvents = ():void => { + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_NODE_SELECTED, this.initRequirementsAndCapabilities); + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, this.updateRequirementCapabilities); + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_CREATE_COMPONENT_INSTANCE, this.updateRequirementCapabilities); + this.eventListenerService.registerObserverCallback(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, this.updateRequirementCapabilities); + } + + private initScope = ():void => { + + this.$scope.requirements = []; + this.$scope.capabilities = []; + + this.initEvents(); + this.initRequirementsAndCapabilities(); + + this.$scope.isCurrentDisplayComponentIsComplex = ():boolean => { + if (this.$scope.isComponentInstanceSelected()) { + if (this.$scope.currentComponent.selectedInstance.originType === 'VF') { + return true; + } + return false; + } else { + return this.$scope.currentComponent.isComplex(); + } + } + + this.$scope.$on('$destroy', () => { + + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_NODE_SELECTED, this.initRequirementsAndCapabilities); + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_GRAPH_BACKGROUND_CLICKED, this.updateRequirementCapabilities); + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_CREATE_COMPONENT_INSTANCE, this.updateRequirementCapabilities); + this.eventListenerService.unRegisterObserver(GRAPH_EVENTS.ON_DELETE_COMPONENT_INSTANCE, this.updateRequirementCapabilities); + }); + + } +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view.html new file mode 100644 index 0000000000..5ecb12cd6f --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations-view.html @@ -0,0 +1,61 @@ +<perfect-scrollbar class="w-sdc-designer-sidebar-tab-content sdc-general-tab relations"> + <div ng-if="!isCurrentDisplayComponentIsComplex()"> + <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> + <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.capabilities" class="w-sdc-designer-sidebar-section-title"> Capabilities + <div class="w-sdc-designer-sidebar-section-title-icon"></div> + </expand-collapse> + <div class="w-sdc-designer-sidebar-section-content capabilities"> + <capabilities-list capabilities="capabilities"></capabilities-list> + </div> + </div> + <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> + <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.requirements" class="w-sdc-designer-sidebar-section-title"> Requirements + <div class="w-sdc-designer-sidebar-section-title-icon"></div> + </expand-collapse> + + <div class="w-sdc-designer-sidebar-section-content requirements"> + <requirements-list component='currentComponent' requirements="requirements"></requirements-list> + </div> + </div> + </div> + + <div ng-if="isCurrentDisplayComponentIsComplex()"> + <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> + <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.capabilities" class="w-sdc-designer-sidebar-section-title"> Capabilities + <div class="w-sdc-designer-sidebar-section-title-icon"></div> + </expand-collapse> + </div> + <div class="w-sdc-designer-sidebar-section-content capabilities"> + <expand-collapse expanded-selector=".capabilities-component-instances.{{$index}}" is-close-on-init="true" class="general-tab-expand-collapse" + data-ng-repeat-start="(key, instanceCapabilities) in capabilitiesInstancesMap track by $index"> + <div class="expand-collapse-title second-level"> + <div class="expand-collapse-title-icon"></div> + <span class="expand-collapse-title-text" data-ng-bind="key"></span> + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="capabilities-component-instances {{$index}}"> + <capabilities-list capabilities="instanceCapabilities"></capabilities-list> + </div> + </div> + + <div class="w-sdc-designer-sidebar-section w-sdc-designer-sidebar-section-relations"> + <expand-collapse expanded-selector=".w-sdc-designer-sidebar-section-content.requirements" class="w-sdc-designer-sidebar-section-title"> Requirements + <div class="w-sdc-designer-sidebar-section-title-icon"></div> + </expand-collapse> + </div> + <div class="w-sdc-designer-sidebar-section-content requirements"> + <expand-collapse expanded-selector=".requirements-component-instances.{{$index}}" is-close-on-init="true" class="general-tab-expand-collapse" + data-ng-repeat-start="(key, instanceRequirements) in requirementsInstancesMap track by $index"> + <div class="expand-collapse-title second-level"> + <div class="expand-collapse-title-icon"></div> + <span class="expand-collapse-title-text" data-ng-bind="key"></span> + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="requirements-component-instances {{$index}}"> + <requirements-list component='currentComponent' requirements="instanceRequirements"></requirements-list> + </div> + </div> + </div> +</perfect-scrollbar> diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations.less b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations.less new file mode 100644 index 0000000000..c3b224d5a6 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/relations/relations.less @@ -0,0 +1,14 @@ +.w-sdc-designer-sidebar-tab-content.relations { + + .w-sdc-designer-sidebar-section-content { + padding: 0; + } + + .w-sdc-designer-sidebar-section-title { + &.expanded { + margin-bottom: 0; + } + } +} + + diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.html b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/structure/structure-view.html index 2070041990..2070041990 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/composition/tabs/structure/structure-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/structure/structure-view.html diff --git a/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts new file mode 100644 index 0000000000..1c28a46d37 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/composition/tabs/structure/structure-view.ts @@ -0,0 +1,14 @@ +'use strict'; +import {ICompositionViewModelScope} from "../../composition-view-model"; + +interface IStructureViewModel extends ICompositionViewModelScope { +} + +export class StructureViewModel { + static '$inject' = [ + '$scope' + ]; + + constructor(private $scope:IStructureViewModel) { + } +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-description-popover.html b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-description-popover.html new file mode 100644 index 0000000000..0d7d5dc8f4 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-description-popover.html @@ -0,0 +1,23 @@ +<!-- Description Popover --> +<div > + <span data-tests-id='popover-x-button' data-ng-click='closeDescriptionPopover()' class='tlv-sprite tlv-x-btn close-popover-btn'></span> + <div class="w-sdc-form-item" ng-form="descriptionForm" data-ng-class="{error:(descriptionForm.$dirty && descriptionForm.$invalid)}"> + <textarea class="i-sdc-form-textarea {{$index}}" data-ng-class="{'view-mode': isViewMode()}" + data-ng-maxlength="256" + maxlength="256" + data-ng-required="true" + name="description" + data-ng-model="artifact.description" + data-ng-model-options="{ debounce: 200 }" + data-ng-pattern="getValidationPattern('string')" + ng-readonly="isViewMode()" + data-tests-id="description"> + </textarea> + + <div class="input-error" data-ng-show="descriptionForm.$dirty && descriptionForm.$invalid"> + <span ng-show="descriptionForm.$error.required" translate="ADD_ARTIFACT_ERROR_DESCRIPTION_REQUIRED"></span> + <span ng-show="descriptionForm.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span> + <span ng-show="descriptionForm.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + </div> + </div> +</div> diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts new file mode 100644 index 0000000000..2816c312f9 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts @@ -0,0 +1,276 @@ +//@require "./*.html" +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ArtifactModel, ArtifactGroupModel, Resource} from "app/models"; +import {ArtifactsUtils, ModalsHandler, ValidationUtils} from "app/utils"; +import {ComponentServiceNg2} from "app/ng2/services/component-services/component.service"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; + +interface IDeploymentArtifactsViewModelScope extends IWorkspaceViewModelScope { + tableHeadersList:Array<any>; + reverse:boolean; + sortBy:string; + artifacts:Array<ArtifactModel>; + editForm:ng.IFormController; + isLoading:boolean; + artifactDescriptions:any; + selectedArtifactId:string; + popoverTemplate:string; + + addOrUpdate(artifact:ArtifactModel):void; + updateSelectedArtifact():void; + delete(artifact:ArtifactModel):void; + sort(sortBy:string):void; + noArtifactsToShow():boolean; + getValidationPattern(validationType:string, parameterType?:string):RegExp; + validateJson(json:string):boolean; + resetValue(parameter:any):void; + viewModeOrCsarComponent():boolean; + isLicenseArtifact(artifact:ArtifactModel):void; + getEnvArtifact(heatArtifact:ArtifactModel):ArtifactModel; + getEnvArtifactName(artifact:ArtifactModel):string; + openEditEnvParametersModal(artifact:ArtifactModel):void; + openDescriptionPopover(artifactId:string):void; + closeDescriptionPopover():void; +} + +export class DeploymentArtifactsViewModel { + + static '$inject' = [ + '$scope', + '$templateCache', + '$filter', + 'ValidationUtils', + 'ArtifactsUtils', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:IDeploymentArtifactsViewModelScope, + private $templateCache:ng.ITemplateCacheService, + private $filter:ng.IFilterService, + private validationUtils:ValidationUtils, + private artifactsUtils:ArtifactsUtils, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2: ComponentServiceNg2) { + this.initScope(); + this.$scope.updateSelectedMenuItem(); + } + + private initDescriptions = ():void => { + this.$scope.artifactDescriptions = {}; + _.forEach(this.$scope.component.deploymentArtifacts, (artifact:ArtifactModel):void => { + this.$scope.artifactDescriptions[artifact.artifactLabel] = artifact.description; + }); + }; + + private setArtifact = (artifact:ArtifactModel):void => { + if (!artifact.description || !this.$scope.getValidationPattern('string').test(artifact.description)) { + artifact.description = this.$scope.artifactDescriptions[artifact.artifactLabel]; + } + }; + + private initScopeArtifacts = ()=> { + this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.deploymentArtifacts); + _.forEach(this.$scope.artifacts, (artifact:ArtifactModel):void => { + artifact.envArtifact = this.getEnvArtifact(artifact); + }); + }; + + private initArtifacts = (loadFromServer:boolean):void => { + if (loadFromServer) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentDeploymentArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.deploymentArtifacts = response.deploymentArtifacts; + this.initScopeArtifacts(); + this.$scope.isLoading = false; + }); + } else { + this.initScopeArtifacts(); + } + + }; + + private getEnvArtifact = (heatArtifact:ArtifactModel):ArtifactModel=> { + return _.find(this.$scope.artifacts, (item:ArtifactModel)=> { + return item.generatedFromId === heatArtifact.uniqueId; + }); + }; + + private getCurrentArtifact = ():ArtifactModel => { + if (!this.$scope.selectedArtifactId) { + return null; + } + let artifact:ArtifactModel = this.$scope.artifacts.filter((art) => { + return art.uniqueId == this.$scope.selectedArtifactId; + })[0]; + return artifact; + } + + private initScope = ():void => { + let self = this; + this.$scope.isLoading = false; + this.$scope.selectedArtifactId = null; + this.initDescriptions(); + if(this.$scope.component.deploymentArtifacts) { + this.initArtifacts(false); + } else { + this.initArtifacts(true); + } + this.$scope.setValidState(true); + + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'artifactDisplayName'}, + {title: 'Type', property: 'artifactType'}, + {title: 'Deployment timeout', property: 'timeout'}, + {title: 'Version', property: 'artifactVersion'}, + {title: 'UUID', property: 'artifactUUID'} + ]; + + this.$templateCache.put("deployment-artifacts-description-popover.html", require('app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-description-popover.html')); + this.$scope.popoverTemplate = "deployment-artifacts-description-popover.html"; + + this.$scope.isLicenseArtifact = (artifact:ArtifactModel):boolean => { + let isLicense:boolean = false; + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { + + isLicense = this.artifactsUtils.isLicenseType(artifact.artifactType); + } + + return isLicense; + }; + + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + this.$scope.getValidationPattern = (validationType:string, parameterType?:string):RegExp => { + return this.validationUtils.getValidationPattern(validationType, parameterType); + }; + + this.$scope.validateJson = (json:string):boolean => { + if (!json) { + return true; + } + return this.validationUtils.validateJson(json); + }; + + this.$scope.viewModeOrCsarComponent = ():boolean => { + return this.$scope.isViewMode() || (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()); + }; + + this.$scope.addOrUpdate = (artifact:ArtifactModel):void => { + artifact.artifactGroupType = 'DEPLOYMENT'; + let artifactCopy = new ArtifactModel(artifact); + + let success = (response:any):void => { + this.$scope.artifactDescriptions[artifactCopy.artifactLabel] = artifactCopy.description; + this.initArtifacts(true); + // this.$scope.artifacts = _.values(this.$scope.component.deploymentArtifacts); + }; + + let error = (err:any):void => { + console.log(err); + this.initArtifacts(true); + // self.$scope.artifacts = _.values(self.$scope.component.deploymentArtifacts); + }; + + this.ModalsHandler.openArtifactModal(artifactCopy, this.$scope.component).then(success, error); + }; + + this.$scope.noArtifactsToShow = ():boolean => { + return !_.some(this.$scope.artifacts, 'esId'); + }; + + this.$scope.resetValue = (parameter:any):void => { + if (!parameter.currentValue && parameter.defaultValue) { + parameter.currentValue = parameter.defaultValue; + } + else if ('boolean' == parameter.type) { + parameter.currentValue = parameter.currentValue.toUpperCase(); + } + }; + + this.$scope.$watch('editForm.$valid', ():void => { + if (this.$scope.editForm) { + // this.$scope.setValidState(this.$scope.editForm.$valid); + } + }); + + this.$scope.updateSelectedArtifact = ():void => { + if (!this.$scope.isViewMode() && !this.$scope.isLoading) { + let artifact:ArtifactModel = this.getCurrentArtifact(); + this.setArtifact(artifact); //resets artifact description to original value if invalid. + if (artifact && artifact.originalDescription != artifact.description) { + this.$scope.isLoading = true; + let onSuccess = (responseArtifact:ArtifactModel):void => { + this.$scope.artifactDescriptions[responseArtifact.artifactLabel] = responseArtifact.description; + // this.$scope.artifacts = _.values(this.$scope.component.deploymentArtifacts); + this.initArtifacts(true); + this.$scope.isLoading = false; + }; + + let onFailed = (error:any):void => { + console.log('Delete artifact returned error:', error); + this.$scope.isLoading = false; + }; + + this.$scope.component.addOrUpdateArtifact(artifact).then(onSuccess, onFailed); + } + } + }; + + this.$scope.delete = (artifact:ArtifactModel):void => { + let onOk = ():void => { + this.$scope.isLoading = true; + let onSuccess = ():void => { + this.$scope.isLoading = false; + this.initArtifacts(true); + //this.$scope.artifacts = _.values(this.$scope.component.deploymentArtifacts); + }; + + let onFailed = (error:any):void => { + this.$scope.isLoading = false; + console.log('Delete artifact returned error:', error); + }; + + this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); + }; + + let title:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); + let message:string = self.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + + this.$scope.getEnvArtifactName = (artifact:ArtifactModel):string => { + let envArtifact = this.$scope.getEnvArtifact(artifact); + if (envArtifact) { + return envArtifact.artifactDisplayName; + } + }; + + this.$scope.openEditEnvParametersModal = (artifact:ArtifactModel):void => { + this.ModalsHandler.openEditEnvParametersModal(artifact, this.$scope.component).then(()=> { + this.initArtifacts(true); + }, ()=> { + this.initArtifacts(true); + }); + }; + + this.$scope.openDescriptionPopover = (artifactId:string):void => { + if (this.$scope.selectedArtifactId && this.$scope.selectedArtifactId != artifactId) { + this.$scope.updateSelectedArtifact(); + } + this.$scope.selectedArtifactId = artifactId; + + }; + + this.$scope.closeDescriptionPopover = ():void => { + if (this.$scope.selectedArtifactId) { + this.$scope.updateSelectedArtifact(); + this.$scope.selectedArtifactId = null; + } + }; + }; +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html new file mode 100644 index 0000000000..cc914b07a8 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view.html @@ -0,0 +1,126 @@ +<div class="workspace-deployment-artifact"> + + <div data-tests-id="add-deployment-artifact-button" ng-if="!isViewMode()" data-ng-class="{'disabled': isDisableMode()}" data-tests-id="add-property-button" class="add-btn" data-ng-click="addOrUpdate({})">Add</div> + + <div class="table-container-flex"> + + <div class="table" data-ng-class="{'view-mode': isViewMode()}"> + <loader data-display="isLoading"></loader> + <div class="head flex-container"> + <div class="table-header head-row hand flex-item" data-ng-repeat="header in tableHeadersList track by $index" data-ng-click="sort(header.property)">{{header.title}} + <span data-ng-if="sortBy === header.property" class="table-header-sort-arrow" data-ng-class="{'down': reverse, 'up':!reverse}"> </span> + </div> + <div class="table-no-text-header head-row flex-item"></div> + </div> + + <form class="body" name="editForm"> + + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + + <!-- Artifact row --> + <div ng-if="noArtifactsToShow()" data-ng-class="{'disabled': isDisableMode()}" class="no-row-text" translate="DEPLOYMENT_ARTIFACT_NO_ARTIFACTS_TO_DISPLAY"></div> + <div data-ng-repeat-start="artifact in artifacts | orderBy:sortBy:reverse track by $index" + class="flex-container data-row" + data-ng-class="{'selected': selectedArtifactId == artifact.uniqueId }" + data-ng-if="artifact.esId && 'HEAT_ENV' !== artifact.artifactType" + data-tests-id="artifact-item-{{artifact.artifactDisplayName}}"> + <div class="table-col-general flex-item" > + <div class="heat-env-connect-container" ng-class="{'heat-env-connect-container-view-mode': isViewMode()}" data-ng-if="artifact.envArtifact"> + <span class="heat-env-connect"></span> + </div> + <span data-tests-id="artifactDisplayName_{{artifact.artifactDisplayName}}" sdc-smart-tooltip class="artifact-name">{{artifact.artifactDisplayName}}</span> + + <span class="sprite-new show-desc hand description-popover-icon" + uib-popover-template="popoverTemplate" + popover-class="parameter-description-popover deployment-artifact-view top" + popover-title="Description" + popover-placement="top-left" + popover-is-open="selectedArtifactId == artifact.uniqueId && !isLoading" + popover-trigger="'none'" + popover-append-to-body="true" + data-ng-click="openDescriptionPopover(artifact.uniqueId)" + data-tests-id="descriptionIcon_{{artifact.artifactDisplayName}}"></span> + </div> + + <div class="table-col-general flex-item text" data-tests-id="artifactType_{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactType}}"> + {{artifact.artifactType}} + </div> + <div class="table-col-general flex-item" data-tests-id="timeout_{{artifact.artifactDisplayName}}"> + {{artifact.timeout? artifact.timeout:''}} + </div> + <div class="table-col-general flex-item" data-tests-id="artifactVersion_{{artifact.artifactDisplayName}}"> + {{artifact.artifactVersion}} + </div> + <div class="table-col-general flex-item text" data-tests-id="artifactUUID_{{artifact.artifactDisplayName}}" tooltips tooltip-content="{{artifact.artifactUUID}}"> + <span>{{artifact.artifactUUID}}</span> + </div> + + <div class="table-btn-col flex-item"> + <button class="table-edit-btn" data-tests-id="edit_{{artifact.artifactDisplayName}}" + data-ng-if="!isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)" data-ng-click="addOrUpdate(artifact)"></button> + <button class="table-delete-btn" data-tests-id="delete_{{artifact.artifactDisplayName}}" + data-ng-if="!isViewMode() && !artifact.isHEAT() && !artifact.isThirdParty() && !isLicenseArtifact(artifact)" data-ng-click="delete(artifact)"> </button> + <button class="table-download-btn" download-artifact data-tests-id="download_{{artifact.artifactDisplayName}}" + data-ng-if="artifact.artifactDisplayName" component="component" artifact="artifact"></button> + <button ng-if="!isViewMode() && artifact.isHEAT()" + class="sprite e-sdc-small-icon-pad edit-paramtes-button" + data-ng-click="openEditEnvParametersModal(artifact)" type="button" + data-tests-id="edit-parameters-of-{{artifact.artifactDisplayName}}"></button> + </div> + </div> + <div data-ng-repeat-end="" class="flex-container data-row" data-ng-if="artifact.envArtifact"> + + <div class="table-col-general flex-item" zzdata-ng-click="!isViewMode() && addOrUpdate(artifact.envArtifact)"> + <span>{{artifact.envArtifact.artifactDisplayName}}</span> + </div> + + <div class="table-col-general flex-item" data-tests-id="{{artifact.envArtifact.artifactType}}"> + {{artifact.envArtifact.artifactType}} + </div> + <div class="table-col-general flex-item" data-tests-id="{{artifact.envArtifact.timeout}}"> + {{artifact.envArtifact.timeout? artifact.envArtifact.timeout:''}} + </div> + <div class="table-col-general flex-item" data-tests-id="artifactEnvVersion_{{artifact.artifactDisplayName}}"> + {{artifact.envArtifact.artifactVersion}} + </div> + <div class="table-col-general flex-item text" data-tests-id="{{artifact.envArtifact.artifactUUID}}" tooltips tooltip-content="{{artifact.envArtifact.artifactUUID}}"> + <span>{{artifact.envArtifact.artifactUUID}}</span> + </div> + + + <div class="table-btn-col flex-item" > + <button class="table-edit-btn" data-tests-id="edit_{{artifact.artifactLabel}}env" + data-ng-if="!isViewMode()" data-ng-click="addOrUpdate(artifact.envArtifact)"></button> + <button class="table-download-btn" data-tests-id="download_env_{{artifact.artifactDisplayName}}" download-artifact + data-ng-if="artifact.artifactName" component="component" artifact="artifact.envArtifact"></button> + + </div> + </div> + + <!--<div class="i-sdc-designer-sidebar-section-content-item-artifact-heat-env" ng-if="artifact.heatParameters.length">--> + <!--<span class="enabled" data-ng-bind="getEnvArtifactName(artifact)" data-ng-click="!isViewMode() && addOrUpdate(getEnvArtifact(artifact))"></span>--> + <!--<download-artifact class="i-sdc-designer-sidebar-section-content-item-button download-env sprite e-sdc-small-download hand" artifact="getEnvArtifact(artifact)"--> + <!--component="currentComponent" instance="true"--> + <!--data-tests-id="download"></download-artifact>--> + <!--</div>--> + + + + <!-- Add artifacts buttons --> + <!--<button class="add-button" data-ng-repeat="artifact in artifacts track by $index"--> + <!--type="button"--> + <!--data-ng-show="!artifact.esId"--> + <!--data-ng-if="!viewModeOrCsarComponent()"--> + <!--data-ng-class="{'disabled': isDisableMode() || component.isCsarComponent()}"--> + <!--data-tests-id="{{artifact.artifactDisplayName}} deployment_artifact"--> + <!--translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_HEAT"--> + <!--translate-values="{'name': '{{artifact.artifactDisplayName}}'}"--> + <!--data-ng-click="addOrUpdate(artifact)"></button>--> + + <!-- Top add button --> + <button class="add-button" type="button" data-ng-if="!isViewMode()" data-ng-class="{'disabled': isDisableMode()}" translate="DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER" data-ng-click="addOrUpdate({})"></button> + </perfect-scrollbar> + </form> + </div> + </div> +</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less index 9f90a47d5a..dd3b16447c 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less @@ -11,6 +11,47 @@ margin-bottom: 10px; } + + .heat-env-connect-container{ + background-color: white; + position: absolute; + height: 70px; + width:20px; + left: 0; + top:0; + } + .heat-env-connect-container-view-mode{ + background-color: @tlv_color_t; + } + .heat-env-connect{ + border-left: 1px #848586 solid; + height: 50px; + margin-left: 10px; + margin-top: 10px; + border-top: 1px #848586 solid; + border-bottom: 1px #848586 solid; + width: 11px; + float: left; + + } + + .artifact-name{ + width:85%; + } + + .table-container-flex .table .body .data-row div .heat-env-connect-container{ + border-right: none; + } + + .i-sdc-designer-sidebar-section-content-item-file-link::before{ + content:""; + background-color: white; + width: 12px; + + } + + + .table { height:490px; margin-bottom: 0; @@ -32,12 +73,25 @@ margin-top: 27px; + .text{ + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + white-space: nowrap; + } + .flex-item:nth-child(1) { flex-grow: 15; .hand; + padding-left: 30px; + position: relative; span.table-arrow { margin-right: 7px; } + .description-popover-icon{ + float:right; + margin-top:6px; + } } .flex-item:nth-child(2) { @@ -50,7 +104,30 @@ .flex-item:nth-child(4) { flex-grow: 3; - padding-top: 10px; + } + + .flex-item:nth-child(5) { + flex-grow: 20; + } + + .flex-item:nth-child(6) { + flex-grow: 5; + + &.table-btn-col { + display: flex; + justify-content: space-between; + align-items: center; + + button { + flex: 0 1 auto; + background-color: transparent; + border: 0; + margin: 0; + } + .edit-paramtes-button { + order: -1; + } + } } } .w-sdc-form{ @@ -100,3 +177,20 @@ } } } + +.parameter-description-popover.deployment-artifact-view { + margin-left: -10px; + z-index: 1040; + min-width: 300px; + .input-error { + .q_12_m; + } + .error textarea{ + border-color: @main_color_g; + color: @color_h; + outline: none; + } + .popover-content textarea { + width:100%; + } +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts new file mode 100644 index 0000000000..c94342a51e --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view-model.ts @@ -0,0 +1,127 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ComponentFactory, MenuHandler, ChangeLifecycleStateHandler, ModalsHandler} from "app/utils"; +import {LeftPaletteLoaderService, CacheService, SharingService} from "app/services"; +import {Component, IAppMenu, Tab, ComponentInstance} from "app/models"; +import {GRAPH_EVENTS} from "../../../../utils/constants"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {EventListenerService} from "../../../../services/event-listener-service"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; + +export interface IDeploymentViewModelScope extends IWorkspaceViewModelScope { + + currentComponent:Component; + selectedComponent:Component; + isLoading:boolean; + sharingService:SharingService; + sdcMenu:IAppMenu; + version:string; + isViewOnly:boolean; + tabs:Array<Tab>; + selectedTab: Tab; + isComponentInstanceSelected():boolean; + updateSelectedComponent():void + openUpdateModal(); + deleteSelectedComponentInstance():void; + onBackgroundClick():void; + setSelectedInstance(componentInstance:ComponentInstance):void; + printScreen():void; + +} + +export class DeploymentViewModel { + + static '$inject' = [ + '$scope', + '$templateCache', + 'sdcMenu', + 'MenuHandler', + '$state', + 'Sdc.Services.SharingService', + '$filter', + 'Sdc.Services.CacheService', + 'ComponentFactory', + 'ChangeLifecycleStateHandler', + 'LeftPaletteLoaderService', + 'ModalsHandler', + 'EventListenerService', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:IDeploymentViewModelScope, + private $templateCache:ng.ITemplateCacheService, + private sdcMenu:IAppMenu, + private MenuHandler:MenuHandler, + private $state:ng.ui.IStateService, + private sharingService:SharingService, + private $filter:ng.IFilterService, + private cacheService:CacheService, + private ComponentFactory:ComponentFactory, + private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler, + private LeftPaletteLoaderService:LeftPaletteLoaderService, + private ModalsHandler:ModalsHandler, + private eventListenerService: EventListenerService, + private ComponentServiceNg2: ComponentServiceNg2) { + + this.$scope.setValidState(true); + this.initScope(); + this.initGraphData(); + this.$scope.updateSelectedMenuItem(); + } + + + private initComponent = ():void => { + + this.$scope.currentComponent = this.$scope.component; + this.$scope.selectedComponent = this.$scope.currentComponent; + this.updateUuidMap(); + this.$scope.isViewOnly = this.$scope.isViewMode(); + }; + + + private updateUuidMap = ():void => { + /** + * In case user press F5, the page is refreshed and this.sharingService.currentEntity will be undefined, + * but after loadService or loadResource this.sharingService.currentEntity will be defined. + * Need to update the uuidMap with the new resource or service. + */ + this.sharingService.addUuidValue(this.$scope.currentComponent.uniqueId, this.$scope.currentComponent.uuid); + }; + + private initRightTabs = ()=> { + if (this.$scope.currentComponent.groups) { + this.$templateCache.put("hierarchy-view.html", require('app/view-models/tabs/hierarchy/hierarchy-view.html')); + let hierarchyTab = new Tab("hierarchy-view.html", 'Sdc.ViewModels.HierarchyViewModel', 'hierarchy', this.$scope.isViewMode(), this.$scope.currentComponent, 'hierarchy'); + this.$scope.tabs.push(hierarchyTab) + } + } + + private initGraphData = ():void => { + if(!this.$scope.component.componentInstances || !this.$scope.component.componentInstancesRelations || !this.$scope.component.groups) { + this.ComponentServiceNg2.getDeploymentGraphData(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.componentInstances = response.componentInstances; + this.$scope.component.componentInstancesRelations = response.componentInstancesRelations; + this.$scope.component.groups = response.groups; + this.$scope.isLoading = false; + this.initComponent(); + this.initRightTabs(); + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DEPLOYMENT_GRAPH_DATA_LOADED); + this.$scope.selectedTab = this.$scope.tabs[0]; + }); + } else { + this.$scope.isLoading = false; + this.initRightTabs(); + this.eventListenerService.notifyObservers(GRAPH_EVENTS.ON_DEPLOYMENT_GRAPH_DATA_LOADED); + + } + }; + + private initScope = ():void => { + this.$scope.isLoading = true; + this.$scope.sharingService = this.sharingService; + this.$scope.sdcMenu = this.sdcMenu; + this.$scope.version = this.cacheService.get('version'); + this.initComponent(); + this.$scope.tabs = Array<Tab>(); + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment-view.html b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view.html index 9e26656f5f..f8b5f23a25 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment-view.html @@ -1,10 +1,10 @@ <div class="deployment-view"> + <loader display="isLoading"></loader> <div class="w-sdc-deployment-canvas" data-ng-class="{sidebaractive: displayDesignerRightSidebar}"> - <!--<module-graph data-tests-id="canvas" current-component="currentComponent" is-view-only="isViewOnly" is-loading="isLoading"></module-graph>--> <deployment-graph component="currentComponent" is-view-only="isViewOnly"></deployment-graph> </div> <div class="w-sdc-deployment-right-bar"> - <sdc-tabs tabs="tabs" is-view-only="isViewOnly"></sdc-tabs> + <sdc-tabs tabs="tabs" is-view-only="isViewOnly" selected-tab="selectedTab"></sdc-tabs> </div> </div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment.less b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment.less index 0439ccd0fa..4c548c7331 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/deployment/deployment.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/deployment/deployment.less @@ -1,4 +1,4 @@ -.deployment-view{ +.deployment-view { display: inline-block; text-align: left; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts new file mode 100644 index 0000000000..ce2e0169bf --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view-model.ts @@ -0,0 +1,83 @@ +'use strict'; +import {Distribution, DistributionComponent, ExportExcel} from "app/models"; + +interface IDistributionStatusModalViewModelScope { + distribution:Distribution; + status:string; + getStatusCount(distributionComponent:Array<DistributionComponent>):any; + getUrlName(url:string):string; + modalDitributionStatus:ng.ui.bootstrap.IModalServiceInstance; + footerButtons:Array<any>; + //exportExcelData:ExportExcel; + close():void; + initDataForExportExcel():ExportExcel; +} + +export class DistributionStatusModalViewModel { + + static '$inject' = ['$scope', '$uibModalInstance', 'data', '$filter']; + + constructor(private $scope:IDistributionStatusModalViewModelScope, + private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance, + private data:any, + private $filter:ng.IFilterService) { + this.initScope(); + } + + private generateMetaDataForExportExcel = ():Array<string>=> { + let metaData = []; + metaData[0] = 'Name:' + this.data.component.name + '| UUID:' + this.data.component.uuid + '| Invariant UUID:' + this.data.component.invariantUUID; + metaData[1] = 'Distribution ID:' + this.$scope.distribution.distributionID + + '| USER ID:' + this.$scope.distribution.userId + + '| Time[UTC]:' + this.$filter('date')(this.$scope.distribution.timestamp, 'MM/dd/yyyy h:mma', 'UTC') + + '| Status:' + this.$scope.distribution.deployementStatus; + return metaData; + }; + + private generateDataObjectForExportExcel = ():any=> { + let correctFormatDataObj = []; + _.each(this.$scope.distribution.distributionComponents, (dComponent:DistributionComponent) => { + if (dComponent.status == this.$scope.status) { + correctFormatDataObj.push({ + 'omfComponentID': dComponent.omfComponentID, + 'artiFactName': this.$scope.getUrlName(dComponent.url), + 'url': dComponent.url, + 'timestamp': this.$filter('date')(dComponent.timestamp, 'MM/dd/yyyy h:mma', 'UTC'), + 'status': dComponent.status + }); + } + }); + return correctFormatDataObj; + }; + + private initScope = ():void => { + this.$scope.distribution = this.data.distribution; + this.$scope.status = this.data.status; + this.$scope.modalDitributionStatus = this.$uibModalInstance; + + + this.$scope.getUrlName = (url:string):string => { + let urlName:string = _.last(url.split('/')); + return urlName; + }; + + this.$scope.initDataForExportExcel = ():ExportExcel => { + let exportExcelData = new ExportExcel(); + exportExcelData.fileName = this.$scope.status; + exportExcelData.groupByField = "omfComponentID"; + exportExcelData.tableHeaders = ["Component ID", "Artifact Name", "URL", "Time(UTC)", "Status"]; + exportExcelData.metaData = this.generateMetaDataForExportExcel(); + exportExcelData.dataObj = this.generateDataObjectForExportExcel(); + return exportExcelData; + }; + + this.$scope.close = ():void => { + this.$uibModalInstance.close(); + }; + + this.$scope.footerButtons = [ + {'name': 'Close', 'css': 'blue', 'callback': this.$scope.close} + ]; + + }; +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html index b3393e99e0..3367193fc7 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal-view.html @@ -5,6 +5,10 @@ </div> + <div class="actions-buttons"> + <json-export-excel init-export-excel-data="initDataForExportExcel()"> + </json-export-excel> + </div> <perfect-scrollbar include-padding="true" class="w-sdc-distribution-view-content"> <div class="w-sdc-distribution-view-content-section w-sdc-distribute-parent-block"> @@ -34,7 +38,7 @@ </div> <div class="w-sdc-distribute-status-block" data-ng-show="distribution.statusCount"> <div class="status-item-1">Status: {{status}} <span data-ng-bind="(distribution.distributionComponents | filter:status:true).length" - class="blue-font"></span></div> + class="blue-font"></span></div> </div> </div> @@ -48,7 +52,7 @@ <div class="w-sdc-distribution-arrow-btn" data-ng-click="omfComponentListExtends=!omfComponentListExtends" ng-class="{'extends': omfComponentListExtends}" data-ng-init="omfComponentListExtends=false" - ></div> + ></div> <div class="w-sdc-distribute-status-block"> <div class="status-item-1">{{omfComponentID}} <span class="blue-font">{{omfComponentList.length}}</span> </div> @@ -73,7 +77,7 @@ <div class="w-sdc-distribution-arrow-btn" data-ng-click="urlListExtends=!urlListExtends" data-ng-class="{'extends': urlListExtends}" data-ng-init="urlListListExtends=false" - ></div> + ></div> {{urlList[0].omfComponentID}} </div> <div class="w-sdc-distribute-cell item-2" sdc-smart-tooltip> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less index 02321b6e2f..d167083a2b 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less @@ -1,9 +1,16 @@ .w-sdc-classic-top-line-modal { .w-sdc-modal-head { - // border-bottom: none; + // border-bottom: none; } .w-sdc-distribution-view { + .actions-buttons { + height: 29px; + padding: 0 25px 0 0px; + span{ + float: right; + } + } .w-sdc-distribution-view-content { height: 500px; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts new file mode 100644 index 0000000000..002b16f63f --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view-model.ts @@ -0,0 +1,111 @@ +'use strict'; +import {Distribution, DistributionComponent, Service} from "app/models"; +import {ModalsHandler, Dictionary} from "app/utils"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; + +interface IDistributionViewModel extends IWorkspaceViewModelScope { + modalDistribution:ng.ui.bootstrap.IModalServiceInstance; + service:Service; + distributions:Array<Distribution>; + showComponents(distribution:Distribution):void; + markAsDeployed(distribution:Distribution):void; + getStatusCount(distributionComponent:Array<DistributionComponent>):any; + initDistributions():void; + getUrlName(url:string):string; + close():void; + openDisributionStatusModal:Function; +} + +export class DistributionViewModel { + + static '$inject' = [ + '$scope', + 'ModalsHandler' + + ]; + + constructor(private $scope:IDistributionViewModel, + private ModalsHandler:ModalsHandler) { + this.initScope(); + this.$scope.setValidState(true); + this.$scope.updateSelectedMenuItem(); + } + + private initScope = ():void => { + this.$scope.service = <Service>this.$scope.component; + + + // Open Distribution status modal + this.$scope.openDisributionStatusModal = (distribution:Distribution, status:string):void => { + this.ModalsHandler.openDistributionStatusModal(distribution, status, this.$scope.component).then(()=> { + // OK + }, ()=> { + // ERROR + }); + }; + + + this.$scope.showComponents = (distribution:Distribution):void => { + let onError = (response) => { + console.info('onError showComponents', response); + }; + let onSuccess = (distributionComponents:Array<DistributionComponent>) => { + distribution.distributionComponents = distributionComponents; + distribution.statusCount = this.$scope.getStatusCount(distribution.distributionComponents); + // distribution.components = this.aggregateDistributionComponent(distributionComponents);; + }; + this.$scope.service.getDistributionsComponent(distribution.distributionID).then(onSuccess, onError); + }; + + this.$scope.getStatusCount = (distributionComponent:Array<DistributionComponent>):any => { + return _.countBy(distributionComponent, 'status') + }; + + this.$scope.getUrlName = (url:string):string => { + let urlName:string = _.last(url.split('/')); + return urlName; + }; + + this.$scope.markAsDeployed = (distribution:Distribution):void => { + let onError = (response) => { + console.info('onError markAsDeployed', response); + }; + let onSuccess = (result:any) => { + distribution.deployementStatus = 'Deployed'; + }; + this.$scope.service.markAsDeployed(distribution.distributionID).then(onSuccess, onError); + + }; + + this.$scope.initDistributions = ():void => { + let onError = (response) => { + console.info('onError initDistributions', response); + }; + let onSuccess = (distributions:Array<Distribution>) => { + this.$scope.distributions = distributions; + }; + this.$scope.service.getDistributionsList().then(onSuccess, onError); + }; + + this.$scope.initDistributions(); + + }; + + + private aggregateDistributionComponent = (distributionComponents:Array<DistributionComponent>):any => { + let aggregateDistributions:Dictionary<string,Dictionary<string,Array<DistributionComponent>>> = new Dictionary<string,Dictionary<string,Array<DistributionComponent>>>(); + let tempAggregateDistributions:any = _.groupBy(distributionComponents, 'omfComponentID'); + let aa = new Dictionary<string,Array<DistributionComponent>>(); + + let tempAggregate:any; + _.forEach(tempAggregateDistributions, (distributionComponents:Array<DistributionComponent>, omfComponentID:string)=> { + + let urls:any = _.groupBy(distributionComponents, 'url'); + aggregateDistributions.setValue(omfComponentID, urls); + // aggregateDistributions[omfComponentID] = ; + + }); + console.log(aggregateDistributions); + return aggregateDistributions; + }; +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution-view.html b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view.html index 1ab0f1e111..710336af15 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution-view.html @@ -54,29 +54,34 @@ data-ng-click="(item.deployementStatus==='Deployed') || markAsDeployed(item)"></div> </div> </div> - <div class="w-sdc-distribute-status-block" data-ng-show="item.statusCount"> + <div class="w-sdc-distribute-status-block" data-ng-if="item.statusCount"> <div class="status-item-1">Total Artifacts:<span data-ng-bind="(item.statusCount.NOT_NOTIFIED || 0) + (item.statusCount.NOTIFIED || 0) " class="blue-font" data-tests-id="totalArtifacts_{{$index}}"></span></div> <div class="status-item-2 " ><sapn class="link" data-ng-click="openDisributionStatusModal(item,'NOTIFIED')">Notified:</sapn><span data-ng-bind="item.statusCount.NOTIFIED || 0" class="blue-font" data-tests-id="notified_{{$index}}"></span></div> + <div class="status-item-3 link" ><sapn class="link" data-ng-click="openDisributionStatusModal(item,'DOWNLOAD_OK')">Downloaded:</sapn><span data-ng-bind="item.statusCount.DOWNLOAD_OK || 0" class="blue-font" data-tests-id="downloaded_{{$index}}"></span></div> + <div class="status-item-4 link"><sapn class="link" data-ng-click="openDisributionStatusModal(item,'DEPLOY_OK')">Deployed:</sapn><span data-ng-bind="item.statusCount.DEPLOY_OK || 0" class="blue-font" data-tests-id="deployed_{{$index}}" ></span><span data-ng-class="{'deployed':(item.statusCount.DEPLOY_OK > 0)}"></span></div> <div class="status-item-5 link" ><sapn class="link" data-ng-click="openDisributionStatusModal(item,'NOT_NOTIFIED')">Not Notified:</sapn><span data-ng-bind="item.statusCount.NOT_NOTIFIED || 0" class="blue-font" data-tests-id="NotNotified_{{$index}}"></span></div> - <div class="status-item-6"><sapn class="link" data-ng-click="openDisributionStatusModal(item,'DOWNLOAD_ERROR')" >Errors:</sapn><span + <div class="status-item-6"><sapn class="link" data-ng-click="openDisributionStatusModal(item,'DEPLOY_ERROR')" >Deploy Errors:</sapn><span + data-ng-bind="item.statusCount.DEPLOY_ERROR || 0" class="red-font "></span><span + data-ng-class="{'error':(item.statusCount.DEPLOY_ERROR > 0)}" data-tests-id="errors_{{$index}}"></span></div> + <div class="status-item-7"><sapn class="link" data-ng-click="openDisributionStatusModal(item,'DOWNLOAD_ERROR')" >Download Errors:</sapn><span data-ng-bind="item.statusCount.DOWNLOAD_ERROR || 0" class="red-font "></span><span data-ng-class="{'error':(item.statusCount.DOWNLOAD_ERROR > 0)}" data-tests-id="errors_{{$index}}"></span></div> </div> </div> </div> - <ul data-ng-show="item.showDetails && item.distributionComponents.length" + <ul data-ng-if="item.showDetails && item.distributionComponents.length" class="w-sdc-distribute-components-block disable-hover"> - <li data-ng-repeat="(omfComponentID,omfComponentList) in item.distributionComponents | orderBy: '-timestamp' | filter:searchBind | groupBy:'omfComponentID' " + <li data-ng-repeat="(omfComponentID,omfComponentList) in ::item.distributionComponents | orderBy: '-timestamp' | filter:searchBind | groupBy:'omfComponentID' " class="disable-hover" data-ng-init="statusCount = getStatusCount(omfComponentList);"> <div class="w-sdc-distribute-row omf-component-row w-sdc-distribute-row-extends" @@ -97,12 +102,15 @@ data-ng-class="{'deployed':(statusCount.DEPLOY_OK > 0)}"></span></div> <div class="status-item-5">Not Notified:<span data-ng-bind="statusCount.NOT_NOTIFIED || 0" class="blue-font"></span></div> - <div class="status-item-6">Errors:<span + <div class="status-item-6">Deploy Errors:<span + data-ng-bind="statusCount.DEPLOY_ERROR || 0" class="red-font"></span><span + data-ng-class="{'error':(statusCount.DEPLOY_ERROR > 0)}"></span></div> + <div class="status-item-7">Download Errors:<span data-ng-bind="statusCount.DOWNLOAD_ERROR || 0" class="red-font"></span><span data-ng-class="{'error':(statusCount.DOWNLOAD_ERROR > 0)}"></span></div> </div> </div> - <div data-ng-show="omfComponentListExtends" + <div data-ng-if="omfComponentListExtends" class="w-sdc-distribute-omfComponent-block disable-hover"> <div class="w-sdc-distribute-row-extends disable-hover"> <div class="disable-hover"> @@ -115,17 +123,17 @@ </div> <div class="w-sdc-distribute-row omfComponent-table-row" - data-ng-repeat-start="(url,urlList) in omfComponentList | orderBy: '-timestamp' | groupBy:'url'" + data-ng-repeat-start="(url,urlList) in ::omfComponentList | orderBy: '-timestamp' | groupBy:'url'" data-ng-class="urlListExtends?'extends row-{{$index}}':'row-{{$index}}'"> - <div class="w-sdc-distribute-cell item-1"> + <div class="w-sdc-distribute-cell item-1" sdc-smart-tooltip> <div class="w-sdc-distribution-arrow-btn" data-ng-click="urlListExtends=!urlListExtends" data-ng-class="{'extends': urlListExtends}" - data-ng-init="urlListListExtends=false" + data-ng-init="urlListListExtends=false;urlList[0].displayUrl=getUrlName(urlList[0].url)" ></div> {{urlList[0].omfComponentID}} </div> <div class="w-sdc-distribute-cell item-2" sdc-smart-tooltip> - {{getUrlName(urlList[0].url)}} + {{urlList[0].displayUrl}} </div> <div class="w-sdc-distribute-cell item-3 disable-hover"> <div sdc-smart-tooltip class="distribution-url">{{urlList[0].url}}</div> @@ -135,15 +143,17 @@ <div class="w-sdc-distribute-cell item-4"><span data-ng-bind="urlList[0].timestamp | date: 'MM/dd/yyyy h:mma':'UTC'"></span> </div> - <div class="w-sdc-distribute-cell item-5">{{urlList[0].status}}</div> + <div class="w-sdc-distribute-cell item-5" sdc-smart-tooltip> + {{urlList[0].status}} + </div> </div> - <div data-ng-repeat-end data-ng-show="urlListExtends" class="disable-hover" > + <div data-ng-repeat-end data-ng-if="urlListExtends" class="disable-hover" > <div class="w-sdc-distribute-row extends disable-hover"> - <ul data-ng-show="urlListExtends" + <ul data-ng-if="urlListExtends" class="w-sdc-distribute-url-block disable-hover"> - <li data-ng-repeat="distributionComponent in urlList | orderBy: '-timestamp'" + <li data-ng-repeat="distributionComponent in ::urlList | orderBy: '-timestamp'" class="disable-hover"> <span data-ng-bind="distributionComponent.timestamp | date: 'MM/dd/yyyy h:mma':'UTC'" @@ -151,9 +161,9 @@ <span class="disable-hover">{{distributionComponent.status}}</span> <span - class="disable-hover reason" data-ng-show="distributionComponent.status == 'NOT_NOTIFIED'">Reason: Component has determined artifact is not needed.</span> + class="disable-hover reason" data-ng-if="distributionComponent.status == 'NOT_NOTIFIED'">Reason: Component has determined artifact is not needed.</span> <span - class="disable-hover reason" data-ng-show="distributionComponent.errorReason">Reason: {{distributionComponent.errorReason}}</span> + class="disable-hover reason" data-ng-if="distributionComponent.errorReason">Reason: {{distributionComponent.errorReason}}</span> </li> </ul> </div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution.less b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution.less index 8ad8c1793e..ee1f7ed2d6 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/distribution/distribution.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/distribution/distribution.less @@ -147,6 +147,7 @@ .sprite-new; .arrow-up-small; margin: 0 6px; + display: inline-table; } .extends.w-sdc-distribution-arrow-btn { -webkit-transform: rotate(180deg); diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts new file mode 100644 index 0000000000..44953985fc --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts @@ -0,0 +1,349 @@ +'use strict'; +import {ModalsHandler, ValidationUtils, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ComponentType, DEFAULT_ICON, + ResourceType} from "app/utils"; +import {CacheService, EventListenerService, ProgressService} from "app/services"; +import {IAppConfigurtaion, Product, IValidate, IMainCategory, Resource, ISubCategory,Service} from "app/models"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; + +export class Validation { + componentNameValidationPattern:RegExp; + contactIdValidationPattern:RegExp; + tagValidationPattern:RegExp; + vendorValidationPattern:RegExp; + commentValidationPattern:RegExp; + projectCodeValidationPattern:RegExp; +} + +export class componentCategories {//categories field bind to this obj in order to solve this bug: DE242059 + selectedCategory:string; +} + +export interface IGeneralScope extends IWorkspaceViewModelScope { + validation:Validation; + editForm:ng.IFormController; + categories:Array<IMainCategory>; + latestCategoryId:string; + latestVendorName:string; + importedFileExtension:any; + isCreate:boolean; + isShowFileBrowse:boolean; + isShowOnboardingSelectionBrowse:boolean; + importedToscaBrowseFileText:string; + importCsarProgressKey:string; + browseFileLabel:string; + componentCategories:componentCategories; + + onToscaFileChange():void + validateField(field:any):boolean; + validateName(isInit:boolean):void; + calculateUnique(mainCategory:string, subCategory:string):string; // Build unique string from main and sub category + onVendorNameChange(oldVendorName:string):void; + convertCategoryStringToOneArray(category:string, subcategory:string):Array<IMainCategory>; + onCategoryChange():void; + onEcompGeneratedNamingChange():void; + openOnBoardingModal():void; + initCategoreis():void; +} + +export class GeneralViewModel { + + static '$inject' = [ + '$scope', + 'Sdc.Services.CacheService', + 'ComponentNameValidationPattern', + 'ContactIdValidationPattern', + 'TagValidationPattern', + 'VendorValidationPattern', + 'CommentValidationPattern', + 'ValidationUtils', + 'sdcConfig', + 'ProjectCodeValidationPattern', + '$state', + 'ModalsHandler', + 'EventListenerService', + 'Notification', + 'Sdc.Services.ProgressService', + '$interval', + '$filter', + '$timeout' + ]; + + constructor(private $scope:IGeneralScope, + private cacheService:CacheService, + private ComponentNameValidationPattern:RegExp, + private ContactIdValidationPattern:RegExp, + private TagValidationPattern:RegExp, + private VendorValidationPattern:RegExp, + private CommentValidationPattern:RegExp, + private ValidationUtils:ValidationUtils, + private sdcConfig:IAppConfigurtaion, + private ProjectCodeValidationPattern:RegExp, + private $state:ng.ui.IStateService, + private ModalsHandler:ModalsHandler, + private EventListenerService:EventListenerService, + private Notification:any, + private progressService:ProgressService, + protected $interval:any, + private $filter:ng.IFilterService, + private $timeout:ng.ITimeoutService) { + + this.initScopeValidation(); + this.initScopeMethods(); + this.initScope(); + this.$scope.updateSelectedMenuItem(); + } + + + + + private initScopeValidation = ():void => { + this.$scope.validation = new Validation(); + this.$scope.validation.componentNameValidationPattern = this.ComponentNameValidationPattern; + this.$scope.validation.contactIdValidationPattern = this.ContactIdValidationPattern; + this.$scope.validation.tagValidationPattern = this.TagValidationPattern; + this.$scope.validation.vendorValidationPattern = this.VendorValidationPattern; + this.$scope.validation.commentValidationPattern = this.CommentValidationPattern; + this.$scope.validation.projectCodeValidationPattern = this.ProjectCodeValidationPattern; + }; + + private initScope = ():void => { + + // Work around to change the csar version + if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { + (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + } + + this.$scope.importedToscaBrowseFileText = this.$scope.component.name + " (" + (<Resource>this.$scope.component).csarVersion + ")"; + this.$scope.importCsarProgressKey = "importCsarProgressKey"; + this.$scope.browseFileLabel = this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType === ResourceType.VF ? "Upload file" : "Upload VFC"; + this.$scope.progressService = this.progressService; + this.$scope.componentCategories = new componentCategories(); + this.$scope.componentCategories.selectedCategory = this.$scope.component.selectedCategory; + + // Workaround to short vendor name to 25 chars + // Amdocs send 27 chars, and the validation pattern is 25 chars. + if (this.$scope.component.vendorName) { + this.$scope.component.vendorName = this.$scope.component.vendorName.substr(0, 25); + } + + // Init UIModel + this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name); + + // Init categories + this.$scope.initCategoreis(); + + // Init the decision if to show file browse. + this.$scope.isShowFileBrowse = false; + if (this.$scope.component.isResource()) { + let resource:Resource = <Resource>this.$scope.component; + console.log(resource.name + ": " + resource.csarUUID); + if (resource.importedFile) { // Component has imported file. + this.$scope.isShowFileBrowse = true; + } + if (this.$scope.isEditMode() && resource.resourceType == ResourceType.VF && !resource.csarUUID) { + this.$scope.isShowFileBrowse = true; + } + } + ; + + // Init the decision if to show onboarding + this.$scope.isShowOnboardingSelectionBrowse = false; + if (this.$scope.component.isResource() && + this.$scope.isEditMode() && + (<Resource>this.$scope.component).resourceType == ResourceType.VF && + (<Resource>this.$scope.component).csarUUID) { + this.$scope.isShowOnboardingSelectionBrowse = true; + } + + //init file extensions based on the file that was imported. + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) { + let fileName:string = (<Resource>this.$scope.component).importedFile.filename; + let fileExtension:string = fileName.split(".").pop(); + if (this.sdcConfig.csarFileExtension.indexOf(fileExtension.toLowerCase()) !== -1) { + this.$scope.importedFileExtension = this.sdcConfig.csarFileExtension; + (<Resource>this.$scope.component).importedFile.filetype = "csar"; + } else if (this.sdcConfig.toscaFileExtension.indexOf(fileExtension.toLowerCase()) !== -1) { + (<Resource>this.$scope.component).importedFile.filetype = "yaml"; + this.$scope.importedFileExtension = this.sdcConfig.toscaFileExtension; + } + } else if (this.$scope.isEditMode() && (<Resource>this.$scope.component).resourceType === ResourceType.VF) { + this.$scope.importedFileExtension = this.sdcConfig.csarFileExtension; + //(<Resource>this.$scope.component).importedFile.filetype="csar"; + } + + this.$scope.setValidState(true); + + this.$scope.calculateUnique = (mainCategory:string, subCategory:string):string => { + let uniqueId:string = mainCategory; + if (subCategory) { + uniqueId += "_#_" + subCategory; // Set the select category combobox to show the selected category. + } + return uniqueId; + }; + + //TODO remove this after handling contact in UI + if (this.$scope.component.isProduct() && this.$scope.isCreateMode()) { + (<Product>this.$scope.component).contacts = []; + (<Product>this.$scope.component).contacts.push(this.cacheService.get("user").userId); + } else if (this.$scope.isCreateMode()) { + this.$scope.component.contactId = this.cacheService.get("user").userId; + } + + }; + + // Convert category string MainCategory_#_SubCategory to Array with one item (like the server except) + private convertCategoryStringToOneArray = ():Array<IMainCategory> => { + let tmp = this.$scope.component.selectedCategory.split("_#_"); + let mainCategory = tmp[0]; + let subCategory = tmp[1]; + + // Find the selected category and add the relevant sub category. + let selectedMainCategory:IMainCategory = <IMainCategory>_.find(this.$scope.categories, function (item) { + return item["name"] === mainCategory; + + }); + + let mainCategoryClone = angular.copy(selectedMainCategory); + if (subCategory) { + let selectedSubcategory = <ISubCategory>_.find(selectedMainCategory.subcategories, function (item) { + return item["name"] === subCategory; + }); + mainCategoryClone['subcategories'] = [angular.copy(selectedSubcategory)]; + } + let tmpSelected = <IMainCategory> mainCategoryClone; + + let result:Array<IMainCategory> = []; + result.push(tmpSelected); + + return result; + }; + + private updateComponentNameInBreadcrumbs = ():void => { + //update breadcrum after changing name + this.$scope.breadcrumbsModel[1].updateSelectedMenuItemText(this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name); + this.$scope.updateMenuComponentName(this.$scope.component.name); + }; + + private initScopeMethods = ():void => { + + this.$scope.initCategoreis = ():void => { + if (this.$scope.componentType === ComponentType.RESOURCE) { + this.$scope.categories = this.cacheService.get('resourceCategories'); + + } + if (this.$scope.componentType === ComponentType.SERVICE) { + this.$scope.categories = this.cacheService.get('serviceCategories'); + } + }; + + this.$scope.validateField = (field:any):boolean => { + if (field && field.$dirty && field.$invalid) { + return true; + } + return false; + }; + + this.$scope.openOnBoardingModal = ():void => { + let csarUUID = (<Resource>this.$scope.component).csarUUID; + this.ModalsHandler.openOnboadrdingModal('Update', csarUUID).then(()=> { + // OK + this.$scope.uploadFileChangedInGeneralTab(); + }, ()=> { + // ERROR + }); + }; + + this.$scope.validateName = (isInit:boolean):void => { + if (isInit === undefined) { + isInit = false; + } + + let name = this.$scope.component.name; + if (!name || name === "") { + if (this.$scope.editForm + && this.$scope.editForm["componentName"] + && this.$scope.editForm["componentName"].$error) { + + // Clear the error name already exists + this.$scope.editForm["componentName"].$setValidity('nameExist', true); + } + + return; + } + //????????????????????????? + let subtype:string = ComponentType.RESOURCE == this.$scope.componentType ? this.$scope.component.getComponentSubType() : undefined; + + let onFailed = (response) => { + //console.info('onFaild', response); + //this.$scope.isLoading = false; + }; + + let onSuccess = (validation:IValidate) => { + this.$scope.editForm["componentName"].$setValidity('nameExist', validation.isValid); + if (validation.isValid) { + //update breadcrumb after changing name + this.updateComponentNameInBreadcrumbs(); + } + }; + + if (isInit) { + // When page is init after update + if (this.$scope.component.name !== this.$scope.originComponent.name) { + if (!(this.$scope.componentType === ComponentType.RESOURCE && (<Resource>this.$scope.component).csarUUID !== undefined) + ) { + this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); + } + } + } else { + // Validating on change (has debounce) + if (this.$scope.editForm + && this.$scope.editForm["componentName"] + && this.$scope.editForm["componentName"].$error + && !this.$scope.editForm["componentName"].$error.pattern + && (!this.$scope.originComponent.name || this.$scope.component.name.toUpperCase() !== this.$scope.originComponent.name.toUpperCase()) + ) { + if (!(this.$scope.componentType === ComponentType.RESOURCE && (<Resource>this.$scope.component).csarUUID !== undefined) + ) { + this.$scope.component.validateName(name, subtype).then(onSuccess, onFailed); + } + } else if (this.$scope.originComponent.name && this.$scope.component.name.toUpperCase() === this.$scope.originComponent.name.toUpperCase()) { + // Clear the error + this.$scope.editForm["componentName"].$setValidity('nameExist', true); + } + } + }; + + this.$scope.$watchCollection('component.name', (newData:any):void => { + this.$scope.validateName(false); + }); + + // Notify the parent if this step valid or not. + this.$scope.$watch("editForm.$valid", (newVal, oldVal) => { + this.$scope.setValidState(newVal); + }); + + this.$scope.$watch("editForm.$dirty", (newVal, oldVal) => { + if (newVal !== oldVal) { + this.$state.current.data.unsavedChanges = newVal && !this.$scope.isCreateMode(); + } + }); + + this.$scope.onCategoryChange = ():void => { + this.$scope.component.selectedCategory = this.$scope.componentCategories.selectedCategory; + this.$scope.component.categories = this.convertCategoryStringToOneArray(); + this.$scope.component.icon = DEFAULT_ICON; + }; + + this.$scope.onEcompGeneratedNamingChange = ():void =>{ + if(!(<Service>this.$scope.component).ecompGeneratedNaming){ + (<Service>this.$scope.component).namingPolicy = ''; + } + }; + + this.$scope.onVendorNameChange = (oldVendorName:string):void => { + if (this.$scope.component.icon === oldVendorName) { + this.$scope.component.icon = DEFAULT_ICON; + } + }; + }; +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general-view.html b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html index 1c1d4fedad..2ad0cbacd6 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html @@ -1,12 +1,12 @@ <div include-padding="true" class="sdc-workspace-general-step"> - <form novalidate class="w-sdc-form" name="editForm"> + <form novalidate class="w-sdc-form" name="editForm" validation-on-load form-to-validate="editForm"> <div class="w-sdc-form-section-container"> <!--------------------- IMPORT TOSCA FILE USING BROWSE (ALSO VFC) --------------------> <div class="i-sdc-form-item" ng-if="isShowFileBrowse"> - <label class="i-sdc-form-label required">{{browseFileLabel}}</label> + <label class="i-sdc-form-label" data-ng-class="{'required':isCreateMode()}">{{browseFileLabel}}</label> <file-upload id="fileUploadElement" class="i-sdc-form-input" element-name="fileElement" @@ -58,7 +58,7 @@ type="text" data-required data-ng-model-options="{ debounce: 500 }" - data-ng-pattern="validation.validationPattern" + data-ng-pattern="validation.componentNameValidationPattern" data-ng-disabled="component.isAlreadyCertified()" data-tests-id="name" autofocus @@ -70,7 +70,7 @@ <span ng-show="editForm.componentName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span> <span ng-show="editForm.componentName.$error.minlength" translate="VALIDATION_ERROR_MIN_LENGTH" translate-values="{'min': '4' }"></span> <span ng-show="editForm.componentName.$error.nameExist" translate="NEW_SERVICE_RESOURCE_ERROR_NAME_EXISTS"></span> - <span ng-show="editForm.componentName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + <span ng-show="editForm.componentName.$error.pattern" translate="VALIDATION_ERROR_INVALID_NAME"></span> </div> </div> <!--------------------- NAME --------------------> @@ -142,13 +142,13 @@ data-ng-class="{'view-mode': isViewMode()}" data-ng-change="onCategoryChange()" data-ng-disabled="component.isAlreadyCertified() || (component.isCsarComponent() && component.selectedCategory && component.selectedCategory!=='')" - data-ng-model="component.selectedCategory" + data-ng-model="componentCategories.selectedCategory" data-tests-id="selectGeneralCategory" > <option value="">Select category</option> <optgroup ng-if="component.isResource()" data-ng-repeat="mainCategory in categories | orderBy:['name']" label="{{mainCategory.name}}" data-tests-id="{{mainCategory.name}}"> <option data-ng-repeat="subCategory in mainCategory.subcategories track by $index" - data-ng-selected="component.selectedCategory === calculateUnique(mainCategory.name,subCategory.name)" + data-ng-selected="componentCategories.selectedCategory === calculateUnique(mainCategory.name,subCategory.name)" data-tests-id="{{subCategory.name}}" value="{{calculateUnique(mainCategory.name, subCategory.name)}}">{{subCategory.name}} @@ -174,11 +174,10 @@ data-ng-model="component.projectCode" data-ng-class="{'view-mode': isViewMode()}" data-ng-model-options="{ debounce: 500 }" - data-ng-maxlength="128" + maxlength="50" data-required name="projectCode" data-ng-pattern="validation.projectCodeValidationPattern" - maxlength="50" data-tests-id="projectCode" /> @@ -188,6 +187,54 @@ </div> </div> + + <!--------------------- ECOMPGENERATEDNAMING --------------------> + + <div class="i-sdc-form-item" + data-ng-class="{'error': validateField(editForm.ecompGeneratedNaming)}" + data-ng-if="component.isService()"> + <label class="i-sdc-form-label">Ecomp Generated Naming</label> + <select class="i-sdc-form-select" + data-required + name="ecompGeneratedNaming" + data-ng-change="onEcompGeneratedNamingChange()" + data-ng-class="{'view-mode': isViewMode()}" + data-ng-model="component.ecompGeneratedNaming" + data-tests-id="ecompGeneratedNaming"> + <option ng-value="true">true</option> + <option ng-value="false">false</option> + </select> + <div class="input-error" data-ng-show="validateField(editForm.ecompGeneratedNaming)"> + + </div> + </div> + <!--------------------- CATEGORIES --------------------> + + <!--------------------- NAMING POLICY --------------------> + <div ng-if="component.isService()" class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.namingPolicy)}"> + <label class="i-sdc-form-label">Naming policy</label> + <input class="i-sdc-form-input" + name="fullName" + data-ng-class="{'view-mode': isViewMode() || !component.ecompGeneratedNaming}" + data-ng-maxlength="100" + maxlength="100" + data-ng-model="component.namingPolicy" + type="text" + data-ng-model-options="{ debounce: 500 }" + data-ng-pattern="validation.commentValidationPattern" + data-tests-id="namingPolicy" + autofocus + ng-readonly="isViewMode() || !component.ecompGeneratedNaming" + /> + + <div class="input-error" data-ng-show="validateField(editForm.namingPolicy)"> + <span ng-show="editForm.namingPolicy.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '100' }"></span> + <span ng-show="editForm.namingPolicy.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span> + </div> + </div> + <!--------------------- NAMING POLICY --------------------> + + <!--------------------- VENDOR NAME --------------------> <div ng-if="component.isResource()" class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.vendorName)}"> <label class="i-sdc-form-label required">Vendor</label> @@ -265,7 +312,7 @@ </div> <!--------------------- RESOURCE TAGS --------------------> - <!--------------------- CONTACT ID --------------------> + <!--------------------- USER ID --------------------> <div class="i-sdc-form-item" data-ng-class="{'error': validateField(editForm.contactId)}"> <label class="i-sdc-form-label " data-ng-class="{'required':!component.isProduct()}" translate="GENERAL_LABEL_CONTACT_ID"></label> <input class="i-sdc-form-input" type="text" data-ng-if="!component.isProduct()" @@ -275,7 +322,7 @@ name="contactId" data-ng-pattern="validation.contactIdValidationPattern" data-ng-model-options="{ debounce: 500 }" - data-tests-id="userId" + data-tests-id="contactId" maxlength="50" /> <input class="i-sdc-form-input" type="text" data-ng-if="component.isProduct()" @@ -285,7 +332,7 @@ name="contactId" data-ng-pattern="validation.contactIdValidationPattern" data-ng-model-options="{ debounce: 500 }" - data-tests-id="userId" + data-tests-id="contactId" maxlength="50" /> @@ -294,7 +341,7 @@ <span ng-show="editForm.contactId.$error.pattern" translate="NEW_SERVICE_RESOURCE_ERROR_CONTACT_NOT_VALID"></span> </div> </div> - <!--------------------- CONTACT ID --------------------> + <!--------------------- USER ID --------------------> </div><!-- Close w-sdc-form-column --> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general.less b/catalog-ui/src/app/view-models/workspace/tabs/general/general.less index 1861d02e98..1861d02e98 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/general/general.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/icons/icons-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons-view-model.ts new file mode 100644 index 0000000000..03dad2cc06 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons-view-model.ts @@ -0,0 +1,111 @@ +/** + * Created by obarda on 4/4/2016. + */ +'use strict'; +import {ComponentFactory} from "app/utils"; +import {AvailableIconsService} from "app/services"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {IMainCategory, ISubCategory} from "app/models"; + +export interface IIconsScope extends IWorkspaceViewModelScope { + icons:Array<string>; + iconSprite:string; + setComponentIcon(iconSrc:string):void; +} + +export class IconsViewModel { + + static '$inject' = [ + '$scope', + 'Sdc.Services.AvailableIconsService', + 'ComponentFactory', + '$state' + ]; + + constructor(private $scope:IIconsScope, + private availableIconsService:AvailableIconsService, + private ComponentFactory:ComponentFactory, + private $state:ng.ui.IStateService) { + + + this.initScope(); + this.initIcons(); + this.$scope.updateSelectedMenuItem(); + this.$scope.iconSprite = this.$scope.component.iconSprite; + + if (this.$scope.component.isResource()) { + this.initVendor(); + } + } + + private initialIcon:string = this.$scope.component.icon; + private initIcons = ():void => { + + // For subcategories that where created by admin, there is no icons + this.$scope.icons = new Array<string>(); + if (this.$scope.component.categories && this.$scope.component.categories.length > 0) { + + _.forEach(this.$scope.component.categories, (category:IMainCategory):void => { + if (category.icons) { + this.$scope.icons = this.$scope.icons.concat(category.icons); + } + if (category.subcategories) { + _.forEach(category.subcategories, (subcategory:ISubCategory):void => { + if (subcategory.icons) { + this.$scope.icons = this.$scope.icons.concat(subcategory.icons); + } + }); + } + }); + } + + if (this.$scope.component.isResource()) { + let resourceType:string = this.$scope.component.getComponentSubType(); + if (resourceType === 'VL') { + this.$scope.icons = ['vl']; + } + if (resourceType === 'CP') { + this.$scope.icons = ['cp']; + } + } + + if (this.$scope.icons.length === 0) { + this.$scope.icons = this.availableIconsService.getIcons(this.$scope.component.componentType); + } + //we always add the defual icon to the list + this.$scope.icons.push('defaulticon'); + }; + + private initVendor = ():void => { + let vendors:Array<string> = this.availableIconsService.getIcons(this.$scope.component.componentType).slice(5, 19); + let vendorName = this.$scope.component.vendorName.toLowerCase(); + if ('at&t' === vendorName) { + vendorName = 'att'; + } + if ('nokia' === vendorName) { + vendorName = 'nokiasiemens'; + } + let vendor:string = _.find(vendors, (vendor:string)=> { + return vendor.replace(/[_]/g, '').toLowerCase() === vendorName; + }); + + if (vendor && this.$scope.icons.indexOf(vendor) === -1) { + this.$scope.icons.push(vendor); + } + }; + + private initScope():void { + this.$scope.icons = []; + this.$scope.setValidState(true); + //if(this.$scope.component.icon === DEFAULT_ICON){ + // //this.$scope.setValidState(false); + //} + + this.$scope.setComponentIcon = (iconSrc:string):void => { + this.$state.current.data.unsavedChanges = !this.$scope.isViewMode() && (iconSrc != this.initialIcon); + this.$scope.component.icon = iconSrc; + // this.$scope.setValidState(true); + }; + + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons-view.html b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons-view.html index aac14e0e84..aac14e0e84 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons-view.html diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons.less b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons.less index 65f946f395..65f946f395 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/icons/icons.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/icons/icons.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts new file mode 100644 index 0000000000..e10a9944d3 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view-model.ts @@ -0,0 +1,138 @@ +'use strict'; +import {ModalsHandler} from "app/utils"; +import {SharingService} from "app/services"; +import {IAppConfigurtaion, ArtifactModel, IFileDownload} from "app/models"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; +import {ArtifactGroupModel} from "../../../../models/artifacts"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; + +export interface IInformationArtifactsScope extends IWorkspaceViewModelScope { + artifacts:Array<ArtifactModel>; + tableHeadersList:Array<any>; + artifactType:string; + isResourceInstance:boolean; + downloadFile:IFileDownload; + isLoading:boolean; + sortBy:string; + reverse:boolean; + + getTitle():string; + addOrUpdate(artifact:ArtifactModel):void; + delete(artifact:ArtifactModel):void; + download(artifact:ArtifactModel):void; + clickArtifactName(artifact:any):void; + openEditEnvParametersModal(artifactResource:ArtifactModel):void; + sort(sortBy:string):void; + showNoArtifactMessage():boolean; +} + +export class InformationArtifactsViewModel { + + static '$inject' = [ + '$scope', + '$filter', + '$state', + 'sdcConfig', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:IInformationArtifactsScope, + private $filter:ng.IFilterService, + private $state:any, + private sdcConfig:IAppConfigurtaion, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2: ComponentServiceNg2) { + this.initInformationalArtifacts(); + this.$scope.updateSelectedMenuItem(); + } + + private initInformationalArtifacts = ():void => { + if(!this.$scope.component.artifacts) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentInformationalArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.artifacts = response.artifacts; + this.initScope(); + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + + private initScope = ():void => { + + this.$scope.isLoading = false; + this.$scope.sortBy = 'artifactDisplayName'; + this.$scope.reverse = false; + this.$scope.setValidState(true); + this.$scope.artifactType = 'informational'; + this.$scope.getTitle = ():string => { + return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts'; + + }; + + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'artifactDisplayName'}, + {title: 'Type', property: 'artifactType'}, + {title: 'Version', property: 'artifactVersion'}, + {title: 'UUID', property: 'artifactUUID'} + ]; + + this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + + this.$scope.addOrUpdate = (artifact:ArtifactModel):void => { + artifact.artifactGroupType = 'INFORMATIONAL'; + this.ModalsHandler.openArtifactModal(artifact, this.$scope.component).then(() => { + this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); + }); + }; + + this.$scope.showNoArtifactMessage = ():boolean => { + let artifacts:any = []; + artifacts = _.filter(this.$scope.artifacts, (artifact:ArtifactModel)=> { + return artifact.esId; + }); + + if (artifacts.length === 0) { + return true; + } + return false; + }; + + this.$scope.delete = (artifact:ArtifactModel):void => { + + let onOk = ():void => { + this.$scope.isLoading = true; + let onSuccess = ():void => { + this.$scope.isLoading = false; + this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.artifacts); + }; + + let onFailed = (error:any):void => { + console.log('Delete artifact returned error:', error); + this.$scope.isLoading = false; + }; + + this.$scope.component.deleteArtifact(artifact.uniqueId, artifact.artifactLabel).then(onSuccess, onFailed); + }; + + let title:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("ARTIFACT_VIEW_DELETE_MODAL_TEXT", "{'name': '" + artifact.artifactDisplayName + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + + this.$scope.clickArtifactName = (artifact:any) => { + if (!artifact.esId) { + this.$scope.addOrUpdate(artifact); + } + + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view.html b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view.html index 790117b2fd..7c843e9fe8 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts-view.html @@ -20,15 +20,24 @@ data-ng-class="{'selected': artifact.selected}" data-ng-if="artifact.esId"> - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected"> - <span class="sprite table-arrow" data-ng-class="{'opened': artifact.selected}" data-tests-id="{{artifact.artifactDisplayName}}"></span> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="artifactDisplayName_{{artifact.artifactDisplayName}}"> + <span class="sprite table-arrow" data-ng-class="{'opened': artifact.selected}" data-tests-id="artifact_arrow_{{artifact.artifactDisplayName}}"></span> {{artifact.artifactDisplayName}} </div> - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="{{artifact.artifactType}}"> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="artifactType_{{artifact.artifactDisplayName}}"> {{artifact.artifactType}} </div> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="artifactVersion_{{artifact.artifactDisplayName}}"> + {{artifact.artifactVersion}} + </div> + + <div class="table-col-general flex-item text" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="artifactUUID_{{artifact.artifactDisplayName}}" + tooltips tooltip-content="{{artifact.artifactUUID}}"> + <span>{{artifact.artifactUUID}}</span> + </div> + <div class="table-btn-col flex-item"> <button class="table-edit-btn" data-tests-id="edit_{{artifact.artifactDisplayName}}" data-ng-if="!isViewMode() && !artifact.isThirdParty()" data-ng-click="addOrUpdate(artifact)" data-ng-class="{'disabled': isDisableMode()}"></button> <button class="table-delete-btn" data-tests-id="delete_{{artifact.artifactDisplayName}}" data-ng-if="!isViewMode() && !artifact.isThirdParty()" data-ng-click="delete(artifact)" data-ng-class="{'disabled': isDisableMode()}"> </button> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts.less b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts.less index d3fe14d945..3ba9cf47d5 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/information-artifacts/information-artifacts.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/information-artifacts/information-artifacts.less @@ -18,6 +18,12 @@ word-wrap: break-word; } + .text{ + overflow: hidden; + text-overflow: ellipsis; + display: inline-block; + white-space: nowrap; + } .flex-item:nth-child(1) { flex-grow: 15; @@ -33,11 +39,15 @@ .flex-item:nth-child(3) { flex-grow: 3; - padding-top: 10px; } .flex-item:nth-child(4) { - flex-grow: 1; + flex-grow: 20; + } + + .flex-item:nth-child(5) { + flex-grow: 5; + padding-top: 10px; } } diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/inputs.less b/catalog-ui/src/app/view-models/workspace/tabs/inputs/inputs.less index 76a82c69ee..eff5c5395b 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/inputs.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/inputs.less @@ -1,23 +1,35 @@ .workspace-inputs { .sdc-workspace-container .w-sdc-main-right-container .w-sdc-main-container-body-content { - padding: 25px 8% 0px 8%; + padding: 25px 8% 25px 8%; } + .w-sdc-main-container .w-sdc-main-right-container > div:first-child { + /* scroll fix */ + padding-bottom: 0px; + } + + width: 100%; display: flex; .text { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; padding-left: 15px; + .no-overflow; } .title-text { color: @main_color_m; .f-type._13_m; .bold; + text-overflow: ellipsis; + overflow: hidden; + } + + .no-overflow { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; } .title-blue-text { @@ -28,6 +40,7 @@ padding-right: 13px; border-right: 1px solid rgba(120, 136, 148, 0.26); flex-grow: 1; + .no-overflow; } } @@ -106,25 +119,6 @@ } - .property-row { - border-bottom: 1px solid @border_color_d; - padding-left: 10px; - .property-name-container { - display: flex; - flex-grow: 4; - } - - .type-schema-container { - flex-grow: 1; - border-left: 1px solid @border_color_d; - text-align: left; - line-height: 30px; - text-transform: capitalize; - width: 10px; - } - - } - .table-container-flex { .flex-item { @@ -132,15 +126,6 @@ } .expand-collapse-table-row { - &.expanded { - .flex-container { - .expand-collapse-inputs-table-icon { - transform: rotate(180deg); - left: 0px; - } - } - } - .data-row { background: @tlv_color_u; .hand; @@ -153,48 +138,6 @@ .data-row:hover { .bg_j; } - - .input-row { - padding-left: 45px; - background: @tlv_color_t; - border: @main_color_o solid 1px; - align-items: center; - .hand; - margin: 1px 0px 1px 0px; - - &.service-input-row { - background: @tlv_color_u; - &.new-input { - background: @tlv_color_v; - } - } - &.selected { - background-color: @tlv_color_v; - } - .flex-item { - min-height: 60px; - padding: 0 15px; - } - .input-check-box { - padding-right: 10px; - margin-top: 9px; - } - &>.title-text{ - text-align: start; - padding: 4px 0 0 35px; - } - - .expand-collapse-inputs-table-icon{ - margin-top: 15px; - } - - } - - .input-row:hover { - .bg_j; - } - - } } @@ -224,10 +167,6 @@ background-color: #e6e6e6; } - .property-row:hover{ - background-color: @func_color_r; - } - .body { .scrollbar-container { .perfect-scrollbar; diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts new file mode 100644 index 0000000000..49fedd6e21 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view-model.ts @@ -0,0 +1,117 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ComponentInstance, InstancesInputsOrPropertiesMapData, Resource, PropertyModel, InputModel} from "app/models"; +import {ModalsHandler} from "app/utils"; + +export interface IInputsViewModelScope extends IWorkspaceViewModelScope { + InstanceInputsProperties:InstancesInputsOrPropertiesMapData; //this is tha map object that hold the selected inputs and the inputs we already used + vfInstancesList:Array<ComponentInstance>; + component:Resource; + + onArrowPressed():void; + getInputPropertiesForInstance(instanceId:string, instance:ComponentInstance):ng.IPromise<boolean> ; + loadInputPropertiesForInstance(instanceId:string, input:InputModel):ng.IPromise<boolean> ; + openEditValueModal(input:InputModel):void; + openEditPropertyModal(property:PropertyModel):void; +} + +export class ResourceInputsViewModel { + + static '$inject' = [ + '$scope', + '$q', + 'ModalsHandler' + ]; + + constructor(private $scope:IInputsViewModelScope, private $q:ng.IQService, private ModalsHandler:ModalsHandler) { + this.initScope(); + this.$scope.updateSelectedMenuItem(); + } + + private initScope = ():void => { + + this.$scope.InstanceInputsProperties = new InstancesInputsOrPropertiesMapData(); + this.$scope.vfInstancesList = this.$scope.component.componentInstances; + + // Need to cast all inputs to InputModel for the search to work + let tmpInputs:Array<InputModel> = new Array<InputModel>(); + _.each(this.$scope.component.inputs, (input):void => { + tmpInputs.push(new InputModel(input)); + }); + this.$scope.component.inputs = tmpInputs; + // This function is not supported for resource + //this.$scope.component.getComponentInputs(); + + /* + * When clicking on instance input in the left or right table, this function will load all properties of the selected input + */ + this.$scope.getInputPropertiesForInstance = (instanceId:string, instance:ComponentInstance):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + instance.properties = this.$scope.component.componentInstancesProperties[instanceId]; + deferred.resolve(true); + return deferred.promise; + }; + + /* + * When clicking on instance input in the left or right table, this function will load all properties of the selected input + */ + this.$scope.loadInputPropertiesForInstance = (instanceId:string, input:InputModel):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + + let onSuccess = (properties:Array<PropertyModel>) => { + input.properties = properties; + deferred.resolve(true); + }; + + let onError = () => { + deferred.resolve(false) + }; + + if (!input.properties) { + this.$scope.component.getComponentInstanceInputProperties(instanceId, input.uniqueId).then(onSuccess, onError); + } else { + deferred.resolve(true); + } + return deferred.promise; + }; + + /* + * When pressing the arrow, we create service inputs from the inputs selected + */ + this.$scope.onArrowPressed = ():void => { + let onSuccess = (inputsCreated:Array<InputModel>) => { + + //disabled all the inputs in the left table + _.forEach(this.$scope.InstanceInputsProperties, (properties:Array<PropertyModel>) => { + _.forEach(properties, (property:PropertyModel) => { + property.isAlreadySelected = true; + }); + }); + + // Adding color to the new inputs (right table) + _.forEach(inputsCreated, (input) => { + input.isNew = true; + }); + + // Removing color to the new inputs (right table) + setTimeout(() => { + _.forEach(inputsCreated, (input) => { + input.isNew = false; + }); + this.$scope.$apply(); + }, 3000); + }; + + this.$scope.component.createInputsFormInstances(this.$scope.InstanceInputsProperties).then(onSuccess); + }; + + this.$scope.openEditValueModal = (input:InputModel) => { + this.ModalsHandler.openEditInputValueModal(input); + }; + + this.$scope.openEditPropertyModal = (property:PropertyModel):void => { + this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.component.componentInstancesProperties[property.resourceInstanceUniqueId], false).then(() => { + }); + } + } +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html new file mode 100644 index 0000000000..a0715973ab --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs-view.html @@ -0,0 +1,86 @@ +<div class="workspace-inputs"> + <div class="table-container-flex"> + <div class="w-sdc-inputs-search pull-left hideme"> + <input type="text" class="w-sdc-inputs-search-input" placeholder="Search"/> + <div class="search-icon-container"> + <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> + </div> + </div> + <div class="table"> + <div class="table-header">VFC instances inputs</div> + <div class="body"> + <div class="table-loader" ng-class="{'tlv-loader large loader': isLoading}"></div> + <perfect-scrollbar scroll-y-margin-offset="0" class="scrollbar-container"> + + <expand-collapse expanded-selector=".vf-instance-list.{{$index}}" + class="expand-collapse-table-row" + load-data-function="getInputPropertiesForInstance(instance.uniqueId, instance)" + is-close-on-init="true" + data-ng-repeat-start="instance in vfInstancesList track by $index"> + <div class="flex-container data-row" data-tests-id="input-instance-{{$index}}"> + <div class="expand-collapse-inputs-table-icon"></div> + <div class="table-col-general flex-item text"> + <span class="title-text">{{instance.name}}</span> + </div> + </div> + + </expand-collapse> + + <div data-ng-repeat-end="" class="vf-instance-list {{$index}}"> + <div class="empty-row" data-tests-id="empty-row" ng-if="instance.properties.length===0">No properties to display </div> + <div ng-repeat="property in instance.properties track by $index"> + <property-row property="property" instance-name="instance.name" on-name-clicked="openEditPropertyModal(property)"></property-row> + </div> + + </div> + + </perfect-scrollbar> + </div> + </div> + </div> + + <div class="inputs-button-container pull-left"> + <!--<div ng-click="onArrowPressed()" class="right-arrow-btn"></div>--> + </div> + + <div class="table-container-flex"> + <div class="w-sdc-inputs-search pull-left"> + <input type="text" class="w-sdc-inputs-search-input" data-ng-model="search.filterTerm" placeholder="Search" + data-ng-model-options="{debounce: 200}"/> + <div class="search-icon-container"> + <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> + </div> + </div> + <div class="table"> + <div class="body"> + <div class="table-header">VF inputs</div> + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <expand-collapse expanded-selector=".resource-inputs.{{$index}}" + class="expand-collapse-table-row" + load-data-function="loadInputPropertiesForInstance(resourceInput.uniqueId, resourceInput)" + is-close-on-init="true" + data-ng-repeat-start="resourceInput in component.inputs | filter:search track by $index "> + <div class="input-row service-input-row"> + <input-row input="resourceInput" is-view-only='isViewOnly' + instance-name='resourceInput.name' + data-tests-id="resource-input-{{$index}}" + class="service-input-row" + on-name-clicked="openEditValueModal(resourceInput)" + ng-class="resourceInput.isNew ? 'new-input': ''"> + + </input-row> + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="input-inputs-list resource-inputs {{$index}}"> + <div class="empty-row" ng-if="resourceInput.properties.length===0">No properties to display </div> + <div ng-repeat="property in resourceInput.properties track by $index"> + <property-row property="property" instance-name="property.name"></property-row> + </div> + </div> + + </perfect-scrollbar> + </div> + </div> + </div> +</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less index ebb32fbdb2..ebb32fbdb2 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts new file mode 100644 index 0000000000..f3b2de0943 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view-model.ts @@ -0,0 +1,378 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ComponentInstance, InstancesInputsOrPropertiesMapData, Service, IAppMenu, InputModel, PropertyModel, InputPropertyBase} from "app/models"; +import {DataTypesService} from "app/services"; +import {ModalsHandler, ResourceType} from "app/utils"; + + +interface IServiceInputsViewModelScope extends IWorkspaceViewModelScope { + + vfInstancesList:Array<ComponentInstance>; + instanceInputsMap:InstancesInputsOrPropertiesMapData; //this is tha map object that hold the selected inputs and the inputs we already used + instancePropertiesMap:InstancesInputsOrPropertiesMapData; + component:Service; + sdcMenu:IAppMenu; + isViewOnly:boolean; + isArrowDisabled:boolean; + onArrowPressed():void; + checkArrowState():void; + loadComponentInputs():void; + loadInstanceInputs(instance:ComponentInstance):ng.IPromise<boolean> ; + loadInstanceProperties(instance:ComponentInstance):ng.IPromise<boolean> ; + loadInputPropertiesForInstance(instanceId:string, input:InputModel):ng.IPromise<boolean> ; + loadInputInputs(input:InputModel):ng.IPromise<boolean>; + deleteInput(input:InputModel):void + openEditValueModal(input:InputModel):void; + openSelectPropertyDataTypeViewModel(instanceId:string, property:PropertyModel):void; + openEditPropertyDataTypeViewModel(property:PropertyModel):void; + dataTypesService:DataTypesService; +} + +export class ServiceInputsViewModel { + + static '$inject' = [ + '$scope', + '$q', + 'ModalsHandler', + 'Sdc.Services.DataTypesService' + ]; + + constructor(private $scope:IServiceInputsViewModelScope, + private $q:ng.IQService, + private ModalsHandler:ModalsHandler, + private DataTypesService:DataTypesService) { + this.initScope(); + this.$scope.updateSelectedMenuItem(); + this.$scope.isViewOnly = this.$scope.isViewMode(); + } + + + private getInputsOrPropertiesAlreadySelected = (instanceNormalizeName:string, arrayToFilter:Array<InputPropertyBase>):Array<any> => { + let alreadySelectedInput = []; + _.forEach(arrayToFilter, (inputOrProperty:InputPropertyBase) => { + let expectedServiceInputName = instanceNormalizeName + '_' + inputOrProperty.name; + let inputAlreadyInService = _.find(this.$scope.component.inputs, (serviceInput:InputModel) => { + //Checking if the input prefix is the instance name + '_' + property/input name (prefix because we don't need to check full name for complex dataType) + return serviceInput.name.substring(0, expectedServiceInputName.length) === expectedServiceInputName; + }); + if (inputAlreadyInService) { + inputOrProperty.isAlreadySelected = true; + alreadySelectedInput.push(inputOrProperty); + } else { + inputOrProperty.isAlreadySelected = false; + } + }); + return alreadySelectedInput; + }; + + + /* + * When loading the screen again, we need to disabled the inputs that already created on the service, + * we do that by comparing the service input name, to the instance name + '_' + the resource instance input name. + */ + private disableEnableSelectedInputsOrPropertiesOnInit = (instance:ComponentInstance):void => { + + if (instance.originType === ResourceType.VF) { + this.$scope.instanceInputsMap[instance.uniqueId] = this.getInputsOrPropertiesAlreadySelected(instance.normalizedName, instance.inputs); + } else { + this.$scope.instancePropertiesMap[instance.uniqueId] = this.getInputsOrPropertiesAlreadySelected(instance.normalizedName, instance.properties); + } + }; + + /* + * Enable Input/Property after delete + */ + private enableInputsAfterDelete = (propertiesOrInputsDeletes:Array<InputPropertyBase>):void => { + + _.forEach(propertiesOrInputsDeletes, (deletedInputInput:InputPropertyBase) => { //Enable all component instance inputs deleted + + let inputOrPropertyDeleted:InputPropertyBase = _.find(this.$scope.instanceInputsMap[deletedInputInput.componentInstanceId], (inputOrProperty:InputPropertyBase) => { + return inputOrProperty.uniqueId === deletedInputInput.uniqueId; + }); + inputOrPropertyDeleted.isAlreadySelected = false; + delete _.remove(this.$scope.instanceInputsMap[deletedInputInput.componentInstanceId], {uniqueId: inputOrPropertyDeleted.uniqueId})[0]; + }); + }; + + /* + * Enable Input/Property after delete + */ + private enablePropertiesAfterDelete = (propertiesOrInputsDeletes:Array<InputPropertyBase>):void => { + + _.forEach(propertiesOrInputsDeletes, (deletedInputInput:InputPropertyBase) => { //Enable all component instance inputs deleted + let componentInstance = _.find(this.$scope.vfInstancesList, (instance:ComponentInstance) => { + return instance.uniqueId === deletedInputInput.componentInstanceId; + }); + let inputOrPropertyDeleted:InputPropertyBase = _.find(this.$scope.instancePropertiesMap[deletedInputInput.componentInstanceId], (inputOrProperty:InputPropertyBase) => { + return inputOrProperty.uniqueId === deletedInputInput.uniqueId; + }); + + let expectedName = componentInstance.normalizedName + '_' + inputOrPropertyDeleted.name; + let isAnotherInputExist = _.find(this.$scope.component.inputs, (input:InputModel) => { + return input.name.substring(0, expectedName.length) === expectedName; + }); + if (!isAnotherInputExist) { + inputOrPropertyDeleted.isAlreadySelected = false; + delete _.remove(this.$scope.instancePropertiesMap[deletedInputInput.componentInstanceId], {uniqueId: inputOrPropertyDeleted.uniqueId})[0]; + } + }); + }; + + private initScope = ():void => { + + this.$scope.instanceInputsMap = new InstancesInputsOrPropertiesMapData(); + this.$scope.instancePropertiesMap = new InstancesInputsOrPropertiesMapData(); + this.$scope.isLoading = true; + this.$scope.isArrowDisabled = true; + // Why do we need this? we call this later. + //this.$scope.component.getComponentInputs(); + + let onSuccess = (componentInstances:Array<ComponentInstance>) => { + console.log("component instances loaded: ", componentInstances); + this.$scope.vfInstancesList = componentInstances; + this.$scope.isLoading = false; + }; + + //This function will get al component instance for the left table - in + // future the instances will be filter according to search text + this.$scope.component.getComponentInstancesFilteredByInputsAndProperties().then(onSuccess); + + // This function will get the service inputs for the right table + this.$scope.component.getComponentInputs(); + + /* + * When clicking on instance in the left table, this function will load all instance inputs + */ + this.$scope.loadInstanceInputs = (instance:ComponentInstance):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + + let onSuccess = (inputs:Array<InputModel>) => { + instance.inputs = inputs; + this.disableEnableSelectedInputsOrPropertiesOnInit(instance); + deferred.resolve(true); + }; + + let onError = () => { + deferred.resolve(false); + }; + + if (!instance.inputs) { + this.$scope.component.getComponentInstanceInputs(instance.uniqueId, instance.componentUid).then(onSuccess, onError); + //this.disableEnableSelectedInputs(instance); + } else { + deferred.resolve(true); + } + return deferred.promise; + }; + + + this.$scope.loadInstanceProperties = (instance:ComponentInstance):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + + let onSuccess = (properties:Array<PropertyModel>) => { + instance.properties = properties; + this.disableEnableSelectedInputsOrPropertiesOnInit(instance); + deferred.resolve(true); + }; + + let onError = () => { + deferred.resolve(false); + }; + + if (!instance.properties) { + this.$scope.component.getComponentInstanceProperties(instance.uniqueId).then(onSuccess, onError); + } else { + deferred.resolve(true); + } + return deferred.promise; + }; + + /* + * When clicking on instance input in the left or right table, this function will load all properties of the selected input + */ + this.$scope.loadInputPropertiesForInstance = (instanceId:string, input:InputModel):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + + let onSuccess = (properties:Array<PropertyModel>) => { + input.properties = properties; + deferred.resolve(true); + }; + + let onError = () => { + deferred.resolve(false) + }; + + if (!input.properties) { + this.$scope.component.getComponentInstanceInputProperties(instanceId, input.uniqueId).then(onSuccess, onError); + } else { + deferred.resolve(true); + } + return deferred.promise; + }; + + /* + * When clicking on input in the right table, this function will load all inputs of the selected input + */ + this.$scope.loadInputInputs = (input:InputModel):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + + let onSuccess = () => { + deferred.resolve(true); + }; + let onError = () => { + deferred.resolve(false); + }; + + if (!input.inputs) { // Caching, if exists do not get it. + this.$scope.component.getServiceInputInputsAndProperties(input.uniqueId).then(onSuccess, onError); + } else { + deferred.resolve(true); + } + return deferred.promise; + }; + + /* + * When pressing the arrow, we create service inputs from the inputs selected + */ + this.$scope.onArrowPressed = ():void => { + let onSuccess = (inputsCreated:Array<InputModel>) => { + + //disabled all the inputs in the left table + _.forEach(this.$scope.instanceInputsMap, (inputs:Array<InputModel>, instanceId:string) => { + _.forEach(inputs, (input:InputModel) => { + input.isAlreadySelected = true; + }); + }); + _.forEach(this.$scope.instancePropertiesMap, (properties:Array<PropertyModel>, instanceId:string) => { + _.forEach(properties, (property:PropertyModel) => { + property.isAlreadySelected = true; + }); + }); + this.addColorToItems(inputsCreated); + }; + + let onFailed = (error:any) => { + this.$scope.isArrowDisabled = false; + console.log("Error declaring input/property"); + }; + + this.$scope.isArrowDisabled = true; + this.$scope.component.createInputsFormInstances(this.$scope.instanceInputsMap, this.$scope.instancePropertiesMap).then(onSuccess, onFailed); + }; + + + /* Iterates through array of selected inputs and properties and returns true if there is at least one new selection on left */ + this.$scope.checkArrowState = ()=> { + + let newInputSelected:boolean = _.some(this.$scope.instanceInputsMap, (inputs:Array<InputModel>) => { + return _.some(inputs, (input:InputModel)=> { + return input.isAlreadySelected === false; + }); + }); + + let newPropSelected:boolean = _.some(this.$scope.instancePropertiesMap, (properties:Array<PropertyModel>) => { + return _.some(properties, (property:PropertyModel) => { + return property.isAlreadySelected === false; + }); + }); + + this.$scope.isArrowDisabled = !(newInputSelected || newPropSelected); + + }; + + this.$scope.deleteInput = (inputToDelete:InputModel):void => { + + let onDelete = ():void => { + + let onSuccess = (deletedInput:InputModel):void => { + if (deletedInput.inputs && deletedInput.inputs.length > 0) { // Enable input declared from input + this.enableInputsAfterDelete(deletedInput.inputs); + } + + if (deletedInput.properties && deletedInput.properties.length > 0) { // Enable properties + this.enablePropertiesAfterDelete(deletedInput.properties); + } + deletedInput.isDeleteDisabled = false; + this.$scope.checkArrowState(); + + }; + + let onFailed = (error:any):void => { + console.log("Error deleting input"); + inputToDelete.isDeleteDisabled = false; + }; + + inputToDelete.isDeleteDisabled = true; + this.addColorToItems([inputToDelete]); + this.$scope.component.deleteServiceInput(inputToDelete.uniqueId).then((deletedInput:InputModel):void => { + onSuccess(deletedInput); + }, onFailed); + }; + + // Get confirmation modal text from menu.json + let state = "deleteInput"; + let title:string = this.$scope.sdcMenu.alertMessages[state].title; + let message:string = this.$scope.sdcMenu.alertMessages[state].message.format([inputToDelete.name]); + + // Open confirmation modal + this.ModalsHandler.openAlertModal(title, message).then(onDelete); + }; + + this.$scope.openEditValueModal = (input:InputModel) => { + this.ModalsHandler.openEditInputValueModal(input); + }; + + this.$scope.openSelectPropertyDataTypeViewModel = (instanceId:string, property:PropertyModel) => { + //to open the select data type modal + let selectedInstance = _.find(this.$scope.vfInstancesList, {uniqueId: instanceId}); + this.DataTypesService.selectedInstance = selectedInstance; //set the selected instance on the service for compering the input name on the service & the complex property + this.DataTypesService.selectedComponentInputs = this.$scope.component.inputs; // set all the service inputs on the data type service + let filteredPropertiesMap = _.filter(this.$scope.instancePropertiesMap[instanceId], (instanceProperty)=> { + return instanceProperty.name == property.name; + });//get all properties under the specific property + this.DataTypesService.selectedPropertiesName = property.propertiesName; + + this.ModalsHandler.openSelectDataTypeModal(property, this.$scope.component, this.$scope.component.properties, filteredPropertiesMap).then((selectedProperty:PropertyModel)=> { + if (selectedProperty && selectedProperty.propertiesName) { + let propertyToUpdate:PropertyModel = _.find(selectedInstance.properties, {uniqueId: selectedProperty.uniqueId}); + let existingProperty:PropertyModel = (<PropertyModel>_.find(this.$scope.instancePropertiesMap[instanceId], {uniqueId: propertyToUpdate.uniqueId})); + + if (existingProperty) { + existingProperty.propertiesName = selectedProperty.propertiesName; + existingProperty.input = selectedProperty.input; + existingProperty.isAlreadySelected = false; + } else { + propertyToUpdate.propertiesName = selectedProperty.propertiesName; + propertyToUpdate.input = selectedProperty.input; + this.$scope.instancePropertiesMap[instanceId].push(propertyToUpdate); + + } + this.$scope.checkArrowState(); + + } + }); + }; + + + this.$scope.openEditPropertyDataTypeViewModel = (property:PropertyModel)=> { + this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.component.properties, false).then(() => { + }); + } + }; + + private addColorToItems = (inputsCreated:Array<InputModel>):void => { + + // Adding color to the new inputs (right table) + _.forEach(inputsCreated, (input) => { + input.isNew = true; + }); + + // Removing color to the new inputs (right table) + setTimeout(() => { + _.forEach(inputsCreated, (input) => { + input.isNew = false; + }); + this.$scope.$apply(); + }, 3000); + }; +} diff --git a/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html new file mode 100644 index 0000000000..cb4d853f58 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs-view.html @@ -0,0 +1,134 @@ +<div class="workspace-inputs"> + <div class="table-container-flex"> + <div class="w-sdc-inputs-search pull-left hideme"> + <input type="text" class="w-sdc-inputs-search-input" placeholder="Search"/> + <div class="search-icon-container"> + <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> + </div> + </div> + <div class="table"> + <div class="table-header">Resource instance inputs</div> + <div class="body"> + <div class="table-loader" ng-class="{'tlv-loader large loader': isLoading}"></div> + <perfect-scrollbar scroll-y-margin-offset="0" class="scrollbar-container"> + + <expand-collapse expanded-selector=".vf-instance-list.{{$index}}" + class="expand-collapse-table-row" + load-data-function="instance.originType=='VF' ? loadInstanceInputs(instance):loadInstanceProperties(instance)" + is-close-on-init="true" + data-ng-repeat-start="instance in vfInstancesList track by $index"> + <div class="flex-container data-row"> + <div class="expand-collapse-inputs-table-icon"></div> + <div class="table-col-general flex-item text" data-tests-id="inputs-vf-instance-{{$index}}"> + <span class="title-text">{{instance.name}}</span> + </div> + </div> + </expand-collapse> + + <div data-ng-repeat-end="" class="vf-instance-list {{$index}}"> + <div data-ng-if="instance.originType=='VF'"> + + <expand-collapse expanded-selector=".input-list.{{$parent.$index}}-{{$index}}" + class="expand-collapse-table-row" + load-data-function="loadInputPropertiesForInstance(instance.uniqueId, input)" + is-close-on-init="true" + data-ng-repeat-start="input in instance.inputs track by $index"> + <input-row input="input" + is-view-only='isViewOnly' + instance-id='instance.uniqueId' + instance-name='instance.name' + instance-inputs-map="instanceInputsMap" + on-checkbox-clicked="checkArrowState()"></input-row> + </expand-collapse> + + <div data-ng-repeat-end="" class="input-list {{$parent.$index}}-{{$index}}"> + <div class="empty-row" ng-if="input.properties.length===0">No properties to display + </div> + <div ng-repeat="property in input.properties track by $index"> + <property-row property="property" instance-name="instance.name"></property-row> + </div> + </div> + </div> + <div data-ng-if="instance.originType!='VF'"> + <div class="empty-row" data-tests-id="empty-row" ng-if="instance.properties.length===0"> No + properties to display + </div> + <div ng-repeat="property in instance.properties track by $index"> + <property-row instance-properties-map="instancePropertiesMap" property="property" + on-name-clicked="openSelectPropertyDataTypeViewModel(instance.uniqueId,property)" + on-checkbox-clicked="checkArrowState()" + instance-name="instance.name" + instance-id='instance.uniqueId'></property-row> + </div> + </div> + </div> + + </perfect-scrollbar> + </div> + </div> + </div> + + <div class="inputs-button-container pull-left"> + <div ng-click="onArrowPressed()" ng-class="{disabled: isArrowDisabled || isViewOnly}" data-ng-disabled="isArrowDisabled || isViewOnly" class="right-arrow-btn" data-tests-id="add-inputs-to-service-button"></div> + </div> + + <div class="table-container-flex"> + <div class="w-sdc-inputs-search pull-left"> + <input type="text" class="w-sdc-inputs-search-input" data-ng-model="search.filterTerm" placeholder="Search" + data-ng-model-options="{debounce: 200}"/> + <div class="search-icon-container"> + <span class="w-sdc-search-icon inputs-search-icon magnification-white"></span> + </div> + </div> + <div class="table"> + <div class="body"> + <div class="table-header">Service inputs</div> + <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container"> + <expand-collapse expanded-selector=".service-inputs.{{$index}}" + class="expand-collapse-table-row" + load-data-function="loadInputInputs(serviceInput)" + is-close-on-init="true" + data-ng-repeat-start="serviceInput in component.inputs | filter:search track by $index "> + <input-row input="serviceInput" is-view-only='isViewOnly' instance-name='serviceInput.name' + delete-input='deleteInput(serviceInput)' + data-tests-id="service-input-{{$index}}" + class="service-input-row" + on-name-clicked="openEditValueModal(serviceInput)" + ng-class="serviceInput.isNew ? 'new-input': ''" + ></input-row> + </expand-collapse> + + <div data-ng-repeat-end="" class="service-inputs {{$index}}"> + <div ng-if="serviceInput.inputs.length > 0"> + <expand-collapse expanded-selector=".input-inputs-list.{{$parent.$index}}-{{$index}}" + class="expand-collapse-table-row" + load-data-function="loadInputPropertiesForInstance(input.componentInstanceId, input)" + is-close-on-init="true" + data-ng-repeat-start="input in serviceInput.inputs track by $index"> + <input-row input="input" + is-view-only='isViewOnly' + instance-name='input.componentInstanceName'></input-row> + </expand-collapse> + + <div data-ng-repeat-end="" class="input-inputs-list {{$parent.$index}}-{{$index}}"> + <div class="empty-row" ng-if="input.properties.length===0">No properties to display + </div> + <div ng-repeat="property in input.properties track by $index"> + <property-row property="property" instance-name="property.name" is-clickable="false"></property-row> + </div> + </div> + </div> + <div ng-if="serviceInput.properties.length > 0"> + <div class="empty-row" ng-if="serviceInput.properties.length===0">No properties to display</div> + <div ng-repeat="property in serviceInput.properties track by $index"> + <property-row property="property" instance-name="property.name" is-clickable="false"></property-row> + </div> + </div> + </div> + + + </perfect-scrollbar> + </div> + </div> + </div> +</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs.less b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs.less index 11e613b56e..f783d0b6d6 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/inputs/service-input/service-inputs.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/inputs/service-input/service-inputs.less @@ -32,22 +32,15 @@ border: none; border-bottom: rgba(120, 136, 148, 0.26) solid 1px; - .delete { - width: 50px; - padding: 0; - position: relative; + &.service-input-row { + background: @tlv_color_u; + &.new-input { + background: @tlv_color_v; + } } + } - .remove-input-icon { - position: absolute; - top: 12px; - right: 18px; - } - .remove-input-icon:hover { - .delete-icon-hover; - } - } } } diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts index 2fab118378..b7428e990b 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts +++ b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view-model.ts @@ -1,32 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ -/// <reference path="../../../../references"/> -module Sdc.ViewModels { 'use strict'; + import {ArtifactType} from "app/utils"; + import {ArtifactGroupModel} from "app/models"; + import {participant} from "app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model"; + import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; + import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; + import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; export interface IManagementWorkflowViewModelScope extends IWorkspaceViewModelScope { vendorModel:VendorModel; } export class VendorModel { - artifacts: Models.ArtifactGroupModel; + artifacts: ArtifactGroupModel; serviceID: string; readonly: boolean; sessionID: string; @@ -34,7 +19,7 @@ module Sdc.ViewModels { diagramType: string; participants:Array<participant>; - constructor(artifacts: Models.ArtifactGroupModel, serviceID:string, readonly:boolean, sessionID:string, + constructor(artifacts: ArtifactGroupModel, serviceID:string, readonly:boolean, sessionID:string, requestID:string, diagramType:string, participants:Array<participant>){ this.artifacts = artifacts; this.serviceID = serviceID; @@ -50,17 +35,32 @@ module Sdc.ViewModels { static '$inject' = [ '$scope', - 'uuid4' + 'uuid4', + 'ComponentServiceNg2' ]; constructor(private $scope:IManagementWorkflowViewModelScope, - private uuid4:any) { + private uuid4:any, + private ComponentServiceNg2: ComponentServiceNg2) { - this.initScope(); + this.initInformationalArtifacts(); this.$scope.updateSelectedMenuItem(); } + private initInformationalArtifacts = ():void => { + if(!this.$scope.component.artifacts) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentInformationalArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.artifacts = response.artifacts; + this.initScope(); + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + private static getParticipants():Array<participant> { return [ { @@ -112,12 +112,12 @@ module Sdc.ViewModels { private initScope():void { this.$scope.vendorModel = new VendorModel( - this.$scope.component.artifacts.filteredByType(Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW), + this.$scope.component.artifacts.filteredByType(ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW), this.$scope.component.uniqueId, this.$scope.isViewMode(), this.$scope.user.userId, this.uuid4.generate(), - Utils.Constants.ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW, + ArtifactType.THIRD_PARTY_RESERVED_TYPES.WORKFLOW, ManagementWorkflowViewModel.getParticipants() ); @@ -125,4 +125,3 @@ module Sdc.ViewModels { this.$scope.setValidState(true); } } -} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/management-workflow/management-workflow-view.html b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html index bd196daec8..bd196daec8 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/management-workflow/management-workflow-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/management-workflow/management-workflow-view.html diff --git a/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts new file mode 100644 index 0000000000..511c17eb60 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view-model.ts @@ -0,0 +1,79 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {VendorModel} from "app/view-models/workspace/tabs/management-workflow/management-workflow-view-model"; +import {ResourceType, ArtifactType} from "app/utils"; +import {ComponentInstance} from "app/models"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; + +export interface INetworkCallFlowViewModelScope extends IWorkspaceViewModelScope { + vendorMessageModel:VendorModel; +} + +export class participant { + name:string; + id:string; + + constructor(instance:ComponentInstance) { + this.name = instance.name; + this.id = instance.uniqueId; + } +} + + +export class NetworkCallFlowViewModel { + + static '$inject' = [ + '$scope', + 'uuid4', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:INetworkCallFlowViewModelScope, + private uuid4:any, + private ComponentServiceNg2: ComponentServiceNg2) { + + this.initComponentInstancesAndInformationalArtifacts(); + this.$scope.updateSelectedMenuItem(); + } + + private getVFParticipantsFromInstances(instances:Array<ComponentInstance>):Array<participant> { + let participants = []; + _.forEach(instances, (instance)=> { + if (ResourceType.VF == instance.originType) { + participants.push(new participant(instance)); + } + }); + return participants; + } + + private initComponentInstancesAndInformationalArtifacts = ():void => { + if(!this.$scope.component.artifacts || !this.$scope.component.componentInstances) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentInformationalArtifactsAndInstances(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.artifacts = response.artifacts; + this.$scope.component.componentInstances = response.componentInstances; + this.initScope(); + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + + private initScope():void { + this.$scope.vendorMessageModel = new VendorModel( + this.$scope.component.artifacts.filteredByType(ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW), + this.$scope.component.uniqueId, + this.$scope.isViewMode(), + this.$scope.user.userId, + this.uuid4.generate(), + ArtifactType.THIRD_PARTY_RESERVED_TYPES.NETWORK_CALL_FLOW, + this.getVFParticipantsFromInstances(this.$scope.component.componentInstances) + ); + + this.$scope.thirdParty = true; + this.$scope.setValidState(true); + } + +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html index 6ce3e8e2b7..6ce3e8e2b7 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/network-call-flow/network-call-flow-view.html diff --git a/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts new file mode 100644 index 0000000000..233b12952b --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view-model.ts @@ -0,0 +1,109 @@ +'use strict'; +import {ComponentFactory} from "app/utils"; +import {Product, IGroup, ISubCategory, IMainCategory} from "app/models"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {CacheService} from "app/services"; + +export interface IProductHierarchyScope extends IWorkspaceViewModelScope { + + categoriesOptions:Array<IMainCategory>; + product:Product; + isLoading:boolean; + showDropDown:boolean; + + onInputTextClicked():void; + onGroupSelected(category:IMainCategory, subcategory:ISubCategory, group:IGroup):void; + clickOutside():void; + deleteGroup(uniqueId:string):void; +} + +export class ProductHierarchyViewModel { + + static '$inject' = [ + '$scope', + 'Sdc.Services.CacheService', + 'ComponentFactory', + '$state' + ]; + + constructor(private $scope:IProductHierarchyScope, + private cacheService:CacheService, + private ComponentFactory:ComponentFactory, + private $state:ng.ui.IStateService) { + + + this.$scope.product = <Product>this.$scope.getComponent(); + this.$scope.setValidState(true); + this.initScope(); + this.$scope.updateSelectedMenuItem(); + } + + private initCategories = () => { + this.$scope.categoriesOptions = angular.copy(this.cacheService.get('productCategories')); + let selectedGroup:Array<IGroup> = []; + _.forEach(this.$scope.product.categories, (category:IMainCategory) => { + _.forEach(category.subcategories, (subcategory:ISubCategory) => { + selectedGroup = selectedGroup.concat(subcategory.groupings); + }); + }); + _.forEach(this.$scope.categoriesOptions, (category:IMainCategory) => { + _.forEach(category.subcategories, (subcategory:ISubCategory) => { + _.forEach(subcategory.groupings, (group:ISubCategory) => { + let componentGroup:IGroup = _.find(selectedGroup, (componentGroupObj) => { + return componentGroupObj.uniqueId == group.uniqueId; + }); + if (componentGroup) { + group.isDisabled = true; + } + }); + }); + }); + }; + + private setFormValidation = ():void => { + + this.$scope.setValidState(true); + + }; + + private initScope = ():void => { + this.$scope.isLoading = false; + this.$scope.showDropDown = false; + this.initCategories(); + this.setFormValidation(); + + this.$scope.onGroupSelected = (category:IMainCategory, subcategory:ISubCategory, group:IGroup):void => { + this.$scope.product.addGroup(category, subcategory, group); + this.$state.current.data.unsavedChanges = !this.$scope.isViewMode(); + group.isDisabled = true; + this.$scope.showDropDown = false; + this.setFormValidation(); + }; + + this.$scope.onInputTextClicked = ():void => {//just edit the component in place, no pop up nor server update ? + this.$scope.showDropDown = !this.$scope.showDropDown; + }; + + this.$scope.clickOutside = ():any => { + this.$scope.showDropDown = false; + }; + + this.$scope.deleteGroup = (uniqueId:string):void => { + //delete group from component + this.$scope.product.deleteGroup(uniqueId); + this.$state.current.data.unsavedChanges = !this.$scope.isViewMode(); + this.setFormValidation(); + //enabled group + _.forEach(this.$scope.categoriesOptions, (category:IMainCategory) => { + _.forEach(category.subcategories, (subcategory:ISubCategory) => { + let groupObj:IGroup = _.find(subcategory.groupings, (group) => { + return group.uniqueId === uniqueId; + }); + if (groupObj) { + groupObj.isDisabled = false; + } + }); + }); + } + }; +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html index 2335ad7c74..2335ad7c74 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy-view.html diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less index c992558ed2..c992558ed2 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts new file mode 100644 index 0000000000..923cc58a7e --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view-model.ts @@ -0,0 +1,92 @@ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {PropertyModel} from "app/models"; +import {ModalsHandler} from "app/utils"; +import {COMPONENT_FIELDS} from "../../../../utils/constants"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; + +interface IPropertiesViewModelScope extends IWorkspaceViewModelScope { + tableHeadersList:Array<any>; + reverse:boolean; + sortBy:string; + filteredProperties:Array<PropertyModel>; + + addOrUpdateProperty(property?:PropertyModel):void; + delete(property:PropertyModel):void; + sort(sortBy:string):void; +} + +export class PropertiesViewModel { + + static '$inject' = [ + '$scope', + '$filter', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + + constructor(private $scope:IPropertiesViewModelScope, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2:ComponentServiceNg2) { + this.initComponentProperties(); + this.$scope.updateSelectedMenuItem(); + } + + private initComponentProperties = ():void => { + + if(!this.$scope.component.properties) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentProperties(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.properties = response.properties; + this.initScope(); + this.$scope.isLoading = false; + }, () => { + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + + private openEditPropertyModal = (property:PropertyModel):void => { + this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.filteredProperties, false).then(() => { + }); + }; + + private initScope = ():void => { + + //let self = this; + this.$scope.filteredProperties = this.$scope.component.properties; + this.$scope.sortBy = 'name'; + this.$scope.reverse = false; + this.$scope.setValidState(true); + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Type', property: 'type'}, + {title: 'Schema', property: 'schema.property.type'}, + {title: 'Description', property: 'description'}, + ]; + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + + this.$scope.addOrUpdateProperty = (property?:PropertyModel):void => { + this.openEditPropertyModal(property ? property : new PropertyModel()); + }; + + this.$scope.delete = (property:PropertyModel):void => { + + let onOk = ():void => { + this.$scope.component.deleteProperty(property.uniqueId); + }; + let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE"); + let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}"); + this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk); + }; + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties-view.html b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html index e9a4c3879d..d1e0582386 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties-view.html @@ -23,30 +23,27 @@ <span ng-if="!isViewMode()"> click <a data-ng-click="addOrUpdateProperty()">here</a> to add one </span> </div> - <div data-ng-repeat="property in filteredProperties.properties=(component.properties | orderBy:sortBy:reverse | filter: {filterTerm:filterTerms}) track by $index" + <div data-ng-repeat="property in filteredProperties=(component.properties | orderBy:sortBy:reverse | filter: {filterTerm:filterTerms}) track by $index" data-tests-id="propertyRow" data-ng-class="{'selected': property.selected}" class="flex-container data-row"> - <div class="table-col-general flex-item text"> - <a data-tests-id="{{property.name}}" - tooltips tooltip-content="{{property.name}}" + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.name}}"> + <a data-tests-id="propertyName_{{property.name}}" data-ng-click="addOrUpdateProperty(property); $event.stopPropagation();" data-ng-class="{'disabled': isViewMode()}">{{property.name}}</a> </div> <div class="table-col-general flex-item text" - data-tests-id="{{property.type}}" - tooltips tooltip-content="{{property.type}}" - data-ng-bind="property.type"> + tooltips tooltip-content="{{property.type}}"> + <span data-tests-id="propertyType_{{property.name}}"> {{property.type.replace("org.openecomp.datatypes.heat.","")}}</span> </div> <div class="table-col-general flex-item text" - data-tests-id="{{property.schema.property.type}}" - tooltips tooltip-content="{{property.schema.property.type}}" - data-ng-bind="property.schema.property.type"> + tooltips tooltip-content="{{property.schema.property.type}}"> + <span data-tests-id="propertySchema_{{property.name}}"> {{property.schema.property.type.replace("org.openecomp.datatypes.heat.","")}}</span> </div> - <div class="table-col-general flex-item text"> - <span tooltips tooltip-content="{{property.description}}" data-tests-id="{{property.description}}" data-ng-bind="property.description"></span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.description}}"> + <span data-tests-id="propertyDescription_{{property.name}}" data-ng-bind="property.description"></span> </div> <div class="table-btn-col flex-item" ng-if="!isViewMode()"> <button class="table-delete-btn" data-tests-id="delete_{{property.name}}" data-ng-if="property.parentUniqueId==component.uniqueId" diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties.less b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less index 3e8d6c3fbd..3e8d6c3fbd 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/properties/properties.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/properties/properties.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts new file mode 100644 index 0000000000..4ac99edf8a --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view-model.ts @@ -0,0 +1,147 @@ +/** + * Created by rcohen on 9/22/2016. + */ +'use strict'; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ModalsHandler} from "app/utils"; +import {Capability, PropertyModel, Requirement} from "app/models"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; + +export class SortTableDefined { + reverse:boolean; + sortByField:string; +} + +interface IReqAndCapabilitiesViewModelScope extends IWorkspaceViewModelScope { + requirementsTableHeadersList:Array<any>; + capabilitiesTableHeadersList:Array<any>; + capabilityPropertiesTableHeadersList:Array<any>; + requirementsSortTableDefined:SortTableDefined; + capabilitiesSortTableDefined:SortTableDefined; + propertiesSortTableDefined:SortTableDefined; + requirements:Array<Requirement>; + capabilities:Array<Capability>; + mode:string; + filteredProperties:Array<Array<PropertyModel>>; + searchText:string; + + sort(sortBy:string, sortByTableDefined:SortTableDefined):void; + updateProperty(property:PropertyModel, indexInFilteredProperties:number):void; + allCapabilitiesSelected(selected:boolean):void; +} + +export class ReqAndCapabilitiesViewModel { + + static '$inject' = [ + '$scope', + '$filter', + 'ModalsHandler', + 'ComponentServiceNg2' + ]; + + + constructor(private $scope:IReqAndCapabilitiesViewModelScope, + private $filter:ng.IFilterService, + private ModalsHandler:ModalsHandler, + private ComponentServiceNg2: ComponentServiceNg2) { + + this.initCapabilitiesAndRequirements(); + this.$scope.updateSelectedMenuItem(); + } + + private initCapabilitiesAndRequirements = (): void => { + + if(!this.$scope.component.capabilities || !this.$scope.component.requirements) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getCapabilitiesAndRequirements(this.$scope.component.componentType, this.$scope.component.uniqueId).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.capabilities = response.capabilities; + this.$scope.component.requirements = response.requirements; + this.initScope(); + this.$scope.isLoading = false; + }, () => { + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + + } + + private openEditPropertyModal = (property:PropertyModel, indexInFilteredProperties:number):void => { + //...because there is not be api + _.forEach(this.$scope.filteredProperties[indexInFilteredProperties], (prop:PropertyModel)=> { + prop.readonly = true; + }); + this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.filteredProperties[indexInFilteredProperties], false).then(() => { + + }); + }; + + private initScope = ():void => { + + this.$scope.requirementsSortTableDefined = { + reverse: false, + sortByField: 'name' + }; + this.$scope.capabilitiesSortTableDefined = { + reverse: false, + sortByField: 'name' + }; + this.$scope.propertiesSortTableDefined = { + reverse: false, + sortByField: 'name' + }; + + this.$scope.setValidState(true); + this.$scope.requirementsTableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Capability', property: 'capability'}, + {title: 'Node', property: 'node'}, + {title: 'Relationship', property: 'relationship'}, + {title: 'Connected To', property: ''}, + {title: 'Occurrences', property: ''} + ]; + this.$scope.capabilitiesTableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Type', property: 'type'}, + {title: 'Description', property: ''}, + {title: 'Valid Source', property: ''}, + {title: 'Occurrences', property: ''} + ]; + this.$scope.capabilityPropertiesTableHeadersList = [ + {title: 'Name', property: 'name'}, + {title: 'Type', property: 'type'}, + {title: 'Schema', property: 'schema.property.type'}, + {title: 'Description', property: 'description'}, + ]; + this.$scope.filteredProperties = []; + + this.$scope.mode = 'requirements'; + this.$scope.requirements = []; + _.forEach(this.$scope.component.requirements, (req:Array<Requirement>, capName)=> { + this.$scope.requirements = this.$scope.requirements.concat(req); + }); + + this.$scope.capabilities = []; + _.forEach(this.$scope.component.capabilities, (cap:Array<Capability>, capName)=> { + this.$scope.capabilities = this.$scope.capabilities.concat(cap); + }); + + this.$scope.sort = (sortBy:string, sortByTableDefined:SortTableDefined):void => { + sortByTableDefined.reverse = (sortByTableDefined.sortByField === sortBy) ? !sortByTableDefined.reverse : false; + sortByTableDefined.sortByField = sortBy; + }; + + this.$scope.updateProperty = (property:PropertyModel, indexInFilteredProperties:number):void => { + this.openEditPropertyModal(property, indexInFilteredProperties); + }; + + this.$scope.allCapabilitiesSelected = (selected:boolean):void => { + _.forEach(this.$scope.capabilities, (cap:Capability)=> { + cap.selected = selected; + }); + }; + } +} + diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view.html b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view.html index 047768689a..3d6ccb9d00 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities-view.html @@ -30,21 +30,21 @@ <div data-ng-repeat="req in requirements | orderBy:requirementsSortTableDefined.sortByField:requirementsSortTableDefined.reverse | filter: {filterTerm:filterTerms} track by $index" class="flex-container data-row" data-tests-id="reqRow"> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{req.name}}" tooltips tooltip-content="{{req.name}}">{{req.name}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{req.name}}"> + <span data-tests-id="{{req.name}}">{{req.name}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{req.capability}}" tooltips tooltip-content="{{req.capability}}">{{req.capability.substring("tosca.capabilities.".length)}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{req.capability}}"> + <span data-tests-id="{{req.capability}}">{{req.capability.substring("tosca.capabilities.".length)}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{req.node}}" tooltips tooltip-content="{{req.node}}">{{req.node.substring("tosca.nodes.".length)}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{req.node}}"> + <span data-tests-id="{{req.node}}">{{req.node.substring("tosca.nodes.".length)}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{req.relationship}}" tooltips tooltip-content="{{req.relationship}}">{{req.relationship.substring("tosca.relationships.".length)}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{req.relationship}}"> + <span data-tests-id="{{req.relationship}}">{{req.relationship.substring("tosca.relationships.".length)}}</span> </div> <div class="table-col-general flex-item text" data-tests-id="{{}}" data-ng-bind=""></div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{req.minOccurrences}},{{req.maxOccurrences}}" tooltips tooltip-content="{{req.minOccurrences}},{{req.maxOccurrences}}">{{req.minOccurrences}},{{req.maxOccurrences}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{req.minOccurrences}},{{req.maxOccurrences}}"> + <span data-tests-id="{{req.minOccurrences}},{{req.maxOccurrences}}">{{req.minOccurrences}},{{req.maxOccurrences}}</span> </div> </div> </perfect-scrollbar> @@ -70,24 +70,24 @@ class="flex-container data-row" data-ng-class="{'selected': capability.selected}" data-ng-click="capability.selected = !capability.selected" data-tests-id="capabilities-table-row"> - <div class="table-col-general flex-item text"> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{capability.name}}"> <span class="sprite-new arrow-up-small" data-ng-class="{'opened': capability.selected}"></span> - <span data-tests-id="{{capability.name}}" tooltips tooltip-content="{{capability.name}}">{{capability.name}}</span> + <span data-tests-id="{{capability.name}}">{{capability.name}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{capability.type}}" tooltips tooltip-content="{{capability.type}}">{{capability.type.substring("tosca.capabilities.".length)}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{capability.type}}"> + <span data-tests-id="{{capability.type}}">{{capability.type.replace("tosca.capabilities.","")}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{capability.description}}" tooltips tooltip-content="{{capability.description}}">{{capability.description}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{capability.description}}"> + <span data-tests-id="{{capability.description}}">{{capability.description}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{capability.validSourceTypes.join(',')}}" tooltips tooltip-content="{{capability.validSourceTypes.join(',')}}">{{capability.validSourceTypes.join(',')}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{capability.validSourceTypes.join(',')}}"> + <span data-tests-id="{{capability.validSourceTypes.join(',')}}">{{capability.validSourceTypes.join(',')}}</span> </div> - <div class="table-col-general flex-item text"> - <span data-tests-id="{{capability.minOccurrences}},{{capability.maxOccurrences}}" tooltips tooltip-content="{{capability.minOccurrences}},{{capability.maxOccurrences}}">{{capability.minOccurrences}},{{capability.maxOccurrences}}</span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{capability.minOccurrences}},{{capability.maxOccurrences}}"> + <span data-tests-id="{{capability.minOccurrences}},{{capability.maxOccurrences}}">{{capability.minOccurrences}},{{capability.maxOccurrences}}</span> </div> </div> <div data-ng-repeat-end="" data-ng-if="capability.selected" class="item-opened"> @@ -108,9 +108,8 @@ data-tests-id="propertyRow" class="flex-container data-row"> - <div class="table-col-general flex-item text"> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.name}}"> <a data-tests-id="{{property.name}}" - tooltips tooltip-content="{{property.name}}" data-ng-click="updateProperty(property, $parent.$index); $event.stopPropagation();" data-ng-class="{'disabled': isViewMode()}">{{property.name}}</a> @@ -126,8 +125,8 @@ tooltips tooltip-content="{{property.schema.property.type}}" data-ng-bind="property.schema.property.type"> </div> - <div class="table-col-general flex-item text"> - <span tooltips tooltip-content="{{property.description}}" data-tests-id="{{property.description}}" data-ng-bind="property.description"></span> + <div class="table-col-general flex-item text" tooltips tooltip-content="{{property.description}}"> + <span data-tests-id="{{property.description}}" data-ng-bind="property.description"></span> </div> </div> </div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less index 9b52fad411..9b52fad411 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less diff --git a/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts new file mode 100644 index 0000000000..06022786ee --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view-model.ts @@ -0,0 +1,84 @@ +'use strict'; +import {ArtifactModel, IFileDownload} from "app/models"; +import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model"; +import {ComponentGenericResponse} from "../../../../ng2/services/responses/component-generic-response"; +import {ComponentServiceNg2} from "../../../../ng2/services/component-services/component.service"; +export interface IToscaArtifactsScope extends IWorkspaceViewModelScope { + artifacts:Array<ArtifactModel>; + tableHeadersList:Array<any>; + artifactType:string; + downloadFile:IFileDownload; + isLoading:boolean; + sortBy:string; + reverse:boolean; + + getTitle():string; + download(artifact:ArtifactModel):void; + sort(sortBy:string):void; + showNoArtifactMessage():boolean; +} + +export class ToscaArtifactsViewModel { + + static '$inject' = [ + '$scope', + '$filter', + 'ComponentServiceNg2' + ]; + + constructor(private $scope:IToscaArtifactsScope, + private $filter:ng.IFilterService, + private ComponentServiceNg2:ComponentServiceNg2) { + this.initToscaArtifacts(); + this.$scope.updateSelectedMenuItem(); + } + + private initToscaArtifacts = (): void => { + + if(!this.$scope.component.toscaArtifacts) { + this.$scope.isLoading = true; + this.ComponentServiceNg2.getComponentToscaArtifacts(this.$scope.component).subscribe((response:ComponentGenericResponse) => { + this.$scope.component.toscaArtifacts = response.toscaArtifacts; + this.initScope(); + this.$scope.isLoading = false; + }, () => { + this.$scope.isLoading = false; + }); + } else { + this.initScope(); + } + } + + private initScope = ():void => { + this.$scope.isLoading = false; + this.$scope.sortBy = 'artifactDisplayName'; + this.$scope.reverse = false; + this.$scope.setValidState(true); + this.$scope.artifactType = 'informational'; + this.$scope.getTitle = ():string => { + return this.$filter("resourceName")(this.$scope.component.name) + ' Artifacts'; + + }; + + this.$scope.tableHeadersList = [ + {title: 'Name', property: 'artifactDisplayName'}, + {title: 'Type', property: 'artifactType'}, + {title: 'Version', property: 'artifactVersion'} + ]; + + this.$scope.artifacts = <ArtifactModel[]>_.values(this.$scope.component.toscaArtifacts); + this.$scope.sort = (sortBy:string):void => { + this.$scope.reverse = (this.$scope.sortBy === sortBy) ? !this.$scope.reverse : false; + this.$scope.sortBy = sortBy; + }; + + + this.$scope.showNoArtifactMessage = ():boolean => { + if (this.$scope.artifacts.length === 0) { + return true; + } + return false; + }; + + } +} diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view.html b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view.html index 947b37db93..5df6b5c11f 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view.html +++ b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts-view.html @@ -13,24 +13,28 @@ There are no TOSCA artifacts to display </div> <div data-ng-repeat-start="artifact in artifacts| orderBy:sortBy:reverse track by $index" - class="flex-container data-row" + class="flex-container data-row" data-tests-id="{{artifact.artifactDisplayName}}" data-ng-class="{'selected': artifact.selected}"> - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected"> - <span class="sprite table-arrow" data-ng-class="{'opened': artifact.selected}" data-tests-id="{{artifact.artifactDisplayName}}"></span> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="name-{{$index}}"> + <span class="sprite table-arrow" data-ng-class="{'opened': artifact.selected}"></span> {{artifact.artifactDisplayName}} </div> - <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="{{artifact.artifactType}}"> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="type-{{$index}}"> {{artifact.artifactType}} </div> + <div class="table-col-general flex-item" data-ng-click="artifact.selected = !artifact.selected" data-tests-id="version-{{$index}}"> + {{artifact.artifactVersion}} + </div> + <div class="table-btn-col flex-item download-icon-container"> - <button class="table-download-btn tosca" download-artifact data-tests-id="download_{{artifact.artifactDisplayName}}" + <button class="table-download-btn tosca" download-artifact data-tests-id="download-{{artifact.artifactDisplayName}}" data-ng-if="artifact.artifactName" component="component" artifact="artifact" show-loader="true"></button> </div> </div> - <div data-ng-repeat-end="" data-ng-if="artifact.selected" class="item-opened"> + <div data-ng-repeat-end="" data-ng-if="artifact.selected" class="item-opened" data-tests-id="details-{{$index}}"> <div><span class="details-title">Label:</span> {{artifact.artifactLabel}}</div> <div><span class="details-title">UUID:</span> {{artifact.uniqueId}}</div> <div><span class="details-title">Description:</span> {{artifact.description}}</div> diff --git a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less index f792bb8c53..6dfec2980f 100644 --- a/catalog-ui/app/scripts/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less +++ b/catalog-ui/src/app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less @@ -41,6 +41,10 @@ flex-grow: 1; } + .flex-item:nth-child(4) { + flex-grow: 1; + } + diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts new file mode 100644 index 0000000000..ff4636e002 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts @@ -0,0 +1,718 @@ +/** + * Created by obarda on 3/30/2016. + */ +'use strict'; +import {IUserProperties, IAppMenu, Resource, Component} from "app/models"; +import { + WorkspaceMode, ComponentFactory, ChangeLifecycleStateHandler, Role, ComponentState, MenuItemGroup, MenuHandler, + MenuItem, ModalsHandler, States, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ResourceType +} from "app/utils"; +import { + EventListenerService, + EntityService, + ProgressService, + CacheService, + LeftPaletteLoaderService +} from "app/services"; +import {FileUploadModel} from "../../directives/file-upload/file-upload"; + + +export interface IWorkspaceViewModelScope extends ng.IScope { + + isLoading:boolean; + isCreateProgress:boolean; + component:Component; + originComponent:Component; + componentType:string; + importFile:any; + leftBarTabs:MenuItemGroup; + isNew:boolean; + isFromImport:boolean; + isValidForm:boolean; + mode:WorkspaceMode; + breadcrumbsModel:Array<MenuItemGroup>; + sdcMenu:IAppMenu; + changeLifecycleStateButtons:any; + version:string; + versionsList:Array<any>; + changeVersion:any; + isComposition:boolean; + isDeployment:boolean; + $state:ng.ui.IStateService; + user:IUserProperties; + thirdParty:boolean; + disabledButtons:boolean; + menuComponentTitle:string; + progressService:ProgressService; + progressMessage:string; + // leftPanelComponents:Array<Models.Components.Component>; //this is in order to load the left panel once, and not wait long time when moving to composition + + showChangeStateButton():boolean; + getComponent():Component; + setComponent(component:Component):void; + onMenuItemPressed(state:string):ng.IPromise<boolean>; + save():ng.IPromise<boolean>; + setValidState(isValid:boolean):void; + revert():void; + changeLifecycleState(state:string):void; + enabledTabs():void + isDesigner():boolean; + isProductManager():boolean; + isViewMode():boolean; + isEditMode():boolean; + isCreateMode():boolean; + isDisableMode():boolean; + showFullIcons():boolean; + goToBreadcrumbHome():void; + onVersionChanged(selectedId:string):void; + getLatestVersion():void; + getStatus():string; + showLifecycleIcon():boolean; + updateSelectedMenuItem():void; + uploadFileChangedInGeneralTab():void; + updateMenuComponentName(ComponentName:string):void; +} + +export class WorkspaceViewModel { + + static '$inject' = [ + '$scope', + 'injectComponent', + 'ComponentFactory', + '$state', + 'sdcMenu', + '$q', + 'MenuHandler', + 'Sdc.Services.CacheService', + 'ChangeLifecycleStateHandler', + 'ModalsHandler', + 'LeftPaletteLoaderService', + '$filter', + 'EventListenerService', + 'Sdc.Services.EntityService', + 'Notification', + '$stateParams', + 'Sdc.Services.ProgressService' + ]; + + constructor(private $scope:IWorkspaceViewModelScope, + private injectComponent:Component, + private ComponentFactory:ComponentFactory, + private $state:ng.ui.IStateService, + private sdcMenu:IAppMenu, + private $q:ng.IQService, + private MenuHandler:MenuHandler, + private cacheService:CacheService, + private ChangeLifecycleStateHandler:ChangeLifecycleStateHandler, + private ModalsHandler:ModalsHandler, + private LeftPaletteLoaderService:LeftPaletteLoaderService, + private $filter:ng.IFilterService, + private EventListenerService:EventListenerService, + private EntityService:EntityService, + private Notification:any, + private $stateParams:any, + private progressService:ProgressService) { + + this.initScope(); + this.initAfterScope(); + } + + private role:string; + private components:Array<Component>; + + private initViewMode = ():WorkspaceMode => { + let mode = WorkspaceMode.VIEW; + + if (!this.$state.params['id']) { //&& !this.$state.params['vspComponent'] + mode = WorkspaceMode.CREATE; + } else { + if (this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKOUT && + this.$scope.component.lastUpdaterUserId === this.cacheService.get("user").userId) { + if (this.$scope.component.isProduct() && this.role == Role.PRODUCT_MANAGER) { + mode = WorkspaceMode.EDIT; + } + if ((this.$scope.component.isService() || this.$scope.component.isResource()) && this.role == Role.DESIGNER) { + mode = WorkspaceMode.EDIT; + } + } + } + return mode; + }; + + private initChangeLifecycleStateButtons = ():void => { + let state = this.$scope.component.isService() && (Role.OPS == this.role || Role.GOVERNOR == this.role) ? this.$scope.component.distributionStatus : this.$scope.component.lifecycleState; + this.$scope.changeLifecycleStateButtons = this.sdcMenu.roles[this.role].changeLifecycleStateButtons[state]; + }; + + private isNeedSave = ():boolean => { + return this.$scope.isEditMode() && + this.$state.current.data && this.$state.current.data.unsavedChanges; + }; + + private initLeftPalette = ():void => { + this.LeftPaletteLoaderService.loadLeftPanel(this.$scope.component.componentType); + }; + + private initScope = ():void => { + + this.$scope.component = this.injectComponent; + this.initLeftPalette(); + this.$scope.menuComponentTitle = this.$scope.component.name; + this.$scope.disabledButtons = false; + this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component); + this.$scope.componentType = this.$scope.component.componentType; + this.$scope.version = this.cacheService.get('version'); + this.$scope.user = this.cacheService.get("user"); + this.role = this.$scope.user.role; + this.$scope.mode = this.initViewMode(); + this.$scope.isValidForm = true; + this.initChangeLifecycleStateButtons(); + this.initVersionObject(); + this.$scope.$state = this.$state; + this.$scope.isLoading = false; + this.$scope.isComposition = (this.$state.current.name.indexOf(States.WORKSPACE_COMPOSITION) > -1); + this.$scope.isDeployment = (this.$state.current.name.indexOf(States.WORKSPACE_DEPLOYMENT) > -1); + this.$scope.progressService = this.progressService; + + this.$scope.getComponent = ():Component => { + return this.$scope.component; + }; + + this.$scope.updateMenuComponentName = (ComponentName:string):void => { + this.$scope.menuComponentTitle = ComponentName; + }; + + this.$scope.sdcMenu = this.sdcMenu; + // Will be called from each step after save to update the resource. + this.$scope.setComponent = (component:Component):void => { + this.$scope.component = component; + }; + + this.$scope.uploadFileChangedInGeneralTab = ():void => { + // In case user select browse file, and in update mode, need to disable submit for testing and checkin buttons. + if (this.$scope.isEditMode() && this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType == ResourceType.VF) { + this.$scope.disabledButtons = true; + } + }; + + this.$scope.onMenuItemPressed = (state:string):ng.IPromise<boolean> => { + let deferred = this.$q.defer(); + let goToState = ():void => { + this.$state.go(state, { + id: this.$scope.component.uniqueId, + type: this.$scope.component.componentType.toLowerCase(), + components: this.components + }); + deferred.resolve(true); + }; + if (this.isNeedSave()) { + if (this.$scope.isValidForm) { + this.$scope.save().then(goToState); + } else { + console.log('form is not valid'); + deferred.reject(false); + } + } else if (this.$scope.isEditMode() && //this is a workaround for amdocs - we need to get the artifact in order to avoid saving the vf when moving from their tabs + (this.$state.current.name === States.WORKSPACE_MANAGEMENT_WORKFLOW || this.$state.current.name === States.WORKSPACE_NETWORK_CALL_FLOW)) { + let onGetSuccess = (component:Component) => { + this.$scope.isLoading = false; + // Update the components + this.$scope.component = component; + goToState(); + }; + let onFailed = () => { + this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR); + this.$scope.isLoading = false; // stop the progress. + deferred.reject(false); + }; + this.$scope.component.getComponent().then(onGetSuccess, onFailed); + } else { + goToState(); + } + return deferred.promise; + }; + + this.$scope.setValidState = (isValid:boolean):void => { + this.$scope.isValidForm = isValid; + }; + + this.$scope.onVersionChanged = (selectedId:string):void => { + if (this.$state.current.data && this.$state.current.data.unsavedChanges) { + this.$scope.changeVersion.selectedVersion = _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId}); + } + this.$scope.isLoading = true; + this.$state.go(this.$state.current.name, { + id: selectedId, + type: this.$scope.componentType.toLowerCase(), + mode: WorkspaceMode.VIEW, + components: this.$state.params['components'] + }); + + }; + + this.$scope.getLatestVersion = ():void => { + this.$scope.onVersionChanged(_.first(this.$scope.versionsList).versionId); + }; + + this.$scope.save = (state?:string):ng.IPromise<boolean> => { + this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_CLICK); + + this.progressService.initCreateComponentProgress(this.$scope.component.uniqueId); + + let deferred = this.$q.defer(); + let modalInstance:ng.ui.bootstrap.IModalServiceInstance; + + let onFailed = () => { + _.first(this.$scope.leftBarTabs.menuItems).isDisabled = false;//enabled click on general tab (DE246274) + this.EventListenerService.notifyObservers(EVENTS.ON_WORKSPACE_SAVE_BUTTON_ERROR); + this.progressService.deleteProgressValue(this.$scope.component.uniqueId); + modalInstance && modalInstance.close(); // Close the modal in case it is opened. + this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name);// for fix DE246217 + this.$scope.isCreateProgress = false; + this.$scope.isLoading = false; // stop the progress. + + this.$scope.setValidState(true); // Set the form valid (if sent form is valid, the error from server). + if (!this.$scope.isCreateMode()) { + this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); // Set the component back to the original. + this.enableMenuItems(); // Enable the menu items (left tabs), so user can press on them. + this.$scope.disabledButtons = false; // Enable "submit for testing" & checking buttons. + } + + deferred.reject(false); + }; + + let onSuccessCreate = (component:Component) => { + + this.showSuccessNotificationMessage(); + this.progressService.deleteProgressValue(this.$scope.component.uniqueId); + //update components for breadcrumbs + this.components.unshift(component); + this.$state.go(States.WORKSPACE_GENERAL, { + id: component.uniqueId, + type: component.componentType.toLowerCase(), + components: this.components + }); + + deferred.resolve(true); + }; + + let onSuccessUpdate = (component:Component) => { + this.$scope.isCreateProgress = false; + this.$scope.disabledButtons = false; + this.showSuccessNotificationMessage(); + this.progressService.deleteProgressValue(this.$scope.component.uniqueId); + + // Stop the circle loader. + this.$scope.isLoading = false; + + component.tags = _.reject(component.tags, (item)=> { + return item === component.name + }); + + // Update the components + this.$scope.component = component; + this.$scope.originComponent = this.ComponentFactory.createComponent(this.$scope.component); + + //update components for breadcrumbs + this.components.unshift(component); + + // Enable left tags + this.$scope.enabledTabs(); + + + if (this.$state.current.data) { + this.$state.current.data.unsavedChanges = false; + } + + deferred.resolve(true); + }; + + if (this.$scope.isCreateMode()) { + this.$scope.progressMessage = "Creating Asset..."; + // CREATE MODE + this.$scope.isCreateProgress = true; + + _.first(this.$scope.leftBarTabs.menuItems).isDisabled = true;//disabled click on general tab (DE246274) + + // Start creating the component + this.ComponentFactory.createComponentOnServer(this.$scope.component).then(onSuccessCreate, onFailed); + + // In case we import CSAR. Notify user that import VF will take long time (the create is performed in the background). + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).csarUUID) { + this.Notification.info({ + message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_DESCRIPTION"), + title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE") + }); + } + } else { + // UPDATE MODE + this.$scope.isCreateProgress = true; + this.$scope.progressMessage = "Updating Asset..."; + this.disableMenuItems(); + + + // Work around to change the csar version + if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { + (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + this.cacheService.remove(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + } + + this.$scope.component.updateComponent().then(onSuccessUpdate, onFailed); + } + return deferred.promise; + }; + + this.$scope.revert = ():void => { + //in state of import file leave the file in place + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) { + let tempFile:FileUploadModel = (<Resource>this.$scope.component).importedFile; + this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); + (<Resource>this.$scope.component).importedFile = tempFile; + } else { + this.$scope.component = this.ComponentFactory.createComponent(this.$scope.originComponent); + } + + }; + + this.$scope.changeLifecycleState = (state:string):void => { + if (this.isNeedSave() && state !== 'deleteVersion') { + this.$scope.save().then(() => { + changeLifecycleState(state); + }) + } else { + changeLifecycleState(state); + } + }; + + let defaultActionAfterChangeLifecycleState = ():void => { + if (this.$state.current.data && this.$state.current.data.unsavedChanges) { + this.$state.current.data.unsavedChanges = false; + } + this.$state.go('dashboard'); + }; + + let changeLifecycleState = (state:string) => { + if ('monitor' === state) { + this.$state.go('workspace.distribution'); + return; + } + + let data = this.$scope.changeLifecycleStateButtons[state]; + let onSuccess = (component:Component, url:string):void => { + //Updating the component from server response + + //the server returns only metaData (small component) except checkout (Full component) ,so we update only the statuses of distribution & lifecycle + this.$scope.component.lifecycleState = component.lifecycleState; + this.$scope.component.distributionStatus = component.distributionStatus; + + switch (url) { + case 'lifecycleState/CHECKOUT': + // only checkOut get the full component from server + this.$scope.component = component; + // Work around to change the csar version + if (this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG)) { + (<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG); + } + + //when checking out a minor version uuid remains + let bcComponent:Component = _.find(this.components, (item) => { + return item.uuid === component.uuid; + }); + if (bcComponent) { + this.components[this.components.indexOf(bcComponent)] = component; + } else { + //when checking out a major(certified) version + this.components.unshift(component); + } + + this.$state.go(this.$state.current.name, { + id: component.uniqueId, + type: component.componentType.toLowerCase(), + components: this.components + }); + this.Notification.success({ + message: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("CHECKOUT_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'lifecycleState/CHECKIN': + defaultActionAfterChangeLifecycleState(); + this.Notification.success({ + message: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("CHECKIN_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'lifecycleState/UNDOCHECKOUT': + defaultActionAfterChangeLifecycleState(); + this.Notification.success({ + message: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("DELETE_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'lifecycleState/certificationRequest': + defaultActionAfterChangeLifecycleState(); + this.Notification.success({ + message: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("SUBMIT_FOR_TESTING_SUCCESS_MESSAGE_TITLE") + }); + break; + //Tester Role + case 'lifecycleState/failCertification': + defaultActionAfterChangeLifecycleState(); + this.Notification.success({ + message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'lifecycleState/certify': + defaultActionAfterChangeLifecycleState(); + this.Notification.success({ + message: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("ACCEPT_TESTING_SUCCESS_MESSAGE_TITLE") + }); + break; + //DE203504 Bug Fix Start + case 'lifecycleState/startCertification': + this.initChangeLifecycleStateButtons(); + this.Notification.success({ + message: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("START_TESTING_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'lifecycleState/cancelCertification': + this.initChangeLifecycleStateButtons(); + this.Notification.success({ + message: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("CANCEL_TESTING_SUCCESS_MESSAGE_TITLE") + }); + break; + //Ops Role + case 'distribution/PROD/activate': + this.initChangeLifecycleStateButtons(); + this.Notification.success({ + message: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("DISTRIBUTE_SUCCESS_MESSAGE_TITLE") + }); + break; + //Governor Role + case 'distribution-state/reject': + this.initChangeLifecycleStateButtons(); + this.Notification.success({ + message: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("REJECT_SUCCESS_MESSAGE_TITLE") + }); + break; + case 'distribution-state/approve': + this.initChangeLifecycleStateButtons(); + this.$state.go('catalog'); + this.Notification.success({ + message: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TEXT"), + title: this.$filter('translate')("APPROVE_SUCCESS_MESSAGE_TITLE") + }); + break; + //DE203504 Bug Fix End + + default : + defaultActionAfterChangeLifecycleState(); + + } + if (data.url != 'lifecycleState/CHECKOUT') { + this.$scope.isLoading = false; + } + }; + //this.$scope.isLoading = true; + this.ChangeLifecycleStateHandler.changeLifecycleState(this.$scope.component, data, this.$scope, onSuccess); + }; + + this.$scope.enabledTabs = ():void => { + this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => { + item.isDisabled = false; + }); + }; + + this.$scope.isViewMode = ():boolean => { + return this.$scope.mode === WorkspaceMode.VIEW; + }; + + this.$scope.isDesigner = ():boolean => { + return this.role == Role.DESIGNER; + }; + + this.$scope.isProductManager = ():boolean => { + return this.role == Role.PRODUCT_MANAGER; + }; + + this.$scope.isDisableMode = ():boolean => { + return this.$scope.mode === WorkspaceMode.VIEW && this.$scope.component.lifecycleState === ComponentState.NOT_CERTIFIED_CHECKIN; + }; + + this.$scope.showFullIcons = ():boolean => { + //we show revert and save icons only in general\icon view + return this.$state.current.name === States.WORKSPACE_GENERAL || + this.$state.current.name === States.WORKSPACE_ICONS; + }; + + this.$scope.isCreateMode = ():boolean => { + return this.$scope.mode === WorkspaceMode.CREATE; + }; + + this.$scope.isEditMode = ():boolean => { + return this.$scope.mode === WorkspaceMode.EDIT; + }; + + this.$scope.goToBreadcrumbHome = ():void => { + let bcHome:MenuItemGroup = this.$scope.breadcrumbsModel[0]; + this.$state.go(bcHome.menuItems[bcHome.selectedIndex].state); + }; + + this.$scope.showLifecycleIcon = ():boolean => { + return this.role == Role.DESIGNER || + this.role == Role.PRODUCT_MANAGER; + }; + + this.$scope.getStatus = ():string => { + if (this.$scope.isCreateMode()) { + return 'IN DESIGN'; + } + + return this.$scope.component.getStatus(this.sdcMenu); + }; + + this.initMenuItems(); + + this.$scope.showChangeStateButton = ():boolean => { + let result:boolean = true; + if (!this.$scope.component.isLatestVersion() && Role.OPS != this.role && Role.GOVERNOR != this.role) { + result = false; + } + if (this.role === Role.PRODUCT_MANAGER && !this.$scope.component.isProduct()) { + result = false; + } + if ((this.role === Role.DESIGNER || this.role === Role.TESTER) + && this.$scope.component.isProduct()) { + result = false; + } + if (ComponentState.NOT_CERTIFIED_CHECKOUT === this.$scope.component.lifecycleState && this.$scope.isViewMode()) { + result = false; + } + if (ComponentState.CERTIFIED != this.$scope.component.lifecycleState && + (Role.OPS == this.role || Role.GOVERNOR == this.role)) { + result = false; + } + return result; + }; + + this.$scope.updateSelectedMenuItem = ():void => { + let selectedItem:MenuItem = _.find(this.$scope.leftBarTabs.menuItems, (item:MenuItem) => { + return item.state === this.$state.current.name; + }); + this.$scope.leftBarTabs.selectedIndex = selectedItem ? this.$scope.leftBarTabs.menuItems.indexOf(selectedItem) : 0; + }; + + this.$scope.$watch('$state.current.name', (newVal:string):void => { + if (newVal) { + this.$scope.isComposition = (newVal.indexOf(States.WORKSPACE_COMPOSITION) > -1); + this.$scope.isDeployment = (newVal.indexOf(States.WORKSPACE_DEPLOYMENT) > -1); + } + }); + }; + + private initAfterScope = ():void => { + // In case user select csar from the onboarding modal, need to disable checkout and submit for testing. + if (this.$state.params['disableButtons'] === true) { + this.$scope.uploadFileChangedInGeneralTab(); + } + }; + + private initVersionObject = ():void => { + this.$scope.versionsList = (this.$scope.component.getAllVersionsAsSortedArray()).reverse(); + this.$scope.changeVersion = {selectedVersion: _.find(this.$scope.versionsList, {versionId: this.$scope.component.uniqueId})}; + }; + + private getNewComponentBreadcrumbItem = ():MenuItem => { + let text = ""; + if (this.$scope.component.isResource() && (<Resource>this.$scope.component).isCsarComponent()) { + text = this.$scope.component.getComponentSubType() + ': ' + this.$scope.component.name; + } else { + text = 'Create new ' + this.$state.params['type']; + } + return new MenuItem(text, null, States.WORKSPACE_GENERAL, 'goToState', [this.$state.params]); + }; + + private updateMenuItemByRole = (menuItems:Array<MenuItem>, role:string) => { + let tempMenuItems:Array<MenuItem> = new Array<MenuItem>(); + menuItems.forEach((item:MenuItem) => { + //remove item if role is disabled + if (!(item.disabledRoles && item.disabledRoles.indexOf(role) > -1)) { + tempMenuItems.push(item); + } + }); + return tempMenuItems; + }; + + private initBreadcrumbs = () => { + this.components = this.cacheService.get('breadcrumbsComponents'); + let breadcrumbsComponentsLvl = this.MenuHandler.generateBreadcrumbsModelFromComponents(this.components, this.$scope.component); + + if (this.$scope.isCreateMode()) { + let createItem = this.getNewComponentBreadcrumbItem(); + if (!breadcrumbsComponentsLvl.menuItems) { + breadcrumbsComponentsLvl.menuItems = []; + } + breadcrumbsComponentsLvl.menuItems.unshift(createItem); + breadcrumbsComponentsLvl.selectedIndex = 0; + } + + this.$scope.breadcrumbsModel = [breadcrumbsComponentsLvl, this.$scope.leftBarTabs]; + }; + + private initMenuItems() { + + let inCreateMode = this.$scope.isCreateMode(); + this.$scope.leftBarTabs = new MenuItemGroup(); + this.$scope.leftBarTabs.menuItems = this.updateMenuItemByRole(this.sdcMenu.component_workspace_menu_option[this.$scope.component.getComponentSubType()], this.role); + + this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => { + item.params = [item.state]; + item.callback = this.$scope.onMenuItemPressed; + item.isDisabled = (inCreateMode && States.WORKSPACE_GENERAL != item.state) || + (States.WORKSPACE_DEPLOYMENT === item.state && this.$scope.component.groups && this.$scope.component.groups.length === 0 && this.$scope.component.isResource()); + }); + + if (this.cacheService.get('breadcrumbsComponents')) { + this.initBreadcrumbs(); + } else { + let onSuccess = (components:Array<Component>) => { + this.cacheService.set('breadcrumbsComponents', components); + this.initBreadcrumbs(); + }; + this.EntityService.getCatalog().then(onSuccess); //getAllComponents() doesnt return components from catalog + } + } + + private disableMenuItems() { + this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => { + item.params = [item.state]; + item.callback = this.$scope.onMenuItemPressed; + item.isDisabled = (States.WORKSPACE_GENERAL != item.state); + }); + } + + private enableMenuItems() { + this.$scope.leftBarTabs.menuItems.forEach((item:MenuItem) => { + item.params = [item.state]; + item.callback = this.$scope.onMenuItemPressed; + item.isDisabled = false; + }); + } + + private showSuccessNotificationMessage = ():void => { + this.Notification.success({ + message: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_DESCRIPTION"), + title: this.$filter('translate')("IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE") + }); + }; + +} + + diff --git a/catalog-ui/app/scripts/view-models/workspace/workspace-view.html b/catalog-ui/src/app/view-models/workspace/workspace-view.html index 118f7474be..dbb7fa6d63 100644 --- a/catalog-ui/app/scripts/view-models/workspace/workspace-view.html +++ b/catalog-ui/src/app/view-models/workspace/workspace-view.html @@ -1,11 +1,5 @@ <div class="sdc-workspace-container"> <loader data-display="isLoading"></loader> - - <!-- HEADER --> -<!-- - <ecomp-header menu-data="menuItems" version="{{version}}"></ecomp-header> ---> - <div class="w-sdc-main-container"> <div class="w-sdc-left-sidebar" data-ng-if="!isComposition"> @@ -15,14 +9,11 @@ </div> <div include-padding="true" class="w-sdc-main-right-container" data-ng-class="{'composition':isComposition}"> - - <!--<div class="w-sdc-main-right-container" data-ng-class="{'composition':isComposition}">--> - <loader data-display="isCreateProgress" relative="true"></loader> + <loader data-display="isCreateProgress" data-ng-show="isCreateProgress" relative="false"></loader> <div class="sdc-workspace-top-bar"> <div class="version-container"> - <span data-ng-if="!isCreateMode() && !component.isLatestVersion()" class="not-latest"></span> <select class="version-selector" data-ng-if="!isCreateMode()" data-tests-id="versionHeader" data-ng-model="changeVersion.selectedVersion" ng-options="'V'+version.versionNumber for version in versionsList" data-ng-change="onVersionChanged(changeVersion.selectedVersion.versionId)"> @@ -63,7 +54,7 @@ <button ng-if="!isViewMode() && isCreateMode()" data-ng-disabled="!isValidForm || isDisableMode() || isLoading" ng-click="save()" class="tlv-btn outline green" data-tests-id="create/save">Create</button> - <span data-ng-if="isDesigner() && !isCreateMode() && component.lifecycleState === 'NOT_CERTIFIED_CHECKOUT'" sdc-smart-tooltip="" + <span data-ng-if="(isDesigner() || isProductManager()) && !isCreateMode() && component.lifecycleState === 'NOT_CERTIFIED_CHECKOUT'" sdc-smart-tooltip="" data-ng-class="{'disabled' : !isValidForm || isDisableMode() || isViewMode()}" ng-click="changeLifecycleState('deleteVersion')" class="sprite-new delete-btn" data-tests-id="delete_version" sdc-smart-tooltip="">Delete</span> @@ -83,4 +74,5 @@ </div> </div> <top-nav search-bind="search.filterTerm" hide-search="true" menu-model="breadcrumbsModel" version="{{version}}"></top-nav> + <ecomp-footer></ecomp-footer> </div> diff --git a/catalog-ui/src/app/view-models/workspace/workspace.less b/catalog-ui/src/app/view-models/workspace/workspace.less new file mode 100644 index 0000000000..6cf024e335 --- /dev/null +++ b/catalog-ui/src/app/view-models/workspace/workspace.less @@ -0,0 +1,150 @@ +.sdc-workspace-container { + .bg_p; + + .add-btn { + .f-color.a; + .f-type._12_m; + .hand; + float: right; + margin-bottom: 15px; + + &:before { + .sprite-new; + .plus-icon; + margin-right: 5px; + content: ""; + + } + &:hover { + .f-color.b; + &:before { + .sprite-new; + .plus-icon-hover; + } + } + + } + .w-sdc-left-sidebar { + padding: 3px 3px 0px 0px; + background-color: @main_color_p; + box-shadow: 7px -3px 6px -8px @main_color_n; + z-index: 2; + } + + .sdc-asset-creation-info { + .n_12_r; + float: right; + margin: 8px 20px 0 0; + } + + .w-sdc-main-right-container { + + padding: 0px 0px 0px 0px; + background-color: @main_color_p; + z-index: 1; + + .sdc-workspace-top-bar { + height: @action_nav_height; + padding: 12px 10px 0px 50px; + border-bottom: 1px solid @main_color_o; + display: flex; + justify-content: space-between; + + .version-container { + + } + + .progress-container { + flex-grow: 4; + z-index: 10000000; + + .general-view-top-progress { + width: 30%; + margin: 0 auto; + min-width: 200px; + } + } + + .not-latest { + position: absolute; + left: 24px; + top: 20px; + .sprite-new; + .asdc-warning; + } + + .sdc-workspace-top-bar-buttons { + + > button, > span:not(.delimiter) { + margin-right: 10px; + vertical-align: middle; + .hand; + + &.sprite-new { + text-indent: 100%; + } + &.disabled, &:hover.disabled { + pointer-events: none; + } + } + .delimiter { + height: 32px; + width: 1px; + background-color: #959595; + display: inline-block; + vertical-align: middle; + margin-right: 20px; + } + + } + + .lifecycle-state { + padding: 7px 0 0 10px; + margin: 2px 0 7px 10px; + border-left: 1px solid @main_color_o; + line-height: 15px; + font-family: @font-omnes-medium; + color: @main_color_m; + + .lifecycle-state-icon { + .sprite-new; + } + .lifecycle-state-text { + + font-weight: bold; + text-transform: uppercase; + vertical-align: top; + padding: 3px; + } + } + + .version-selector { + // float:left; + background-color: transparent; + border: none; + margin-top: 6px; + } + } + .w-sdc-main-container-body-content { + height:calc(~'100% - @{action_nav_height}'); + + text-align: center; + align-items: center; + padding: 40px 14% 20px 14%; + &.third-party { + text-align: left; + padding: 0; + position: absolute; + top: @action_nav_height; + left: 0; + right: 0; + bottom: 0; + } + } + } +} + + +.properties-assignment .sdc-workspace-container .w-sdc-main-right-container .w-sdc-main-container-body-content{ + padding: 80px 2% 40px 2%; +}
\ No newline at end of file diff --git a/catalog-ui/src/assets/.gitkeep b/catalog-ui/src/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/catalog-ui/src/assets/.gitkeep diff --git a/catalog-ui/app/languages/en_US_OS.json b/catalog-ui/src/assets/languages/en_US.json index d7f639e076..5f752333cd 100644 --- a/catalog-ui/app/languages/en_US_OS.json +++ b/catalog-ui/src/assets/languages/en_US.json @@ -1,4 +1,6 @@ { + "PROJECT_TITLE": "SDC", + "=========== VALIDATION ===========": "", "VALIDATION_ERROR_MAX_LENGTH": "Max length {{max}} characters.", "VALIDATION_ERROR_MIN_LENGTH": "Min length {{min}} characters.", @@ -12,6 +14,7 @@ "VALIDATION_ERROR_MAX_FILE_SIZE": "Max file size is 10 MB.", "VALIDATION_ERROR_EMPTY_FILE": "The file you uploaded was empty, please upload a valid file.", "VALIDATION_ERROR_VALUE_MUST_BE_CHANGED": "Value must be changed", + "VALIDATION_ERROR_INVALID_NAME": "Invalid name.", "=========== GENERAL ===========": "", "GENERAL_LABEL_TYPE": "Type:", @@ -31,7 +34,10 @@ "GENERAL_LABEL_LICENSE_TYPE": "License Type:", "GENERAL_LABEL_SERVICE": "Service:", "GENERAL_LABEL_RESOURCE": "Resource:", - "GENERAL_LABEL_PRODUCT": "Product:", + "GENERAL_LABEL_LIFE_CYCLE_STATUS": "Life Cycle Status:", + "GENERAL_LABEL_DISTRIBUTION_STATUS": "Distribution Status:", + "GENERAL_LABEL_SYSTEM_NAME": "System Name:", + "=========== GENERAL ERROR PAGES ===========": "", "GENERAL_ERROR_403_TITLE": "SDC", @@ -45,6 +51,7 @@ "TOP_MENU_HOME_BUTTON": "HOME", "TOP_MENU_CATALOG_BUTTON": "CATALOG", "TOP_MENU_ON_BOARD_BUTTON": "ONBOARD", + "TOP_MENU_DCAE_BUTTON": "DCAE", "=========== SIGN IN PAGE ===========": "", "SIGN_IN_CAPTION": "Signing in", @@ -258,6 +265,7 @@ "compute": "Compute", "gateway": "Gateway", "defaulticon": "Default Icon", + "monitoring_template": "Monitoring Template", "=========== ADD ARTIFACT FROM ===========": "", "ADD_ARTIFACT_ERROR_VALID_EXTENSIONS": "File extension should be {{extensions}}.", @@ -366,8 +374,8 @@ "CREATE_CATEGORY_MODAL_PATTERN": "{{modelType}} name is not valid" ,"=========== PDF FILE ===========": "", - "PDF_FILE_DECLARATION_BOLD": "AT&T Proprietary (Restricted)", - "PDF_FILE_DECLARATION": "Only for use by authorized individuals or any above-designated team(s) within the AT&T companies and not for general distribution" + "PDF_FILE_DECLARATION_BOLD": "", + "PDF_FILE_DECLARATION": "" ,"=========== DEPLOYMENT ARTIFACTS ===========": "", "DEPLOYMENT_ARTIFACT_NO_ARTIFACTS_TO_DISPLAY": "There are no deployment artifacts to display", @@ -377,7 +385,7 @@ "DEPLOYMENT_ARTIFACT_BUTTON_ADD_VOLUME_HEAT": "Add Volume HEAT Artifact", "DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER": "Add Other Artifact" -,"=========== IMPORT VF ===========": "", + ,"=========== IMPORT VF ===========": "", "IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE": "Create VF", "IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_DESCRIPTION": "Your VF is being created.<br/>It can take up to 10 minutes.<br/>When done, you can view it in SDC Catalog.", "IMPORT_VF_MESSAGE_CREATE_FINISHED_TITLE": "Create/Update", @@ -387,6 +395,7 @@ "=========== TABS TITLE ===========": "", "HIERARCHY_TAB_TITLE": "HIERARCHY", + "DEPLOYMENT_TAB_TITLE": "DEPLOYMENT", "=========== DISTRIBUTION VIEW ===========": "", "DISTRIBUTION_VIEW_TITLE_USER_ID": "User id:", @@ -416,5 +425,17 @@ "=========== ON BOARDING MODAL INFO MESSAGES ===========": "", "ON_BOARDING_GENERAL_INFO": "Displays a table of VSPs created using Onboarding.<br/> Each row displays details for a single VSP.<br/> When expanded you can either import CSAR files that are yet to be imported or update CSAR files that were previously imported.", "ON_BOARDING_IMPORT_INFO": "Displays the Onboarding repository and supports importing on-boarded CSAR files.<br/> Select an imported CSAR file to create a VF from the on-boarded and imported information.", - "ON_BOARDING_UPDATE_INFO": "Displays the Onboarding repository and supports updating on-boarded and previously imported CSAR files.<br/> Clicking Update, updates the existing VF with information available from a new version of the CSAR file." + "ON_BOARDING_UPDATE_INFO": "Displays the Onboarding repository and supports updating on-boarded and previously imported CSAR files.<br/> Clicking Update, updates the existing VF with information available from a new version of the CSAR file.", + + "=========== HEAT PARAMETERS MODAL INFO MESSAGES ===========": "", + "DEFAULT_VALUE_INFO": "This column indicates all the default values that were declared in the Main Heat ", + "CURRENT_VALUE_INFO": "This column indicates:<br/>• Default values that were declared in the main HEAT & does not have a value in the ENV<br/>• Values that were declared in the ENV<br/>• All the values that appear in the current value fields will be generated into the ENV", + + "=========== MODULE PROPERTY FORM ===========": "", + "MIN_VALIDATION_ERROR": "Value cannot be lower than the 'min_vf_module_instances' and 'initial_count'", + "MAX_VALIDATION_ERROR": "Value cannot be higher than the 'max_vf_module_instances' and 'initial_count'", + "MIN_MAX_VALIDATION": "Value must be between 'min_vf_module_instances' and 'max vf module instances'", + "MIN_VALIDATION_VF_LEVE_ERROR": " Value of 'min_vf_module_instances' must not be lower than defined in VF level", + "MAX_VALIDATION_VF_LEVE_ERROR": " Value of 'max_vf_module_instances' must not be higher than defined in VF level" + } diff --git a/catalog-ui/app/styles/animation.less b/catalog-ui/src/assets/styles/animation.less index 014b33a454..014b33a454 100644 --- a/catalog-ui/app/styles/animation.less +++ b/catalog-ui/src/assets/styles/animation.less diff --git a/catalog-ui/src/assets/styles/app.less b/catalog-ui/src/assets/styles/app.less new file mode 100644 index 0000000000..1ce1801d9b --- /dev/null +++ b/catalog-ui/src/assets/styles/app.less @@ -0,0 +1,119 @@ +.sdc-main-container{ + width: 100%; + height: 100%; +} + +@import 'variables.less'; +@import 'variables-old.less'; +@import 'mixins.less'; +@import 'mixins_old.less'; +@import 'global.less'; + +@import 'sprite-old.less'; +@import 'sprite.less'; +@import 'sprite-product-icons.less'; +@import 'sprite-resource-icons.less'; +@import 'sprite-services-icons.less'; + +@import 'animation.less'; +@import 'buttons.less'; +@import 'dark-header.less'; +@import 'fonts.less'; +@import 'form-elements.less'; +@import 'layout/header.less'; +@import 'layout/main.less'; +@import 'layout/sidebar.less'; +@import 'modal.less'; +@import 'multi-level-expand-collapse.less'; +@import 'scroller.less'; +@import 'table-flex.less'; +@import 'tlv-buttons.less'; +@import 'tlv-checkbox.less'; +@import 'tlv-loader.less'; +@import 'tlv-sprite.less'; +@import 'tooltips.less'; +@import 'welcome-sprite.less'; +@import 'welcome-style.less'; +@import 'sdc-ui.css'; + +// Less insides specific files. +@import '../../app/directives/ecomp-footer/ecomp-footer.less'; +@import '../../app/directives/ecomp-header/ecomp-header.less'; +@import '../../app/directives/edit-name-popover/edit-name-popover.less'; +@import '../../app/directives/elements/checkbox/checkbox.less'; +@import '../../app/directives/elements/radiobutton/radiobutton.less'; +@import '../../app/directives/ellipsis/ellipsis-directive.less'; +@import '../../app/directives/file-upload/file-upload.less'; +@import '../../app/directives/graphs-v2/composition-graph/composition-graph.less'; +@import '../../app/directives/graphs-v2/deployment-graph/deployment-graph.less'; +@import '../../app/directives/graphs-v2/palette/palette.less'; +@import '../../app/directives/graphs-v2/relation-menu/relation-menu.less'; +@import '../../app/directives/capabilities-and-requirements/capabilities-requirements-list.less'; +// @import '../../app/directives/graphs-v2/asset-popover/asset-popover.less'; +@import '../../app/directives/info-tooltip/info-tooltip.less'; +@import '../../app/directives/inputs-and-properties/inputs/input-row.less'; +@import '../../app/directives/inputs-and-properties/properties/property-row-view.less'; +@import '../../app/directives/layout/top-nav/top-nav.less'; +@import '../../app/directives/layout/top-progress/top-progress.less'; +@import '../../app/directives/loader/loader-directive.less'; +@import '../../app/directives/modal/sdc-modal.less'; +@import '../../app/directives/property-types/data-type-fields-structure/data-type-fields-structure.less'; +@import '../../app/directives/property-types/type-list/type-list-directive.less'; +@import '../../app/directives/property-types/type-map/type-map-directive.less'; +@import '../../app/directives/sdc-tabs/sdc-single-tab/sdc-single-tab.less'; +@import '../../app/directives/sdc-tabs/sdc-tabs.less'; +@import '../../app/directives/select-property-types/select-data-type-fields-structure/select-data-type-fields-structure.less'; +@import '../../app/directives/select-property-types/select-type-list/select-type-list-directive.less'; +@import '../../app/directives/select-property-types/select-type-map/select-type-map-directive.less'; +@import '../../app/directives/structure-tree/structure-tree-directive.less'; +@import '../../app/directives/tag/tag-directive.less'; +@import '../../app/directives/user-header-details/user-header-details-directive.less'; +@import '../../app/directives/utils/expand-collapse-list-header/expand-collapse-list-header.less'; +@import '../../app/directives/utils/expand-collapse-menu-box/expand-collapse-menu-box.less'; +@import '../../app/directives/utils/expand-collapse/expand-collapse.less'; +@import '../../app/directives/utils/sdc-tags/sdc-tags.less'; +@import '../../app/view-models/admin-dashboard/add-category-modal/add-category-modal-view.less'; +@import '../../app/view-models/admin-dashboard/admin-dashboard.less'; +@import '../../app/view-models/admin-dashboard/category-management/category-management.less'; +@import '../../app/view-models/admin-dashboard/user-management/user-management.less'; +@import '../../app/view-models/catalog/catalog.less'; +@import '../../app/view-models/dashboard/dashboard.less'; +@import '../../app/view-models/dcae-app/dcae-app.less'; +@import '../../app/view-models/forms/artifact-form/artifact-form.less'; +@import '../../app/view-models/forms/env-parameters-form/env-parameters-form.less'; +@import '../../app/view-models/forms/property-forms/base-property-form/property-form-base.less'; +@import '../../app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less'; +@import '../../app/view-models/forms/resource-instance-name-form/resource-instance-name.less'; +@import '../../app/view-models/modals/confirmation-modal/confirmation-modal.less'; +@import '../../app/view-models/modals/email-modal/email-modal.less'; +@import '../../app/view-models/modals/error-modal/error.less'; +@import '../../app/view-models/modals/message-modal/message-client-modal/client-message-modal.less'; +@import '../../app/view-models/modals/message-modal/message-server-modal/server-message-modal.less'; +@import '../../app/view-models/modals/onboarding-modal/onboarding-modal.less'; +@import '../../app/view-models/onboard-vendor/onboard-vendor.less'; +@import '../../app/view-models/support/support.less'; +@import '../../app/view-models/tabs/general-tab.less'; +@import '../../app/view-models/tabs/hierarchy/hierarchy.less'; +@import '../../app/view-models/tutorial-end/tutorial-end.less'; +@import '../../app/view-models/workspace/tabs/activity-log/activity-log.less'; +@import '../../app/view-models/workspace/tabs/attributes/attributes.less'; +@import '../../app/view-models/workspace/tabs/composition/composition.less'; +@import '../../app/view-models/workspace/tabs/composition/tabs/artifacts/artifacts.less'; +@import '../../app/view-models/workspace/tabs/composition/tabs/details/details.less'; +@import '../../app/view-models/workspace/tabs/composition/tabs/properties-and-attributes/properties.less'; +@import '../../app/view-models/workspace/tabs/composition/tabs/relations/relations.less'; +@import '../../app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts.less'; +@import '../../app/view-models/workspace/tabs/deployment/deployment.less'; +@import '../../app/view-models/workspace/tabs/distribution/disribution-status-modal/disribution-status-modal.less'; +@import '../../app/view-models/workspace/tabs/distribution/distribution.less'; +@import '../../app/view-models/workspace/tabs/general/general.less'; +@import '../../app/view-models/workspace/tabs/icons/icons.less'; +@import '../../app/view-models/workspace/tabs/information-artifacts/information-artifacts.less'; +@import '../../app/view-models/workspace/tabs/inputs/inputs.less'; +@import '../../app/view-models/workspace/tabs/inputs/resource-input/resource-inputs.less'; +@import '../../app/view-models/workspace/tabs/inputs/service-input/service-inputs.less'; +@import '../../app/view-models/workspace/tabs/product-hierarchy/product-hierarchy.less'; +@import '../../app/view-models/workspace/tabs/properties/properties.less'; +@import '../../app/view-models/workspace/tabs/req-and-capabilities/req-and-capabilities.less'; +@import '../../app/view-models/workspace/tabs/tosca-artifacts/tosca-artifacts.less'; +@import '../../app/view-models/workspace/workspace.less'; diff --git a/catalog-ui/app/styles/buttons.less b/catalog-ui/src/assets/styles/buttons.less index 7215d7a3d4..7215d7a3d4 100644 --- a/catalog-ui/app/styles/buttons.less +++ b/catalog-ui/src/assets/styles/buttons.less diff --git a/catalog-ui/app/styles/dark-header.less b/catalog-ui/src/assets/styles/dark-header.less index 38b4175daa..38b4175daa 100644 --- a/catalog-ui/app/styles/dark-header.less +++ b/catalog-ui/src/assets/styles/dark-header.less diff --git a/catalog-ui/app/styles/fonts.less b/catalog-ui/src/assets/styles/fonts.less index 752f41f86a..752f41f86a 100644 --- a/catalog-ui/app/styles/fonts.less +++ b/catalog-ui/src/assets/styles/fonts.less diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.eot Binary files differindex 83074fbe2b..83074fbe2b 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.svg index 564f750d99..564f750d99 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.ttf Binary files differindex 7bfb9d5cc2..7bfb9d5cc2 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.woff Binary files differindex b1f00eeac9..b1f00eeac9 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bd.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bd.woff diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.eot Binary files differindex 22646213e6..22646213e6 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.svg index 0996bb5eec..0996bb5eec 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.ttf Binary files differindex 69b3c834e6..69b3c834e6 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.woff Binary files differindex f2850a6f53..f2850a6f53 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BdIt.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BdIt.woff diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.eot Binary files differindex a945fb3592..a945fb3592 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.svg index 279204943f..279204943f 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.ttf Binary files differindex b4390461c6..b4390461c6 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.woff Binary files differindex 5373567803..5373567803 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Bk.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Bk.woff diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.eot Binary files differindex 4ab6695752..4ab6695752 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.svg index c2337a7f89..c2337a7f89 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.ttf Binary files differindex 7e7aa05778..7e7aa05778 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.woff Binary files differindex 55fbfd6896..55fbfd6896 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-BkIt.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-BkIt.woff diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.eot Binary files differindex 06a4bf9949..06a4bf9949 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.svg index 40656e14f8..40656e14f8 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.ttf Binary files differindex c9a45c0e51..c9a45c0e51 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.woff Binary files differindex 521ee2e918..521ee2e918 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-Lt.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-Lt.woff diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.eot b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.eot Binary files differindex 06772919e7..06772919e7 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.eot +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.eot diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.svg b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.svg index bff63e5524..bff63e5524 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.svg +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.svg diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.ttf b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.ttf Binary files differindex bd7ac47137..bd7ac47137 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.ttf +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.ttf diff --git a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.woff b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.woff Binary files differindex 7f8a274165..7f8a274165 100644 --- a/catalog-ui/app/styles/fonts/ClearviewATT/ClearviewATT-LtIt.woff +++ b/catalog-ui/src/assets/styles/fonts/ClearviewATT/ClearviewATT-LtIt.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/AT&T Variation ID.tab b/catalog-ui/src/assets/styles/fonts/OmnesATT/AT&T Variation ID.tab index e0085fd9ac..e0085fd9ac 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/AT&T Variation ID.tab +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/AT&T Variation ID.tab diff --git a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.eot Binary files differindex da1c1d1ebe..da1c1d1ebe 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.svg index 916075aa05..916075aa05 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.ttf Binary files differindex 4f35e1f9b8..4f35e1f9b8 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.woff Binary files differindex 1722dce99e..1722dce99e 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/OmnesATTW02BoldItalic.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.eot Binary files differindex 39e1eae7c7..39e1eae7c7 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.svg index 73923de097..73923de097 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.ttf Binary files differindex 2342be4be5..2342be4be5 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.woff Binary files differindex 0acf1f027f..0acf1f027f 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.eot Binary files differindex 0e5892d1e0..0e5892d1e0 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.svg index 9670981b29..9670981b29 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.ttf Binary files differindex 94934087bb..94934087bb 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.woff Binary files differindex 1dfd28f299..1dfd28f299 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Bold.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Bold.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.eot Binary files differindex 8723e66fa0..8723e66fa0 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.svg index dbf33a9768..dbf33a9768 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.ttf Binary files differindex 4ef76763bd..4ef76763bd 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.woff Binary files differindex 750d90d387..750d90d387 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Italic.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Italic.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.eot Binary files differindex 280d111fe4..280d111fe4 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.svg index 85f39f5008..85f39f5008 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.ttf Binary files differindex 273761ab3d..273761ab3d 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.woff Binary files differindex b12120a86e..b12120a86e 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Light.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Light.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.eot Binary files differindex 2da6a99ec6..2da6a99ec6 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.svg index ab6936ceeb..ab6936ceeb 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.ttf Binary files differindex 5153cee682..5153cee682 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.woff Binary files differindex cf9993a1d6..cf9993a1d6 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02LightItalic.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.eot Binary files differindex 37c715f5be..37c715f5be 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.svg index ad72d0be51..ad72d0be51 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.ttf Binary files differindex 2740425412..2740425412 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.woff Binary files differindex 5cff69add1..5cff69add1 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02Medium.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02Medium.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.eot b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.eot Binary files differindex 84ba4acc6b..84ba4acc6b 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.eot +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.eot diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.svg b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.svg index eca8f73836..eca8f73836 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.svg +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.svg diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.ttf b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.ttf Binary files differindex 46bfd531b0..46bfd531b0 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.ttf +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.ttf diff --git a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.woff b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.woff Binary files differindex 20419ed3b3..20419ed3b3 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.woff +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/Omnes_ATTW02MediumItalic.woff diff --git a/catalog-ui/app/styles/fonts/OmnesATT/demo-async.htm b/catalog-ui/src/assets/styles/fonts/OmnesATT/demo-async.htm index f7a43e6a34..f7a43e6a34 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/demo-async.htm +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/demo-async.htm diff --git a/catalog-ui/app/styles/fonts/OmnesATT/demo.htm b/catalog-ui/src/assets/styles/fonts/OmnesATT/demo.htm index edb62ad34a..edb62ad34a 100644 --- a/catalog-ui/app/styles/fonts/OmnesATT/demo.htm +++ b/catalog-ui/src/assets/styles/fonts/OmnesATT/demo.htm diff --git a/catalog-ui/app/styles/form-elements.less b/catalog-ui/src/assets/styles/form-elements.less index 9f8146d3f5..9f8146d3f5 100644 --- a/catalog-ui/app/styles/form-elements.less +++ b/catalog-ui/src/assets/styles/form-elements.less diff --git a/catalog-ui/app/styles/global.less b/catalog-ui/src/assets/styles/global.less index 9faf4aeb0e..9faf4aeb0e 100644 --- a/catalog-ui/app/styles/global.less +++ b/catalog-ui/src/assets/styles/global.less diff --git a/catalog-ui/app/styles/images/anonymous.jpg b/catalog-ui/src/assets/styles/images/anonymous.jpg Binary files differindex 863af35321..863af35321 100644 --- a/catalog-ui/app/styles/images/anonymous.jpg +++ b/catalog-ui/src/assets/styles/images/anonymous.jpg diff --git a/catalog-ui/src/assets/styles/images/att-globe.svg b/catalog-ui/src/assets/styles/images/att-globe.svg new file mode 100644 index 0000000000..dc9042f524 --- /dev/null +++ b/catalog-ui/src/assets/styles/images/att-globe.svg @@ -0,0 +1 @@ +<svg baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><path fill="#089EDA" d="M7.1 32c3 2.3 6.8 3.7 10.9 3.7 4.5 0 8.6-1.7 11.7-4.4-1.4.9-5.4 3-11.7 3-5.5 0-9-1.2-10.9-2.3m12.1.9c4.4 0 9.2-1.2 12-3.6.8-.6 1.5-1.5 2.2-2.6.4-.7.8-1.5 1.1-2.2-2.7 3.9-10.4 6.4-18.4 6.4-5.6 0-11.7-1.8-14.1-5.3 2.2 4.8 8.9 7.3 17.2 7.3m-4.8-7.8c-9.1 0-13.4-4.2-14.1-7.1 0 1 .1 2.2.3 3.1.1.4.4 1 .9 1.6 2.2 2.3 7.7 5.5 17.2 5.5 12.9 0 15.9-4.3 16.5-5.7.4-1 .7-2.8.7-4.4v-1c-.9 3.4-11.9 8-21.5 8m-12.5-14.7c-.5 1-1.1 2.8-1.3 3.7-.1.4 0 .6.1.9 1.1 2.3 6.6 6 19.4 6 7.8 0 13.9-1.9 14.9-5.4.2-.6.2-1.3 0-2.2-.3-1-.7-2.2-1.2-3.1.1 4.6-12.7 7.6-19.2 7.6-7 0-12.9-2.8-12.9-6.3.1-.5.2-.9.2-1.2m27.8-5.7c.1.1.1.2.1.4 0 2-6 5.4-15.6 5.4-7.1 0-8.4-2.6-8.4-4.3 0-.6.2-1.2.7-1.8-.9.9-1.7 1.7-2.5 2.7-.3.4-.5.8-.5 1 0 3.5 8.7 5.9 16.7 5.9 8.6 0 12.5-2.8 12.5-5.3 0-.9-.3-1.4-1.2-2.4-.6-.6-1.2-1.1-1.8-1.6m-2.6-1.9c-2.7-1.6-5.7-2.5-9.1-2.5-3.4 0-6.5.9-9.2 2.6-.8.4-1.3.8-1.3 1.3 0 1.5 3.5 3.1 9.7 3.1 6.1 0 10.9-1.8 10.9-3.5.1-.3-.3-.6-1-1"/></svg>
\ No newline at end of file diff --git a/catalog-ui/app/styles/images/att_logo_white.png b/catalog-ui/src/assets/styles/images/att_logo_white.png Binary files differindex 6321b7582d..6321b7582d 100644 --- a/catalog-ui/app/styles/images/att_logo_white.png +++ b/catalog-ui/src/assets/styles/images/att_logo_white.png diff --git a/catalog-ui/app/styles/images/relationship-icons/AttachesTo.svg b/catalog-ui/src/assets/styles/images/relationship-icons/AttachesTo.svg index 68b57a08c8..68b57a08c8 100644 --- a/catalog-ui/app/styles/images/relationship-icons/AttachesTo.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/AttachesTo.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/BindsTo.svg b/catalog-ui/src/assets/styles/images/relationship-icons/BindsTo.svg index ae5647dda9..ae5647dda9 100644 --- a/catalog-ui/app/styles/images/relationship-icons/BindsTo.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/BindsTo.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/ConnectedTo.svg b/catalog-ui/src/assets/styles/images/relationship-icons/ConnectedTo.svg index 4ee7672305..4ee7672305 100644 --- a/catalog-ui/app/styles/images/relationship-icons/ConnectedTo.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/ConnectedTo.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/DependsOn.svg b/catalog-ui/src/assets/styles/images/relationship-icons/DependsOn.svg index e38808e2df..e38808e2df 100644 --- a/catalog-ui/app/styles/images/relationship-icons/DependsOn.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/DependsOn.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/HostedOn.svg b/catalog-ui/src/assets/styles/images/relationship-icons/HostedOn.svg index 5daf84a334..5daf84a334 100644 --- a/catalog-ui/app/styles/images/relationship-icons/HostedOn.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/HostedOn.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/LinksTo.svg b/catalog-ui/src/assets/styles/images/relationship-icons/LinksTo.svg index fb4c687774..fb4c687774 100644 --- a/catalog-ui/app/styles/images/relationship-icons/LinksTo.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/LinksTo.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/RoutesTo.svg b/catalog-ui/src/assets/styles/images/relationship-icons/RoutesTo.svg index 4c3caf5886..4c3caf5886 100644 --- a/catalog-ui/app/styles/images/relationship-icons/RoutesTo.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/RoutesTo.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/arrow.png b/catalog-ui/src/assets/styles/images/relationship-icons/arrow.png Binary files differindex d7c0ec8a86..d7c0ec8a86 100644 --- a/catalog-ui/app/styles/images/relationship-icons/arrow.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/arrow.png diff --git a/catalog-ui/app/styles/images/relationship-icons/arrow.svg b/catalog-ui/src/assets/styles/images/relationship-icons/arrow.svg index 4696e50d57..4696e50d57 100644 --- a/catalog-ui/app/styles/images/relationship-icons/arrow.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/arrow.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/arrow_connection_right.svg b/catalog-ui/src/assets/styles/images/relationship-icons/arrow_connection_right.svg index ea2d9f258d..ea2d9f258d 100644 --- a/catalog-ui/app/styles/images/relationship-icons/arrow_connection_right.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/arrow_connection_right.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/attach.png b/catalog-ui/src/assets/styles/images/relationship-icons/attach.png Binary files differindex f01ebd86ca..f01ebd86ca 100644 --- a/catalog-ui/app/styles/images/relationship-icons/attach.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/attach.png diff --git a/catalog-ui/app/styles/images/relationship-icons/binding.png b/catalog-ui/src/assets/styles/images/relationship-icons/binding.png Binary files differindex 15307d8267..15307d8267 100644 --- a/catalog-ui/app/styles/images/relationship-icons/binding.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/binding.png diff --git a/catalog-ui/app/styles/images/relationship-icons/conected.png b/catalog-ui/src/assets/styles/images/relationship-icons/conected.png Binary files differindex 1243146c3f..1243146c3f 100644 --- a/catalog-ui/app/styles/images/relationship-icons/conected.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/conected.png diff --git a/catalog-ui/app/styles/images/relationship-icons/conected.svg b/catalog-ui/src/assets/styles/images/relationship-icons/conected.svg index 4ee7672305..4ee7672305 100644 --- a/catalog-ui/app/styles/images/relationship-icons/conected.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/conected.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/dependency.png b/catalog-ui/src/assets/styles/images/relationship-icons/dependency.png Binary files differindex 1bfd3e41c6..1bfd3e41c6 100644 --- a/catalog-ui/app/styles/images/relationship-icons/dependency.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/dependency.png diff --git a/catalog-ui/app/styles/images/relationship-icons/host.png b/catalog-ui/src/assets/styles/images/relationship-icons/host.png Binary files differindex cf314d1d4a..cf314d1d4a 100644 --- a/catalog-ui/app/styles/images/relationship-icons/host.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/host.png diff --git a/catalog-ui/app/styles/images/relationship-icons/link.png b/catalog-ui/src/assets/styles/images/relationship-icons/link.png Binary files differindex 9b81a4de57..9b81a4de57 100644 --- a/catalog-ui/app/styles/images/relationship-icons/link.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/link.png diff --git a/catalog-ui/app/styles/images/relationship-icons/local_storage.png b/catalog-ui/src/assets/styles/images/relationship-icons/local_storage.png Binary files differindex f01ebd86ca..f01ebd86ca 100644 --- a/catalog-ui/app/styles/images/relationship-icons/local_storage.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/local_storage.png diff --git a/catalog-ui/app/styles/images/relationship-icons/local_storage.svg b/catalog-ui/src/assets/styles/images/relationship-icons/local_storage.svg index e255a4f058..e255a4f058 100644 --- a/catalog-ui/app/styles/images/relationship-icons/local_storage.svg +++ b/catalog-ui/src/assets/styles/images/relationship-icons/local_storage.svg diff --git a/catalog-ui/app/styles/images/relationship-icons/rout.png b/catalog-ui/src/assets/styles/images/relationship-icons/rout.png Binary files differindex 6a3aefac44..6a3aefac44 100644 --- a/catalog-ui/app/styles/images/relationship-icons/rout.png +++ b/catalog-ui/src/assets/styles/images/relationship-icons/rout.png diff --git a/catalog-ui/app/styles/images/resource-icons/Red_PLUS_HOVER.png b/catalog-ui/src/assets/styles/images/resource-icons/Red_PLUS_HOVER.png Binary files differindex eb623b0204..eb623b0204 100644 --- a/catalog-ui/app/styles/images/resource-icons/Red_PLUS_HOVER.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Red_PLUS_HOVER.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_COLLABORATION-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_COLLABORATION-.png Binary files differindex b0de76e4eb..b0de76e4eb 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_COLLABORATION-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_COLLABORATION-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_COMPUTE-AS-SERVICE-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_COMPUTE-AS-SERVICE-.png Binary files differindex ec2723b766..ec2723b766 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_COMPUTE-AS-SERVICE-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_COMPUTE-AS-SERVICE-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_MESSAGING-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_MESSAGING-.png Binary files differindex e745e20604..e745e20604 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_MESSAGING-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_MESSAGING-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_MOBILITY.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_MOBILITY.png Binary files differindex 4993ffe1f5..4993ffe1f5 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_MOBILITY.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_MOBILITY.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-.png Binary files differindex fb7a2518c2..fb7a2518c2 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-CLOUD-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-CLOUD-.png Binary files differindex a06093726a..a06093726a 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-CLOUD-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-CLOUD-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-1-3.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-1-3.png Binary files differindex a9f876afd9..a9f876afd9 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-1-3.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-1-3.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-4.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-4.png Binary files differindex e1023e743b..e1023e743b 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-4.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NETWORK-L-4.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NOTIFICATION-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NOTIFICATION-.png Binary files differindex dfa21d6d34..dfa21d6d34 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_NOTIFICATION-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_NOTIFICATION-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_ORPHAN.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_ORPHAN.png Binary files differindex 91619e0ae8..91619e0ae8 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_ORPHAN.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_ORPHAN.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_PLATFORM-AS-SERVICE-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_PLATFORM-AS-SERVICE-.png Binary files differindex 8c763391e6..8c763391e6 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_PLATFORM-AS-SERVICE-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_PLATFORM-AS-SERVICE-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_SECURITY-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_SECURITY-.png Binary files differindex c015ffe569..c015ffe569 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_SECURITY-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_SECURITY-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_SETTING-.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_SETTING-.png Binary files differindex b9db3ced5a..b9db3ced5a 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_SETTING-.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_SETTING-.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_avater.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_avater.png Binary files differindex 209e6e7e34..209e6e7e34 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_NB_avater.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_NB_avater.png diff --git a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_STORAGE-AS-SERVICE.png b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_STORAGE-AS-SERVICE.png Binary files differindex 86111d0842..86111d0842 100644 --- a/catalog-ui/app/styles/images/resource-icons/Resource_Icons_STORAGE-AS-SERVICE.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/Resource_Icons_STORAGE-AS-SERVICE.png diff --git a/catalog-ui/app/styles/images/resource-icons/alcatelLucent.png b/catalog-ui/src/assets/styles/images/resource-icons/alcatelLucent.png Binary files differindex 259096fea4..259096fea4 100644 --- a/catalog-ui/app/styles/images/resource-icons/alcatelLucent.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/alcatelLucent.png diff --git a/catalog-ui/src/assets/styles/images/resource-icons/allotted_resource.png b/catalog-ui/src/assets/styles/images/resource-icons/allotted_resource.png Binary files differnew file mode 100644 index 0000000000..c494e89e19 --- /dev/null +++ b/catalog-ui/src/assets/styles/images/resource-icons/allotted_resource.png diff --git a/catalog-ui/app/styles/images/resource-icons/applicationServer.png b/catalog-ui/src/assets/styles/images/resource-icons/applicationServer.png Binary files differindex f50b392249..f50b392249 100644 --- a/catalog-ui/app/styles/images/resource-icons/applicationServer.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/applicationServer.png diff --git a/catalog-ui/app/styles/images/resource-icons/aricent.png b/catalog-ui/src/assets/styles/images/resource-icons/aricent.png Binary files differindex 6cc36f679f..6cc36f679f 100644 --- a/catalog-ui/app/styles/images/resource-icons/aricent.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/aricent.png diff --git a/catalog-ui/app/styles/images/resource-icons/att.png b/catalog-ui/src/assets/styles/images/resource-icons/att.png Binary files differindex 80a814a34f..80a814a34f 100644 --- a/catalog-ui/app/styles/images/resource-icons/att.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/att.png diff --git a/catalog-ui/app/styles/images/resource-icons/borderElement.png b/catalog-ui/src/assets/styles/images/resource-icons/borderElement.png Binary files differindex b3525c2e55..b3525c2e55 100644 --- a/catalog-ui/app/styles/images/resource-icons/borderElement.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/borderElement.png diff --git a/catalog-ui/app/styles/images/resource-icons/broadsoft.png b/catalog-ui/src/assets/styles/images/resource-icons/broadsoft.png Binary files differindex 2539d30d57..2539d30d57 100644 --- a/catalog-ui/app/styles/images/resource-icons/broadsoft.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/broadsoft.png diff --git a/catalog-ui/app/styles/images/resource-icons/brocade.png b/catalog-ui/src/assets/styles/images/resource-icons/brocade.png Binary files differindex 29b713105c..29b713105c 100644 --- a/catalog-ui/app/styles/images/resource-icons/brocade.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/brocade.png diff --git a/catalog-ui/app/styles/images/resource-icons/call_controll.png b/catalog-ui/src/assets/styles/images/resource-icons/call_controll.png Binary files differindex afedac5ad3..afedac5ad3 100644 --- a/catalog-ui/app/styles/images/resource-icons/call_controll.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/call_controll.png diff --git a/catalog-ui/app/styles/images/resource-icons/canvasPlusIcon-red.png b/catalog-ui/src/assets/styles/images/resource-icons/canvasPlusIcon-red.png Binary files differindex bf56d13d6d..bf56d13d6d 100644 --- a/catalog-ui/app/styles/images/resource-icons/canvasPlusIcon-red.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/canvasPlusIcon-red.png diff --git a/catalog-ui/app/styles/images/resource-icons/canvasPlusIcon.png b/catalog-ui/src/assets/styles/images/resource-icons/canvasPlusIcon.png Binary files differindex f2c289cea6..f2c289cea6 100644 --- a/catalog-ui/app/styles/images/resource-icons/canvasPlusIcon.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/canvasPlusIcon.png diff --git a/catalog-ui/app/styles/images/resource-icons/cisco.png b/catalog-ui/src/assets/styles/images/resource-icons/cisco.png Binary files differindex e83c771bf3..e83c771bf3 100644 --- a/catalog-ui/app/styles/images/resource-icons/cisco.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/cisco.png diff --git a/catalog-ui/app/styles/images/resource-icons/closeModule.png b/catalog-ui/src/assets/styles/images/resource-icons/closeModule.png Binary files differindex 994cf2c4a5..994cf2c4a5 100644 --- a/catalog-ui/app/styles/images/resource-icons/closeModule.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/closeModule.png diff --git a/catalog-ui/app/styles/images/resource-icons/closeModuleHover.png b/catalog-ui/src/assets/styles/images/resource-icons/closeModuleHover.png Binary files differindex 47f7cb2c6a..47f7cb2c6a 100644 --- a/catalog-ui/app/styles/images/resource-icons/closeModuleHover.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/closeModuleHover.png diff --git a/catalog-ui/app/styles/images/resource-icons/cloud.png b/catalog-ui/src/assets/styles/images/resource-icons/cloud.png Binary files differindex 8e4c77694e..8e4c77694e 100644 --- a/catalog-ui/app/styles/images/resource-icons/cloud.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/cloud.png diff --git a/catalog-ui/app/styles/images/resource-icons/cloudep.png b/catalog-ui/src/assets/styles/images/resource-icons/cloudep.png Binary files differindex bdaadbd272..bdaadbd272 100644 --- a/catalog-ui/app/styles/images/resource-icons/cloudep.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/cloudep.png diff --git a/catalog-ui/app/styles/images/resource-icons/compute.png b/catalog-ui/src/assets/styles/images/resource-icons/compute.png Binary files differindex 6deb0a0db6..6deb0a0db6 100644 --- a/catalog-ui/app/styles/images/resource-icons/compute.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/compute.png diff --git a/catalog-ui/app/styles/images/resource-icons/connector.png b/catalog-ui/src/assets/styles/images/resource-icons/connector.png Binary files differindex c479eea892..c479eea892 100644 --- a/catalog-ui/app/styles/images/resource-icons/connector.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/connector.png diff --git a/catalog-ui/app/styles/images/resource-icons/cp.png b/catalog-ui/src/assets/styles/images/resource-icons/cp.png Binary files differindex f337d35afa..f337d35afa 100644 --- a/catalog-ui/app/styles/images/resource-icons/cp.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/cp.png diff --git a/catalog-ui/app/styles/images/resource-icons/database.png b/catalog-ui/src/assets/styles/images/resource-icons/database.png Binary files differindex b2e7684222..b2e7684222 100644 --- a/catalog-ui/app/styles/images/resource-icons/database.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/database.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_analytics.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_analytics.png Binary files differindex dd7180479d..dd7180479d 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_analytics.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_analytics.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_collector.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_collector.png Binary files differindex 2870362601..2870362601 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_collector.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_collector.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_database.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_database.png Binary files differindex b2e7684222..b2e7684222 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_database.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_database.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_microservice.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_microservice.png Binary files differindex 933abb106e..933abb106e 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_microservice.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_microservice.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_policy.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_policy.png Binary files differindex befb65ecc6..befb65ecc6 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_policy.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_policy.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_source.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_source.png Binary files differindex 58bfa34553..58bfa34553 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_source.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_source.png diff --git a/catalog-ui/app/styles/images/resource-icons/dcae_utilty.png b/catalog-ui/src/assets/styles/images/resource-icons/dcae_utilty.png Binary files differindex fd68ebf135..fd68ebf135 100644 --- a/catalog-ui/app/styles/images/resource-icons/dcae_utilty.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/dcae_utilty.png diff --git a/catalog-ui/app/styles/images/resource-icons/default.png b/catalog-ui/src/assets/styles/images/resource-icons/default.png Binary files differindex 91619e0ae8..91619e0ae8 100644 --- a/catalog-ui/app/styles/images/resource-icons/default.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/default.png diff --git a/catalog-ui/app/styles/images/resource-icons/defaulticon.png b/catalog-ui/src/assets/styles/images/resource-icons/defaulticon.png Binary files differindex 168859d253..168859d253 100644 --- a/catalog-ui/app/styles/images/resource-icons/defaulticon.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/defaulticon.png diff --git a/catalog-ui/app/styles/images/resource-icons/ericsson.png b/catalog-ui/src/assets/styles/images/resource-icons/ericsson.png Binary files differindex 7e3147593e..7e3147593e 100644 --- a/catalog-ui/app/styles/images/resource-icons/ericsson.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/ericsson.png diff --git a/catalog-ui/app/styles/images/resource-icons/firewall.png b/catalog-ui/src/assets/styles/images/resource-icons/firewall.png Binary files differindex 5650f2276d..5650f2276d 100644 --- a/catalog-ui/app/styles/images/resource-icons/firewall.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/firewall.png diff --git a/catalog-ui/app/styles/images/resource-icons/fortinet.png b/catalog-ui/src/assets/styles/images/resource-icons/fortinet.png Binary files differindex e4e52be0c4..e4e52be0c4 100644 --- a/catalog-ui/app/styles/images/resource-icons/fortinet.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/fortinet.png diff --git a/catalog-ui/app/styles/images/resource-icons/gateway.png b/catalog-ui/src/assets/styles/images/resource-icons/gateway.png Binary files differindex 478a3af494..478a3af494 100644 --- a/catalog-ui/app/styles/images/resource-icons/gateway.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/gateway.png diff --git a/catalog-ui/app/styles/images/resource-icons/juniper.png b/catalog-ui/src/assets/styles/images/resource-icons/juniper.png Binary files differindex ed9b183b3b..ed9b183b3b 100644 --- a/catalog-ui/app/styles/images/resource-icons/juniper.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/juniper.png diff --git a/catalog-ui/app/styles/images/resource-icons/loadBalancer.png b/catalog-ui/src/assets/styles/images/resource-icons/loadBalancer.png Binary files differindex 5c5e555883..5c5e555883 100644 --- a/catalog-ui/app/styles/images/resource-icons/loadBalancer.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/loadBalancer.png diff --git a/catalog-ui/app/styles/images/resource-icons/metaswitch.png b/catalog-ui/src/assets/styles/images/resource-icons/metaswitch.png Binary files differindex 970dfdd756..970dfdd756 100644 --- a/catalog-ui/app/styles/images/resource-icons/metaswitch.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/metaswitch.png diff --git a/catalog-ui/app/styles/images/resource-icons/module.png b/catalog-ui/src/assets/styles/images/resource-icons/module.png Binary files differindex 24574f5ac8..24574f5ac8 100644 --- a/catalog-ui/app/styles/images/resource-icons/module.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/module.png diff --git a/catalog-ui/app/styles/images/resource-icons/mysql.png b/catalog-ui/src/assets/styles/images/resource-icons/mysql.png Binary files differindex 07eeaa7d2a..07eeaa7d2a 100644 --- a/catalog-ui/app/styles/images/resource-icons/mysql.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/mysql.png diff --git a/catalog-ui/app/styles/images/resource-icons/network.png b/catalog-ui/src/assets/styles/images/resource-icons/network.png Binary files differindex c98eef324e..c98eef324e 100644 --- a/catalog-ui/app/styles/images/resource-icons/network.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/network.png diff --git a/catalog-ui/app/styles/images/resource-icons/networkrules.png b/catalog-ui/src/assets/styles/images/resource-icons/networkrules.png Binary files differindex 4fe91fa7e5..4fe91fa7e5 100644 --- a/catalog-ui/app/styles/images/resource-icons/networkrules.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/networkrules.png diff --git a/catalog-ui/app/styles/images/resource-icons/nokia_siemens.png b/catalog-ui/src/assets/styles/images/resource-icons/nokia_siemens.png Binary files differindex 37a702d79f..37a702d79f 100644 --- a/catalog-ui/app/styles/images/resource-icons/nokia_siemens.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/nokia_siemens.png diff --git a/catalog-ui/app/styles/images/resource-icons/objectStorage.png b/catalog-ui/src/assets/styles/images/resource-icons/objectStorage.png Binary files differindex 27212b71c8..27212b71c8 100644 --- a/catalog-ui/app/styles/images/resource-icons/objectStorage.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/objectStorage.png diff --git a/catalog-ui/app/styles/images/resource-icons/openModule.png b/catalog-ui/src/assets/styles/images/resource-icons/openModule.png Binary files differindex 291d0c0361..291d0c0361 100644 --- a/catalog-ui/app/styles/images/resource-icons/openModule.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/openModule.png diff --git a/catalog-ui/app/styles/images/resource-icons/openModuleHover.png b/catalog-ui/src/assets/styles/images/resource-icons/openModuleHover.png Binary files differindex 0206c5e4d3..0206c5e4d3 100644 --- a/catalog-ui/app/styles/images/resource-icons/openModuleHover.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/openModuleHover.png diff --git a/catalog-ui/app/styles/images/resource-icons/oracle.png b/catalog-ui/src/assets/styles/images/resource-icons/oracle.png Binary files differindex b58acc0823..b58acc0823 100644 --- a/catalog-ui/app/styles/images/resource-icons/oracle.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/oracle.png diff --git a/catalog-ui/app/styles/images/resource-icons/ossep.png b/catalog-ui/src/assets/styles/images/resource-icons/ossep.png Binary files differindex 0c921dbc76..0c921dbc76 100644 --- a/catalog-ui/app/styles/images/resource-icons/ossep.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/ossep.png diff --git a/catalog-ui/app/styles/images/resource-icons/personep.png b/catalog-ui/src/assets/styles/images/resource-icons/personep.png Binary files differindex 5b743b62d2..5b743b62d2 100644 --- a/catalog-ui/app/styles/images/resource-icons/personep.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/personep.png diff --git a/catalog-ui/app/styles/images/resource-icons/port.png b/catalog-ui/src/assets/styles/images/resource-icons/port.png Binary files differindex 95285b5b61..95285b5b61 100644 --- a/catalog-ui/app/styles/images/resource-icons/port.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/port.png diff --git a/catalog-ui/app/styles/images/resource-icons/premisesep.png b/catalog-ui/src/assets/styles/images/resource-icons/premisesep.png Binary files differindex bedd82073f..bedd82073f 100644 --- a/catalog-ui/app/styles/images/resource-icons/premisesep.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/premisesep.png diff --git a/catalog-ui/app/styles/images/resource-icons/router.png b/catalog-ui/src/assets/styles/images/resource-icons/router.png Binary files differindex 27d4897f33..27d4897f33 100644 --- a/catalog-ui/app/styles/images/resource-icons/router.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/router.png diff --git a/catalog-ui/app/styles/images/resource-icons/securityrules.png b/catalog-ui/src/assets/styles/images/resource-icons/securityrules.png Binary files differindex 520ab278cb..520ab278cb 100644 --- a/catalog-ui/app/styles/images/resource-icons/securityrules.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/securityrules.png diff --git a/catalog-ui/app/styles/images/resource-icons/selectedCPInstance.png b/catalog-ui/src/assets/styles/images/resource-icons/selectedCPInstance.png Binary files differindex 2f63077037..2f63077037 100644 --- a/catalog-ui/app/styles/images/resource-icons/selectedCPInstance.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/selectedCPInstance.png diff --git a/catalog-ui/app/styles/images/resource-icons/selectedInstance.png b/catalog-ui/src/assets/styles/images/resource-icons/selectedInstance.png Binary files differindex f2f5c90ac9..f2f5c90ac9 100644 --- a/catalog-ui/app/styles/images/resource-icons/selectedInstance.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/selectedInstance.png diff --git a/catalog-ui/app/styles/images/resource-icons/selectedUcpeInstance.png b/catalog-ui/src/assets/styles/images/resource-icons/selectedUcpeInstance.png Binary files differindex f168929ed6..f168929ed6 100644 --- a/catalog-ui/app/styles/images/resource-icons/selectedUcpeInstance.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/selectedUcpeInstance.png diff --git a/catalog-ui/app/styles/images/resource-icons/selectedVLInstance.png b/catalog-ui/src/assets/styles/images/resource-icons/selectedVLInstance.png Binary files differindex 17407f2609..17407f2609 100644 --- a/catalog-ui/app/styles/images/resource-icons/selectedVLInstance.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/selectedVLInstance.png diff --git a/catalog-ui/app/styles/images/resource-icons/server.png b/catalog-ui/src/assets/styles/images/resource-icons/server.png Binary files differindex b51305d58f..b51305d58f 100644 --- a/catalog-ui/app/styles/images/resource-icons/server.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/server.png diff --git a/catalog-ui/app/styles/images/resource-icons/tropo.png b/catalog-ui/src/assets/styles/images/resource-icons/tropo.png Binary files differindex 88a5ea5e68..88a5ea5e68 100644 --- a/catalog-ui/app/styles/images/resource-icons/tropo.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/tropo.png diff --git a/catalog-ui/app/styles/images/resource-icons/ucpe.png b/catalog-ui/src/assets/styles/images/resource-icons/ucpe.png Binary files differindex 8e8e430e3c..8e8e430e3c 100644 --- a/catalog-ui/app/styles/images/resource-icons/ucpe.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/ucpe.png diff --git a/catalog-ui/app/styles/images/resource-icons/uncertified.png b/catalog-ui/src/assets/styles/images/resource-icons/uncertified.png Binary files differindex 35d747a7d0..35d747a7d0 100644 --- a/catalog-ui/app/styles/images/resource-icons/uncertified.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/uncertified.png diff --git a/catalog-ui/app/styles/images/resource-icons/vfw.png b/catalog-ui/src/assets/styles/images/resource-icons/vfw.png Binary files differindex b8adc1f09c..b8adc1f09c 100644 --- a/catalog-ui/app/styles/images/resource-icons/vfw.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/vfw.png diff --git a/catalog-ui/app/styles/images/resource-icons/vl.png b/catalog-ui/src/assets/styles/images/resource-icons/vl.png Binary files differindex 1fb2fc07ce..1fb2fc07ce 100644 --- a/catalog-ui/app/styles/images/resource-icons/vl.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/vl.png diff --git a/catalog-ui/app/styles/images/resource-icons/vrouter.png b/catalog-ui/src/assets/styles/images/resource-icons/vrouter.png Binary files differindex 70e89e5125..70e89e5125 100644 --- a/catalog-ui/app/styles/images/resource-icons/vrouter.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/vrouter.png diff --git a/catalog-ui/app/styles/images/resource-icons/wanx.png b/catalog-ui/src/assets/styles/images/resource-icons/wanx.png Binary files differindex daa493a0f2..daa493a0f2 100644 --- a/catalog-ui/app/styles/images/resource-icons/wanx.png +++ b/catalog-ui/src/assets/styles/images/resource-icons/wanx.png diff --git a/catalog-ui/app/styles/images/service-icons/call_controll.png b/catalog-ui/src/assets/styles/images/service-icons/call_controll.png Binary files differindex ef1d92757e..ef1d92757e 100644 --- a/catalog-ui/app/styles/images/service-icons/call_controll.png +++ b/catalog-ui/src/assets/styles/images/service-icons/call_controll.png diff --git a/catalog-ui/app/styles/images/service-icons/collaboration.png b/catalog-ui/src/assets/styles/images/service-icons/collaboration.png Binary files differindex 3d34b914f5..3d34b914f5 100644 --- a/catalog-ui/app/styles/images/service-icons/collaboration.png +++ b/catalog-ui/src/assets/styles/images/service-icons/collaboration.png diff --git a/catalog-ui/app/styles/images/service-icons/collaboration1.png b/catalog-ui/src/assets/styles/images/service-icons/collaboration1.png Binary files differindex 6780931e2b..6780931e2b 100644 --- a/catalog-ui/app/styles/images/service-icons/collaboration1.png +++ b/catalog-ui/src/assets/styles/images/service-icons/collaboration1.png diff --git a/catalog-ui/app/styles/images/service-icons/compute.png b/catalog-ui/src/assets/styles/images/service-icons/compute.png Binary files differindex cb2b127ef1..cb2b127ef1 100644 --- a/catalog-ui/app/styles/images/service-icons/compute.png +++ b/catalog-ui/src/assets/styles/images/service-icons/compute.png diff --git a/catalog-ui/app/styles/images/service-icons/defaulticon.png b/catalog-ui/src/assets/styles/images/service-icons/defaulticon.png Binary files differindex 5afead32d8..5afead32d8 100644 --- a/catalog-ui/app/styles/images/service-icons/defaulticon.png +++ b/catalog-ui/src/assets/styles/images/service-icons/defaulticon.png diff --git a/catalog-ui/app/styles/images/service-icons/messaging.png b/catalog-ui/src/assets/styles/images/service-icons/messaging.png Binary files differindex eb5f14d178..eb5f14d178 100644 --- a/catalog-ui/app/styles/images/service-icons/messaging.png +++ b/catalog-ui/src/assets/styles/images/service-icons/messaging.png diff --git a/catalog-ui/app/styles/images/service-icons/mobility.png b/catalog-ui/src/assets/styles/images/service-icons/mobility.png Binary files differindex 285c442aba..285c442aba 100644 --- a/catalog-ui/app/styles/images/service-icons/mobility.png +++ b/catalog-ui/src/assets/styles/images/service-icons/mobility.png diff --git a/catalog-ui/app/styles/images/service-icons/network_l_1-3.png b/catalog-ui/src/assets/styles/images/service-icons/network_l_1-3.png Binary files differindex 128c2bec8b..128c2bec8b 100644 --- a/catalog-ui/app/styles/images/service-icons/network_l_1-3.png +++ b/catalog-ui/src/assets/styles/images/service-icons/network_l_1-3.png diff --git a/catalog-ui/app/styles/images/service-icons/network_l_4.png b/catalog-ui/src/assets/styles/images/service-icons/network_l_4.png Binary files differindex 7b05e1b101..7b05e1b101 100644 --- a/catalog-ui/app/styles/images/service-icons/network_l_4.png +++ b/catalog-ui/src/assets/styles/images/service-icons/network_l_4.png diff --git a/catalog-ui/app/styles/images/service-icons/notification.png b/catalog-ui/src/assets/styles/images/service-icons/notification.png Binary files differindex a5de34c40f..a5de34c40f 100644 --- a/catalog-ui/app/styles/images/service-icons/notification.png +++ b/catalog-ui/src/assets/styles/images/service-icons/notification.png diff --git a/catalog-ui/app/styles/images/service-icons/platform.png b/catalog-ui/src/assets/styles/images/service-icons/platform.png Binary files differindex 934eae9136..934eae9136 100644 --- a/catalog-ui/app/styles/images/service-icons/platform.png +++ b/catalog-ui/src/assets/styles/images/service-icons/platform.png diff --git a/catalog-ui/app/styles/images/service-icons/storage.png b/catalog-ui/src/assets/styles/images/service-icons/storage.png Binary files differindex 9abfd2d3a4..9abfd2d3a4 100644 --- a/catalog-ui/app/styles/images/service-icons/storage.png +++ b/catalog-ui/src/assets/styles/images/service-icons/storage.png diff --git a/catalog-ui/app/styles/images/service-icons/uncertified.png b/catalog-ui/src/assets/styles/images/service-icons/uncertified.png Binary files differindex 35d747a7d0..35d747a7d0 100644 --- a/catalog-ui/app/styles/images/service-icons/uncertified.png +++ b/catalog-ui/src/assets/styles/images/service-icons/uncertified.png diff --git a/catalog-ui/app/styles/images/sprites/sprite-global-old.png b/catalog-ui/src/assets/styles/images/sprites/sprite-global-old.png Binary files differindex a1014f55d7..a1014f55d7 100644 --- a/catalog-ui/app/styles/images/sprites/sprite-global-old.png +++ b/catalog-ui/src/assets/styles/images/sprites/sprite-global-old.png diff --git a/catalog-ui/src/assets/styles/images/sprites/sprite-global.png b/catalog-ui/src/assets/styles/images/sprites/sprite-global.png Binary files differnew file mode 100644 index 0000000000..f684d2de9c --- /dev/null +++ b/catalog-ui/src/assets/styles/images/sprites/sprite-global.png diff --git a/catalog-ui/app/styles/images/sprites/sprite-product-icons.png b/catalog-ui/src/assets/styles/images/sprites/sprite-product-icons.png Binary files differindex e85467a09c..e85467a09c 100644 --- a/catalog-ui/app/styles/images/sprites/sprite-product-icons.png +++ b/catalog-ui/src/assets/styles/images/sprites/sprite-product-icons.png diff --git a/catalog-ui/app/styles/images/sprites/sprite-resource-icons.png b/catalog-ui/src/assets/styles/images/sprites/sprite-resource-icons.png Binary files differindex 61989d63e1..7d520a8628 100644 --- a/catalog-ui/app/styles/images/sprites/sprite-resource-icons.png +++ b/catalog-ui/src/assets/styles/images/sprites/sprite-resource-icons.png diff --git a/catalog-ui/app/styles/images/sprites/sprite-services-icons.png b/catalog-ui/src/assets/styles/images/sprites/sprite-services-icons.png Binary files differindex ac19fa186b..ac19fa186b 100644 --- a/catalog-ui/app/styles/images/sprites/sprite-services-icons.png +++ b/catalog-ui/src/assets/styles/images/sprites/sprite-services-icons.png diff --git a/catalog-ui/app/styles/images/sprites/tlv-sprite.png b/catalog-ui/src/assets/styles/images/sprites/tlv-sprite.png Binary files differindex 7f11c2ece1..7f11c2ece1 100644 --- a/catalog-ui/app/styles/images/sprites/tlv-sprite.png +++ b/catalog-ui/src/assets/styles/images/sprites/tlv-sprite.png diff --git a/catalog-ui/app/styles/images/tutorial/10.png b/catalog-ui/src/assets/styles/images/tutorial/10.png Binary files differindex 312d48f99a..312d48f99a 100644 --- a/catalog-ui/app/styles/images/tutorial/10.png +++ b/catalog-ui/src/assets/styles/images/tutorial/10.png diff --git a/catalog-ui/app/styles/images/tutorial/11.png b/catalog-ui/src/assets/styles/images/tutorial/11.png Binary files differindex 8c4f8aec39..8c4f8aec39 100644 --- a/catalog-ui/app/styles/images/tutorial/11.png +++ b/catalog-ui/src/assets/styles/images/tutorial/11.png diff --git a/catalog-ui/app/styles/images/tutorial/13.png b/catalog-ui/src/assets/styles/images/tutorial/13.png Binary files differindex d2c35ddb47..d2c35ddb47 100644 --- a/catalog-ui/app/styles/images/tutorial/13.png +++ b/catalog-ui/src/assets/styles/images/tutorial/13.png diff --git a/catalog-ui/app/styles/images/tutorial/14.png b/catalog-ui/src/assets/styles/images/tutorial/14.png Binary files differindex 0aabc9fd11..0aabc9fd11 100644 --- a/catalog-ui/app/styles/images/tutorial/14.png +++ b/catalog-ui/src/assets/styles/images/tutorial/14.png diff --git a/catalog-ui/app/styles/images/tutorial/15.png b/catalog-ui/src/assets/styles/images/tutorial/15.png Binary files differindex d6720989c2..d6720989c2 100644 --- a/catalog-ui/app/styles/images/tutorial/15.png +++ b/catalog-ui/src/assets/styles/images/tutorial/15.png diff --git a/catalog-ui/app/styles/images/tutorial/16.png b/catalog-ui/src/assets/styles/images/tutorial/16.png Binary files differindex 95005bd5a2..95005bd5a2 100644 --- a/catalog-ui/app/styles/images/tutorial/16.png +++ b/catalog-ui/src/assets/styles/images/tutorial/16.png diff --git a/catalog-ui/app/styles/images/tutorial/17.png b/catalog-ui/src/assets/styles/images/tutorial/17.png Binary files differindex c22875e6d3..c22875e6d3 100644 --- a/catalog-ui/app/styles/images/tutorial/17.png +++ b/catalog-ui/src/assets/styles/images/tutorial/17.png diff --git a/catalog-ui/app/styles/images/tutorial/18.png b/catalog-ui/src/assets/styles/images/tutorial/18.png Binary files differindex e5b9b5a8b0..e5b9b5a8b0 100644 --- a/catalog-ui/app/styles/images/tutorial/18.png +++ b/catalog-ui/src/assets/styles/images/tutorial/18.png diff --git a/catalog-ui/app/styles/images/tutorial/19.png b/catalog-ui/src/assets/styles/images/tutorial/19.png Binary files differindex f7374928ba..f7374928ba 100644 --- a/catalog-ui/app/styles/images/tutorial/19.png +++ b/catalog-ui/src/assets/styles/images/tutorial/19.png diff --git a/catalog-ui/app/styles/images/tutorial/2.png b/catalog-ui/src/assets/styles/images/tutorial/2.png Binary files differindex 4e141bd764..4e141bd764 100644 --- a/catalog-ui/app/styles/images/tutorial/2.png +++ b/catalog-ui/src/assets/styles/images/tutorial/2.png diff --git a/catalog-ui/app/styles/images/tutorial/20.png b/catalog-ui/src/assets/styles/images/tutorial/20.png Binary files differindex c3849b0a17..c3849b0a17 100644 --- a/catalog-ui/app/styles/images/tutorial/20.png +++ b/catalog-ui/src/assets/styles/images/tutorial/20.png diff --git a/catalog-ui/app/styles/images/tutorial/21.png b/catalog-ui/src/assets/styles/images/tutorial/21.png Binary files differindex aa60a153a0..aa60a153a0 100644 --- a/catalog-ui/app/styles/images/tutorial/21.png +++ b/catalog-ui/src/assets/styles/images/tutorial/21.png diff --git a/catalog-ui/app/styles/images/tutorial/22.png b/catalog-ui/src/assets/styles/images/tutorial/22.png Binary files differindex 0d4a71c1e4..0d4a71c1e4 100644 --- a/catalog-ui/app/styles/images/tutorial/22.png +++ b/catalog-ui/src/assets/styles/images/tutorial/22.png diff --git a/catalog-ui/app/styles/images/tutorial/23.png b/catalog-ui/src/assets/styles/images/tutorial/23.png Binary files differindex 6854d0e4e5..6854d0e4e5 100644 --- a/catalog-ui/app/styles/images/tutorial/23.png +++ b/catalog-ui/src/assets/styles/images/tutorial/23.png diff --git a/catalog-ui/app/styles/images/tutorial/24.png b/catalog-ui/src/assets/styles/images/tutorial/24.png Binary files differindex 099fa28874..099fa28874 100644 --- a/catalog-ui/app/styles/images/tutorial/24.png +++ b/catalog-ui/src/assets/styles/images/tutorial/24.png diff --git a/catalog-ui/app/styles/images/tutorial/25.png b/catalog-ui/src/assets/styles/images/tutorial/25.png Binary files differindex 718cf4a65f..718cf4a65f 100644 --- a/catalog-ui/app/styles/images/tutorial/25.png +++ b/catalog-ui/src/assets/styles/images/tutorial/25.png diff --git a/catalog-ui/app/styles/images/tutorial/26.png b/catalog-ui/src/assets/styles/images/tutorial/26.png Binary files differindex cd4885ec4a..cd4885ec4a 100644 --- a/catalog-ui/app/styles/images/tutorial/26.png +++ b/catalog-ui/src/assets/styles/images/tutorial/26.png diff --git a/catalog-ui/app/styles/images/tutorial/27.png b/catalog-ui/src/assets/styles/images/tutorial/27.png Binary files differindex 85c7378e39..85c7378e39 100644 --- a/catalog-ui/app/styles/images/tutorial/27.png +++ b/catalog-ui/src/assets/styles/images/tutorial/27.png diff --git a/catalog-ui/app/styles/images/tutorial/28.png b/catalog-ui/src/assets/styles/images/tutorial/28.png Binary files differindex 54c5ada0d7..54c5ada0d7 100644 --- a/catalog-ui/app/styles/images/tutorial/28.png +++ b/catalog-ui/src/assets/styles/images/tutorial/28.png diff --git a/catalog-ui/app/styles/images/tutorial/29.png b/catalog-ui/src/assets/styles/images/tutorial/29.png Binary files differindex ae07010492..ae07010492 100644 --- a/catalog-ui/app/styles/images/tutorial/29.png +++ b/catalog-ui/src/assets/styles/images/tutorial/29.png diff --git a/catalog-ui/app/styles/images/tutorial/3.png b/catalog-ui/src/assets/styles/images/tutorial/3.png Binary files differindex ff1a86b4d0..ff1a86b4d0 100644 --- a/catalog-ui/app/styles/images/tutorial/3.png +++ b/catalog-ui/src/assets/styles/images/tutorial/3.png diff --git a/catalog-ui/app/styles/images/tutorial/30.png b/catalog-ui/src/assets/styles/images/tutorial/30.png Binary files differindex ef83db0e01..ef83db0e01 100644 --- a/catalog-ui/app/styles/images/tutorial/30.png +++ b/catalog-ui/src/assets/styles/images/tutorial/30.png diff --git a/catalog-ui/app/styles/images/tutorial/4.png b/catalog-ui/src/assets/styles/images/tutorial/4.png Binary files differindex dfc148868e..dfc148868e 100644 --- a/catalog-ui/app/styles/images/tutorial/4.png +++ b/catalog-ui/src/assets/styles/images/tutorial/4.png diff --git a/catalog-ui/app/styles/images/tutorial/5.png b/catalog-ui/src/assets/styles/images/tutorial/5.png Binary files differindex f18e52527d..f18e52527d 100644 --- a/catalog-ui/app/styles/images/tutorial/5.png +++ b/catalog-ui/src/assets/styles/images/tutorial/5.png diff --git a/catalog-ui/app/styles/images/tutorial/6.png b/catalog-ui/src/assets/styles/images/tutorial/6.png Binary files differindex 173dc55d1c..173dc55d1c 100644 --- a/catalog-ui/app/styles/images/tutorial/6.png +++ b/catalog-ui/src/assets/styles/images/tutorial/6.png diff --git a/catalog-ui/app/styles/images/tutorial/7.png b/catalog-ui/src/assets/styles/images/tutorial/7.png Binary files differindex 3e31376143..3e31376143 100644 --- a/catalog-ui/app/styles/images/tutorial/7.png +++ b/catalog-ui/src/assets/styles/images/tutorial/7.png diff --git a/catalog-ui/app/styles/images/tutorial/8.png b/catalog-ui/src/assets/styles/images/tutorial/8.png Binary files differindex 59f95dfa2e..59f95dfa2e 100644 --- a/catalog-ui/app/styles/images/tutorial/8.png +++ b/catalog-ui/src/assets/styles/images/tutorial/8.png diff --git a/catalog-ui/app/styles/images/welcome.png b/catalog-ui/src/assets/styles/images/welcome.png Binary files differindex 8534a33088..8534a33088 100644 --- a/catalog-ui/app/styles/images/welcome.png +++ b/catalog-ui/src/assets/styles/images/welcome.png diff --git a/catalog-ui/app/styles/images/welcome/bg/002.png b/catalog-ui/src/assets/styles/images/welcome/002.png Binary files differindex f3e7a7c3ed..f3e7a7c3ed 100644 --- a/catalog-ui/app/styles/images/welcome/bg/002.png +++ b/catalog-ui/src/assets/styles/images/welcome/002.png diff --git a/catalog-ui/app/styles/images/welcome/sprite.png b/catalog-ui/src/assets/styles/images/welcome/sprite.png Binary files differindex 3bb7542446..3bb7542446 100644 --- a/catalog-ui/app/styles/images/welcome/sprite.png +++ b/catalog-ui/src/assets/styles/images/welcome/sprite.png diff --git a/catalog-ui/app/styles/layout/header.less b/catalog-ui/src/assets/styles/layout/header.less index f8e95e8b41..f8e95e8b41 100644 --- a/catalog-ui/app/styles/layout/header.less +++ b/catalog-ui/src/assets/styles/layout/header.less diff --git a/catalog-ui/app/styles/layout/main.less b/catalog-ui/src/assets/styles/layout/main.less index 925da09431..54f6b87d7c 100644 --- a/catalog-ui/app/styles/layout/main.less +++ b/catalog-ui/src/assets/styles/layout/main.less @@ -8,7 +8,7 @@ top: @header_height + @top_nav_height; left: 0; right: 0; - bottom: 0; + bottom: @footer_height; .w-sdc-main-right-container { .bg_n; @@ -20,13 +20,23 @@ top: 0; overflow: hidden; - - & > div:first-child { /* scroll fix */ + & > div:first-child { padding-bottom: 80px; } + + .sdc-tile-catalog { + margin: 10px; + } + } } +.w-sdc-row-flex-items { + display: flex; + flex-wrap: wrap; + flex-direction: row; +} + .sdc-loading-page { display: flex; align-items: center; diff --git a/catalog-ui/app/styles/layout/sidebar.less b/catalog-ui/src/assets/styles/layout/sidebar.less index 9b8dc240c7..9b8dc240c7 100644 --- a/catalog-ui/app/styles/layout/sidebar.less +++ b/catalog-ui/src/assets/styles/layout/sidebar.less diff --git a/catalog-ui/app/styles/mixins.less b/catalog-ui/src/assets/styles/mixins.less index 7bd413ed05..7ce9906d88 100644 --- a/catalog-ui/app/styles/mixins.less +++ b/catalog-ui/src/assets/styles/mixins.less @@ -92,32 +92,6 @@ } } -.buildForColor(a); -.buildForColor(b); -.buildForColor(c); -.buildForColor(d); -.buildForColor(e); -.buildForColor(f); -.buildForColor(g); -.buildForColor(h); -.buildForColor(i); -.buildForColor(j); -.buildForColor(k); -.buildForColor(l); -.buildForColor(m); -.buildForColor(n); -.buildForColor(o); -.buildForColor(p); - -.buildForFuncColor(q); -.buildForFuncColor(r); -.buildForFuncColor(s); - -.buildForTlvColor(t); -.buildForTlvColor(u); -.buildForTlvColor(v); - - .buildForColor(@c){ .@{c}_36 { color: ~"@{main_color_@{c}}"; .f-type > ._36;} .@{c}_24 { color: ~"@{main_color_@{c}}"; .f-type > ._24;} @@ -173,6 +147,32 @@ .@{c}_12_i { color: ~"@{tlv_color_@{c}}"; .f-type > ._12_i;} } +.buildForColor(a); +.buildForColor(b); +.buildForColor(c); +.buildForColor(d); +.buildForColor(e); +.buildForColor(f); +.buildForColor(g); +.buildForColor(h); +.buildForColor(i); +.buildForColor(j); +.buildForColor(k); +.buildForColor(l); +.buildForColor(m); +.buildForColor(n); +.buildForColor(o); +.buildForColor(p); + +.buildForFuncColor(q); +.buildForFuncColor(r); +.buildForFuncColor(s); + +.buildForTlvColor(t); +.buildForTlvColor(u); +.buildForTlvColor(v); + + .disabled { opacity: 0.4 !important; cursor: auto; diff --git a/catalog-ui/app/styles/mixins_old.less b/catalog-ui/src/assets/styles/mixins_old.less index 8a4f609497..8a4f609497 100644 --- a/catalog-ui/app/styles/mixins_old.less +++ b/catalog-ui/src/assets/styles/mixins_old.less diff --git a/catalog-ui/app/styles/modal.less b/catalog-ui/src/assets/styles/modal.less index 7c8bcd7c1d..eb9de92f80 100644 --- a/catalog-ui/app/styles/modal.less +++ b/catalog-ui/src/assets/styles/modal.less @@ -177,6 +177,7 @@ NEW DESIGN MODAL box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.5); min-height: 165px; min-width: 430px; + word-wrap: break-word; .w-sdc-modal-head { flex-grow: 1; diff --git a/catalog-ui/src/assets/styles/multi-level-expand-collapse.less b/catalog-ui/src/assets/styles/multi-level-expand-collapse.less new file mode 100644 index 0000000000..090768f187 --- /dev/null +++ b/catalog-ui/src/assets/styles/multi-level-expand-collapse.less @@ -0,0 +1,33 @@ +.first-level{ + background-color: @tlv_color_u; + padding:8px 20px 8px 8px !important; + border-bottom: 1px solid rgba(0,0,0,0.1); + box-shadow: inset 0px -1px 0px 0px rgba(255, 255, 255, 0.7); + height: 40px; +} + +.second-level{ + background-color: @tlv_color_t; + padding:4px 20px 4px 37px !important; + border-bottom: 1px solid @main_color_o; + height: 30px; +} + +.expand-collapse-title-icon,.expand-collapse-title-text{ + vertical-align: middle; +} + +.expanded{ + .first-level,.second-level{ + background-color: @tlv_color_v; + border-left: solid @main_color_a 4px; + box-shadow: 0 0px 3px -1px rgba(0,0,0,0.3); + margin-bottom: 2px; + } + .first-level{ + padding-left: 4px !important; + } + .second-level{ + padding-left: 33px !important; + } +} diff --git a/catalog-ui/app/styles/scroller.less b/catalog-ui/src/assets/styles/scroller.less index fcdaf12f3f..fcdaf12f3f 100644 --- a/catalog-ui/app/styles/scroller.less +++ b/catalog-ui/src/assets/styles/scroller.less diff --git a/catalog-ui/src/assets/styles/sdc-ui.css b/catalog-ui/src/assets/styles/sdc-ui.css new file mode 100644 index 0000000000..5247ecda1a --- /dev/null +++ b/catalog-ui/src/assets/styles/sdc-ui.css @@ -0,0 +1,361 @@ +@charset "UTF-8"; +/* Colors */ +.sdc-bc-blue { + background-color: #009fdb; } + +.sdc-bc-dark-blue { + background-color: #0568ae; } + +.sdc-bc-light-blue { + background-color: #71c5e8; } + +.sdc-bc-green { + background-color: #4ca90c; } + +.sdc-bc-dark-green { + background-color: #007a3e; } + +.sdc-bc-light-green { + background-color: #b5bd00; } + +.sdc-bc-orange { + background-color: #ea7400; } + +.sdc-bc-yellow { + background-color: #ffb81c; } + +.sdc-bc-dark-purple { + background-color: #702f8a; } + +.sdc-bc-purple { + background-color: #9063cd; } + +.sdc-bc-light-purple { + background-color: #caa2dd; } + +.sdc-bc-black { + background-color: #000000; } + +.sdc-bc-dark-gray { + background-color: #5a5a5a; } + +.sdc-bc-gray { + background-color: #959595; } + +.sdc-bc-light-gray { + background-color: #d2d2d2; } + +.sdc-bc-white { + background-color: #ffffff; } + +/* Prefix */ +/* Value Prefix*/ +/* Box sizing */ +/* Borders & Shadows */ +/* Opacity */ +/* Ellipsis */ +/* Vertical placement of multuple lines of text */ +/* transform-rotate */ +/* transform-translate */ +/* transform-scale */ +/**/ +/**/ +/*body {*/ + /*-webkit-touch-callout: none;*/ + /*-webkit-user-select: none;*/ + /*-moz-user-select: none;*/ + /*-ms-user-select: none;*/ + /*user-select: none; }*/ + +html { + font-size: 100%; + height: 100%; } + +body { + /* scrollbar styling for Internet Explorer */ + scrollbar-face-color: #191919; + scrollbar-track-color: #191919; + height: 100%; } + +/* scrollbar styling for Google Chrome | Safari | Opera */ +::-webkit-scrollbar { + width: 8px; + height: 8px; } + +::-webkit-scrollbar-track { + background-color: transparent; + border-radius: 10px; } + +::-webkit-scrollbar-thumb { + border-radius: 10px; + background-color: #d2d2d2; + border-right: 2px solid #ffffff; } + +/* Mozilla Firefox currently doesn't support scrollbar styling */ +ul { + list-style: none; } + +h1, h2, h3, h4, h5, h6, ul { + margin: 0; + padding: 0; } + +.disabled { + opacity: 0.7 !important; } + +fieldset { + border: none; } + +fieldset label { + display: inline-block; } + +.nav-tabs > li > a:focus, +.btn:focus, +.btn:active:focus, +.btn.active:focus { + outline: none; } + +/* Fonts */ +.text-lowercase { + text-transform: lowercase; } + +.text-uppercase, .heading-3-light, .heading-3, .heading-3-medium { + text-transform: uppercase; } + +.text-capitalize { + text-transform: capitalize; } + +.heading-1 { + font-weight: 300; + font-size: 36px; } + +.heading-2 { + font-weight: 300; + font-size: 24px; } + +.heading-3-light { + font-weight: 300; + font-size: 20px; } + +.heading-3 { + font-weight: 400; + font-size: 20px; } + +.heading-3-medium { + font-weight: 600; + font-size: 20px; } + +.heading-4 { + font-weight: 400; + font-size: 18px; } + +.heading-4-medium { + font-weight: 600; + font-size: 18px; } + +.heading-5 { + font-weight: 400; + font-size: 16px; } + +.heading-5-medium, .catalog-tile .catalog-tile-top .catalog-tile-item-name, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-item-name { + font-weight: 400; + line-height: 16px; + font-size: 16px; } + +.body-1 { + font-weight: 400; + font-size: 14px; } + +.body-1-medium { + font-weight: 600; + font-size: 14px; } + +.body-1-light { + font-weight: 300; + font-size: 14px; } + +.body-2, .catalog-tile .catalog-tile-top .catalog-tile-entity-details .catalog-tile-version-info .catalog-tile-item-version, .catalog-tile .catalog-tile-content .catalog-tile-locking-user-name, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-version-info .sdc-tile-content-info-version-info-text, .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-text { + font-weight: 400; + font-size: 13px; } + +.body-2-medium, .catalog-tile .catalog-tile-content { + font-weight: 600; + font-size: 13px; } + +.body-3 { + font-weight: 400; + font-size: 12px; } + +.body-3-medium, .catalog-tile .catalog-tile-top .catalog-tile-entity-details .catalog-tile-vendor-name, .catalog-tile.vendor-type .catalog-tile-top .catalog-tile-vsp-count, .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-vendor-name { + font-weight: 600; + font-size: 12px; } + +.body-3-light { + font-weight: 300; + font-size: 12px; } + +.circle-icon-text { + font-weight: 600; + font-size: 14px; } + +.sdc-icon { + display: inline-block; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + width: 16px; + height: 16px; } + +.sdc-icon-locked { + background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='15' viewBox='0 0 11 15' id='locked_icon'> <metadata><?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Adobe XMP Core 5.6-c138 79.159824, 2016/09/14-01:09:01 '> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about=''/> </rdf:RDF></x:xmpmeta><?xpacket end='w'?></metadata><defs> <style> .cls-1 { fill: #959595; fill-rule: evenodd; } </style> </defs> <path id='Shape_77_copy_10' data-name='Shape 77 copy 10' class='cls-1' d='M445,359a16.71,16.71,0,0,0-2.1-.009c-1.945.045-3.195,0.049-3.9,0.009v-5a1.743,1.743,0,0,1,2-2h1a1.743,1.743,0,0,1,2,2v5c0.474,0.063.343-.073,1,0,0.266,0.029,0,.279,0,0v-5a2.726,2.726,0,0,0-3-3h-1.142c-1.72-.125-2.715,1.562-2.858,3,0.088,0.009,0,7.338,0,5h0a1.891,1.891,0,0,0-2,1.689v3.461A1.823,1.823,0,0,0,437.775,366h7.448A1.823,1.823,0,0,0,447,364.15v-3.461A2.018,2.018,0,0,0,445,359Z' transform='translate(-436 -351)'/></svg>"); + background-repeat: no-repeat; } + +.sdc-icon-plus { + background-image: url("data:image/svg+xml;utf8,<?xml version='1.0' encoding='utf-8'?><!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --><svg version='1.1' id='plus_icon' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 19 19' style='enable-background:new 0 0 19 19;' xml:space='preserve'><g><rect y='8' width='19' height='3'/><path id='Rectangle_2139_copy' d='M8,19V0h3v19H8z'/></g></svg>"); + background-repeat: no-repeat; } + +.sdc-icon-unlocked { + background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='18' viewBox='0 0 11 18' id='unlocked_icon'> <metadata><?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Adobe XMP Core 5.6-c138 79.159824, 2016/09/14-01:09:01 '> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about=''/> </rdf:RDF></x:xmpmeta><?xpacket end='w'?></metadata><defs> <style> .cls-1 { fill: #959595; fill-rule: evenodd; } </style> </defs> <path id='Shape_77_copy_16' data-name='Shape 77 copy 16' class='cls-1' d='M663,358a16.723,16.723,0,0,0-2.1-.009c-1.944.045-3.194,0.049-3.9,0.009v-7a1.743,1.743,0,0,1,2-2h1a1.743,1.743,0,0,1,2,2v2c0.474,0.064.343-.073,1,0,0.266,0.029,0,.279,0,0v-2a2.726,2.726,0,0,0-3-3h-1.142c-1.72-.125-2.715,1.562-2.858,3,0.088,0.009,0,9.338,0,7h0a1.891,1.891,0,0,0-2,1.689v4.461a1.823,1.823,0,0,0,1.775,1.85h7.448A1.823,1.823,0,0,0,665,364.15v-4.461A2.018,2.018,0,0,0,663,358Zm1.05,6.15a0.827,0.827,0,0,1-.8.836H655.8a0.827,0.827,0,0,1-.8-0.836l0-4.15a1.164,1.164,0,0,1,.8-1.147h7.448A1.129,1.129,0,0,1,664,360Z' transform='translate(-654 -348)'/></svg>"); + background-repeat: no-repeat; } + +.sdc-icon-vendor { + background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 53 47' id='vendor_icon'><title>vendor</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M49,7,38.5,7V5.92A5.92,5.92,0,0,0,32.58,0H20.42A5.92,5.92,0,0,0,14.5,5.92V7.15L4,7.2a3.8,3.8,0,0,0-4,3.5V43.5C0,45.4,2,47,4.2,47L49,46.8a3.8,3.8,0,0,0,4-3.5V10.5A3.8,3.8,0,0,0,49,7ZM16.5,5.92A3.92,3.92,0,0,1,20.42,2H32.58A3.92,3.92,0,0,1,36.5,5.92V7.06l-20,.09ZM2,10.8A1.9,1.9,0,0,1,4,9l45-.2a1.9,1.9,0,0,1,2,1.8v8.87L32.94,24.18a6.49,6.49,0,0,0-12.89,0L2,19.51V10.8ZM31,25a4.5,4.5,0,1,1-4.5-4.5A4.5,4.5,0,0,1,31,25ZM49,45,4,45.2A1.9,1.9,0,0,1,2,43.4V21.57l18.13,4.73a6.5,6.5,0,0,0,12.74,0L51,21.53V43.21A1.9,1.9,0,0,1,49,45Z'/></g></g></svg>"); + background-repeat: no-repeat; } + +.sdc-icon-vlm { + background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 45 53'><title>vlm_new_icon</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M41,2a2,2,0,0,1,2,2l.19,45a2,2,0,0,1-2,2H4a2,2,0,0,1-2-2L1.81,4a2,2,0,0,1,2-2H41m-.15-2H4A4.2,4.2,0,0,0,0,4.24L.19,49a4,4,0,0,0,4,4H41a4,4,0,0,0,4-4L44.81,4a4,4,0,0,0-4-4Z'/><rect x='14' y='11' width='17' height='2'/><rect x='14' y='18' width='10' height='2'/><polygon points='20.56 38.85 13.87 33.14 15.16 31.62 20.39 36.08 29.08 26.63 30.55 27.98 20.56 38.85'/></g></g></svg>"); + background-repeat: no-repeat; } + +.sdc-icon-vsp { + background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 59.5 40' id='vsp_icon'><title>vsp_new_icon</title><g id='Layer_2' data-name='Layer 2'><g id='vlm_icon' data-name='vlm icon'><path d='M58.28,30.74c-1.49-1.82-3-2.7-4.67-2.74a8.5,8.5,0,0,0-16.22-2.44,6.93,6.93,0,0,0-4.06.66A7.23,7.23,0,0,0,36.42,40H53.5a6,6,0,0,0,6-6A5.18,5.18,0,0,0,58.28,30.74ZM53.5,38H36.42a5.25,5.25,0,0,1-5.21-5.91,5.32,5.32,0,0,1,3-4.06,5,5,0,0,1,2.21-.53,5.25,5.25,0,0,1,1.35.18l.92.24L39,27A6.5,6.5,0,0,1,51.67,29v1.3l1.17-.2c1-.17,2.17-.17,3.91,2a3.18,3.18,0,0,1,.76,2A4,4,0,0,1,53.5,38Z'/><path d='M49,0,4,.17A3.79,3.79,0,0,0,0,3.69V7.94H0v2H0V36.31C0,38.35,2,40,4.25,40l20.84-.08a1,1,0,0,0,0-1.92L4,38.08a1.89,1.89,0,0,1-2-1.76V10H51v7a1,1,0,0,0,2,0V3.53A3.79,3.79,0,0,0,49,0ZM2,8V3.76A1.89,1.89,0,0,1,4,2l45-.16a1.89,1.89,0,0,1,2,1.76V8Z'/></g></g></svg>"); + background-repeat: no-repeat; } + +.svg-icon.purple { + fill: #9063cd; } + +.svg-icon.purple-hover { + fill: #9063cd; } + .svg-icon.purple-hover:hover { + fill: #caa2dd; } + +.svg-icon.blue { + fill: #009fdb; } + +.svg-icon.blue-hover { + fill: #009fdb; } + .svg-icon.blue-hover:hover { + fill: #71c5e8; } + +.svg-icon.gray { + fill: #959595; } + +.svg-icon.gray-hover { + fill: #000000; } + .svg-icon.gray-hover:hover { + fill: #d2d2d2; } + +.svg-icon.black { + fill: #000000; } + +.svg-icon.black-hover { + fill: #000000; } + .svg-icon.black-hover:hover { + fill: #d2d2d2; } + +.sdc-tile, .sdc-tile-catalog { + box-sizing: border-box; + background-color: #ffffff; + display: flex; + flex-direction: column; + padding: 10px; + cursor: pointer; + border: 1px solid #eaeaea; + -webkit-box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05); + -moz-box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05); + box-shadow: 0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05); } + .sdc-tile:active, .sdc-tile-catalog:active { + border: 1px solid #71c5e8; } + .sdc-tile:hover, .sdc-tile-catalog:hover { + box-shadow: 0.3px 5px 12.8px 1.3px rgba(24, 24, 25, 0.15); + border: 1px solid #d2d2d2; } + .sdc-tile .sdc-tile-header, .sdc-tile-catalog .sdc-tile-header { + position: relative; + flex-shrink: 0; + display: flex; + align-items: flex-start; + flex-direction: column; } + .sdc-tile .sdc-tile-content, .sdc-tile-catalog .sdc-tile-content { + position: relative; + flex: 1; + display: flex; + align-items: flex-start; + flex-direction: column; + overflow: auto; + justify-content: space-between; } + .sdc-tile .sdc-tile-footer, .sdc-tile-catalog .sdc-tile-footer { + position: relative; + flex-shrink: 0; + display: flex; + align-items: flex-start; + flex-direction: column; } + +.sdc-tile-catalog { + width: 204px; + height: 200px; } + .sdc-tile-catalog .sdc-tile-header { + line-height: 16px; } + .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type { + font-size: 16px; + text-transform: uppercase; } + .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type.purple { + color: #9063cd; } + .sdc-tile-catalog .sdc-tile-header .sdc-tile-header-type.blue { + color: #009fdb; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-icon { + align-items: center; + display: flex; + flex-direction: column; + width: 100%; + padding-top: 25px; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-icon svg { + width: 60px; + height: 40px; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info { + padding-bottom: 4px; + width: 180px; + overflow: hidden; + text-overflow: ellipsis; + width: auto; + white-space: nowrap; + display: inline-block; + max-width: 178px; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-vendor-name { + color: #959595; + line-height: 12px; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-item-name { + color: #191919; } + .sdc-tile-catalog .sdc-tile-content .sdc-tile-content-info .sdc-tile-content-info-version-info { + display: flex; + justify-content: space-between; } + .sdc-tile-catalog .sdc-tile-footer { + display: flex; + flex-direction: row; + border-top: 1px solid #eaeaea; + padding: 0; + width: 180px; + height: 20px; } + .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-text { + flex: 1; + padding-top: 5px; + overflow: hidden; + text-overflow: ellipsis; + width: auto; + white-space: nowrap; + display: inline-block; + max-width: 164px; } + .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-icon { + flex-shrink: 1; + overflow: hidden; + padding-top: 5px; } + .sdc-tile-catalog .sdc-tile-footer .sdc-tile-footer-icon svg { + width: 16px; + height: 20px; } diff --git a/catalog-ui/app/styles/sprite-old.less b/catalog-ui/src/assets/styles/sprite-old.less index cb2dc2fbe0..cb2dc2fbe0 100644 --- a/catalog-ui/app/styles/sprite-old.less +++ b/catalog-ui/src/assets/styles/sprite-old.less diff --git a/catalog-ui/app/styles/sprite-product-icons.less b/catalog-ui/src/assets/styles/sprite-product-icons.less index 3485ec89a3..3485ec89a3 100644 --- a/catalog-ui/app/styles/sprite-product-icons.less +++ b/catalog-ui/src/assets/styles/sprite-product-icons.less diff --git a/catalog-ui/app/styles/sprite-resource-icons.less b/catalog-ui/src/assets/styles/sprite-resource-icons.less index 0f36527dda..153e8c042c 100644 --- a/catalog-ui/app/styles/sprite-resource-icons.less +++ b/catalog-ui/src/assets/styles/sprite-resource-icons.less @@ -256,3 +256,13 @@ .sprite-resource-icons.dcae_policy.medium { background-position: -141px -4336px; width: 41px; height: 41px;} .sprite-resource-icons.dcae_policy.large { background-position: -70px -4317px; width: 60px; height: 60px;} +.sprite-resource-icons.monitoring_template { background-position: -283px -4824px; width: 54px; height: 36px;} +.sprite-resource-icons.monitoring_template.small { background-position: -211px -4831px; width: 29px; height: 29px;} +.sprite-resource-icons.monitoring_template.medium { background-position: -142px -4819px; width: 41px; height: 41px;} +.sprite-resource-icons.monitoring_template.large { background-position: -71px -4800px; width: 60px; height: 60px;} + +.sprite-resource-icons.allotted_resource { background-position: -283px -4896px; width: 44px; height: 44px;} +.sprite-resource-icons.allotted_resource.small { background-position: -210px -4910px; width: 29px; height: 29px;} +.sprite-resource-icons.allotted_resource.medium { background-position: -141px -4898px; width: 41px; height: 41px;} +.sprite-resource-icons.allotted_resource.large { background-position: -70px -4879px; width: 60px; height: 60px;} + diff --git a/catalog-ui/app/styles/sprite-services-icons.less b/catalog-ui/src/assets/styles/sprite-services-icons.less index d1e666ff12..d1e666ff12 100644 --- a/catalog-ui/app/styles/sprite-services-icons.less +++ b/catalog-ui/src/assets/styles/sprite-services-icons.less diff --git a/catalog-ui/app/styles/sprite.html b/catalog-ui/src/assets/styles/sprite.html index 875c26fe2a..875c26fe2a 100644 --- a/catalog-ui/app/styles/sprite.html +++ b/catalog-ui/src/assets/styles/sprite.html diff --git a/catalog-ui/app/styles/sprite.less b/catalog-ui/src/assets/styles/sprite.less index b7c0146059..e9eed6e0c6 100644 --- a/catalog-ui/app/styles/sprite.less +++ b/catalog-ui/src/assets/styles/sprite.less @@ -29,7 +29,7 @@ .plus-icon { background-position: -50px -231px; width: 12px; height: 12px;} .plus-icon-hover { background-position: -100px -231px; width: 12px; height: 12px;} -.delete-icon { background-position: -650px -231px; width: 11px; height: 13px;} +.delete-icon { background-position: -675px -231px; width: 11px; height: 13px;} .delete-icon-hover { background-position: -702px -231px; width: 11px; height: 13px;} .arrow-up { background-position: -350px -236px; width: 12px; height: 7px;} @@ -155,9 +155,9 @@ .download-btn.disable { background-position: -530px -539px; width: 24px; height: 24px;} .expand-collapse-plus-icon { background-position: -334px -888px; width: 14px; height: 14px;} -.expand-collapse-plus-icon.hover { background-position: -422px -888px; width: 14px; height: 14px;} +.expand-collapse-plus-icon:hover { background-position: -422px -888px; width: 14px; height: 14px;} .expand-collapse-minus-icon { background-position: -378px -888px; width: 14px; height: 14px;} -.expand-collapse-minus-icon.hover { background-position: -466px -888px; width: 14px; height: 14px;} +.expand-collapse-minus-icon:hover { background-position: -466px -888px; width: 14px; height: 14px;} //tabs @@ -210,3 +210,42 @@ .expand-all:hover { background-position: -500px -449px; width: 20px; height: 22px;} .collapse-all { background-position: -465px -420px; width: 20px; height: 22px;} .collapse-all:hover { background-position: -465px -449px; width: 20px; height: 22px;} + +.delete-param:hover{ background-position: -702px -231px; width: 12px; height: 13px;} +.delete-param{ background-position: -675px -231px; width: 12px; height: 13px;} +.revert-param:hover{ background-position: -700px -48px; width: 12px; height: 11px;} +.revert-param{ background-position: -676px -48px; width: 12px; height: 11px;} +.show-desc:hover{ background-position: -635px -75px; width: 13px; height: 14px;} +.show-desc{ background-position: -599px -75px; width: 13px; height: 14px;} +.expand-list{background-position: -812px -66px; width: 21px; height: 21px;} +.expand-list:hover{background-position: -812px -96px; width: 21px; height: 21px;} +.expand-list.open{background-position: -853px -66px; width: 21px; height: 21px;} +.expand-list.open:hover{background-position: -853px -96px; width: 21px; height: 21px;} +//.search-icon{ background-position: -50px -279px; width: 14px; height: 14px;} +.search-icon:hover,.search-icon.selected{ background-position: -894px -101px; width: 14px; height: 14px;} +.search-icon{ background-position: -894px -71px; width: 14px; height: 14px;} +.asc{background-position: -924px -71px; width: 8px; height: 12px;} +.desc{background-position: -924px -101px; width: 8px; height: 12px;} +.add-item-icon {background-position: -50px -960px; width: 19px; height: 19px;} +.add-item-icon:hover {background-position: -100px -960px; width: 19px; height: 19px;} +.delete-item-icon { background-position: -140px -1119px; width: 11px; height: 15px; } +.filter-icon {background-position: -48px -1040px; width: 19px; height: 20px;} +/* +.sprite-new.expand-asset-icon { background-position: -740px -590px; width: 40px; height: 40px; } +.sprite-new.view-info-icon { background-position: -739px -621px; width: 40px; height: 40px; } +.sprite-new.cp-icon { background-position: -741px -652px; width: 40px; height: 40px; } +.sprite-new.vl-icon { background-position: -740px -682px; width: 40px; height:40px; } +.sprite-new.trash-icon { background-position: -740px -712px; width: 40px; height: 40px; } + +.sprite-new.expand-asset-icon:hover { background-position: -780px -590px; } +.sprite-new.view-info-icon:hover { background-position: -779px -621px; } +.sprite-new.cp-icon:hover { background-position: -781px -652px; } +.sprite-new.vl-icon:hover { background-position: -780px -682px; } +.sprite-new.trash-icon:hover { background-position: -780px -712px; } + +.sprite-new.expand-asset-icon:active, .sprite-new.expand-asset-icon.disabled-icon { background-position: -820px -590px;} +.sprite-new.view-info-icon:active, .sprite-new.view-info-icon.disabled-icon { background-position: -819px -621px; } +.sprite-new.cp-icon:active, .sprite-new.cp-icon.disabled-icon { background-position: -821px -652px; } +.sprite-new.vl-icon:active, .sprite-new.vl-icon.disabled-icon { background-position: -820px -682px; } +.sprite-new.trash-icon:active, .sprite-new.trash-icon.disabled-icon { background-position: -820px -712px; } +*/ diff --git a/catalog-ui/app/styles/table-flex.less b/catalog-ui/src/assets/styles/table-flex.less index 3ac014cc1b..3ac014cc1b 100644 --- a/catalog-ui/app/styles/table-flex.less +++ b/catalog-ui/src/assets/styles/table-flex.less diff --git a/catalog-ui/app/styles/tlv-buttons.less b/catalog-ui/src/assets/styles/tlv-buttons.less index 0e42a92231..0e42a92231 100644 --- a/catalog-ui/app/styles/tlv-buttons.less +++ b/catalog-ui/src/assets/styles/tlv-buttons.less diff --git a/catalog-ui/app/styles/tlv-checkbox.less b/catalog-ui/src/assets/styles/tlv-checkbox.less index 9dd5873545..9dd5873545 100644 --- a/catalog-ui/app/styles/tlv-checkbox.less +++ b/catalog-ui/src/assets/styles/tlv-checkbox.less diff --git a/catalog-ui/app/styles/tlv-loader.less b/catalog-ui/src/assets/styles/tlv-loader.less index efe39916e2..efe39916e2 100644 --- a/catalog-ui/app/styles/tlv-loader.less +++ b/catalog-ui/src/assets/styles/tlv-loader.less diff --git a/catalog-ui/app/styles/tlv-sprite.less b/catalog-ui/src/assets/styles/tlv-sprite.less index 472e2fb313..472e2fb313 100644 --- a/catalog-ui/app/styles/tlv-sprite.less +++ b/catalog-ui/src/assets/styles/tlv-sprite.less diff --git a/catalog-ui/app/styles/tooltips.less b/catalog-ui/src/assets/styles/tooltips.less index f4c618e2dc..4528aea5d2 100644 --- a/catalog-ui/app/styles/tooltips.less +++ b/catalog-ui/src/assets/styles/tooltips.less @@ -27,20 +27,51 @@ div.tooltips { } // --------------------------------------------------------------------------------------------------- -// Qtip +// Tooltip // --------------------------------------------------------------------------------------------------- +.w-sdc-canvas-tooltip{ + + position: absolute; + z-index: 100; + + .w-sdc-custom-tooltip { + .c_1; + position:relative; + color: white; + padding:10px; + height: 25px; + min-width: 100px; + background-color: rgba(80, 99, 113, 0.9); + border-radius: 2px; + line-height: 2px; + text-align: center; + + .w-sdc-tooltip-arrow { + position: absolute; + bottom:25px; + right:20px; + width:0;height:0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + border-bottom: 5px solid rgba(80, 99, 113, 0.9); + border-top: transparent; + border-width:7px; + border-style:solid; + } + + } +} + .qtip-custom { -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px; - background-color: rgb(80,99,113); - border-color:rgb(80,99,113); - color:white; - font-size:14px; - + background-color: rgb(80, 99, 113); + border-color:rgb(80, 99, 113); + color: white; + font-size:13px; } - .tooltip-custom { background-color: rgba(80, 99, 113, 0.9); z-index: 1100; @@ -106,5 +137,18 @@ div.tooltips { border-width: 0 6px 6px !important; border-bottom-color: rgba(80, 99, 113, 0.9) !important; } + /* &.right { + white-space: nowrap; + max-width: none; + .tooltip-arrow { + border-right-color: rgba(80, 99, 113, 0.9); + } + } + &.left { + white-space:nowrap; + max-width:none; + .tooltip-arrow { + border-left-color: rgba(80, 99, 113, 0.9); + } + }*/ } - diff --git a/catalog-ui/app/styles/variables-old.less b/catalog-ui/src/assets/styles/variables-old.less index 29eb61de7c..a4e707a076 100644 --- a/catalog-ui/app/styles/variables-old.less +++ b/catalog-ui/src/assets/styles/variables-old.less @@ -1,7 +1,7 @@ /*---------------------------------------------- General ----------------------------------------------*/ @images: "images"; -// Colors +/* Colors */ @color_a: #3b7b9b; // product category @color_b: #666666; @color_c: #ffffff; @@ -31,7 +31,7 @@ @color_zz: #93deb6; -// Color hover +/* Color hover */ @color_a_hover: darken(@color_a, 10.0%); @color_b_hover: darken(@color_b, 10.0%); @color_c_hover: darken(@color_c, 10.0%); @@ -69,7 +69,7 @@ @border_color_g: @color_a; @border_color_view-mode: #ededed; -// Fonts +/* Fonts */ @font-omnes-light: omnes-light, sans-serif; @font-omnes-regular: omnes-regular, sans-serif; @font-omnes-medium: omnes-medium, sans-serif; diff --git a/catalog-ui/app/styles/variables.less b/catalog-ui/src/assets/styles/variables.less index bf8854a5bb..dbed6baf3f 100644 --- a/catalog-ui/app/styles/variables.less +++ b/catalog-ui/src/assets/styles/variables.less @@ -1,4 +1,4 @@ -// Fonts +/* Fonts */ @font-omnes-light: omnes-light, sans-serif; @font-omnes-regular: omnes-regular, sans-serif; @font-omnes-medium: omnes-medium, sans-serif; @@ -8,7 +8,7 @@ /*---------------------------------------------- General ----------------------------------------------*/ @images: "images"; -// Main Colors +/* Main Colors */ @main_color_a: #009fdb; @main_color_b: #056bae; @main_color_c: #71c5eb; @@ -25,8 +25,9 @@ @main_color_n: #959595; @main_color_o: #d2d2d2; @main_color_p: #ffffff; +@main_color_q: #999999; -// Functional Colors +/* Functional Colors */ @func_color_q: #cf2a2a; @func_color_r: #f2f2f2; @func_color_s: #191919; @@ -34,15 +35,17 @@ @func_color_e: #007a3e; @func_color_h: #ffb81c; -// Tlv Colors +/* Tlv Colors */ @tlv_color_t: #f8f8f8; @tlv_color_u: #eaeaea; @tlv_color_v: #e6f6fb; +@tlv_color_w: #c6e6f2; +@tlv_color_x: #067ab4; /*---------------------------------------------- Parameters ----------------------------------------------*/ @header_height: 0px; @top_nav_height: 50px; @top_nav_admin_height: 44px; @action_nav_height: 53px; - -@border_color_view-mode: #ededed; +@footer_height: 89px; +@border_color_view-mode: #ededed;
\ No newline at end of file diff --git a/catalog-ui/app/styles/welcome-sprite.less b/catalog-ui/src/assets/styles/welcome-sprite.less index 010d30c9ef..010d30c9ef 100644 --- a/catalog-ui/app/styles/welcome-sprite.less +++ b/catalog-ui/src/assets/styles/welcome-sprite.less diff --git a/catalog-ui/src/assets/styles/welcome-style.less b/catalog-ui/src/assets/styles/welcome-style.less new file mode 100644 index 0000000000..d9cf16a72f --- /dev/null +++ b/catalog-ui/src/assets/styles/welcome-style.less @@ -0,0 +1,63 @@ + +html, +body { + height: 100%; +} + +* { + box-sizing: border-box; +} + +.sdc-welcome-new-page { + + opacity: 0; + height: 100%; + background-color: @main_color_p; + + .sdc-welcome-close { + position: absolute; + right: 38px; + top: 30px; + z-index: 101; + cursor: pointer; + + .sprite-welcome; + .sprite-welcome.close; + + &:hover { + .sprite-welcome.close_white; + } + } + + .sdc-welcome-wrapper { + height: 100vh; + width: 100%; + background-size: cover; + position: relative; + display: flex; + align-items: center; + justify-content: center; + background-image: url(images/welcome/002.png); + } + + .sdc-welcome-main { + text-align: center; + position: absolute; + bottom: 40%; + z-index: 1; + color: #fff; + left: 0; + width: 100%; + } + + .sdc-welcome-cover { + position: absolute; + top: 0px; + right: 0; + left: 0; + bottom: 0; + background-color: rgba(14, 13, 12, 0.8); + z-index: 0; + } + +} diff --git a/catalog-ui/src/index.html b/catalog-ui/src/index.html new file mode 100644 index 0000000000..c41532e01c --- /dev/null +++ b/catalog-ui/src/index.html @@ -0,0 +1,26 @@ +<!doctype html> +<html> +<head> + <meta charset="utf-8"> + <title>SDC</title> + <base href="/"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <link rel="icon" type="image/x-icon" href="favicon.ico"> +</head> +<body data-ng-class="bodyClass"> + + <!--<h1>Index.html</h1>--> + <app-root>Loading...</app-root> + <!--<h2>Before ui-view</h2>--> + <div ui-view style="height:100%"></div> + <!--<h2>After ui-view</h2>--> + <script type="text/javascript" src="/sdc1/scripts/inline.bundle.js"></script> + <script type="text/javascript" src="/sdc1/scripts/polyfills.bundle.js"></script> + <script type="text/javascript" src="/sdc1/scripts/vendor.bundle.js"></script> + <script type="text/javascript" src="/dcae/dcae-bundle.js"></script> + <script type="text/javascript" src="/sdc1/scripts/main.bundle.js"></script> + <script type="text/javascript" src="/sdc1/scripts/styles.bundle.js"></script></body> + <script type="text/javascript" src="/onboarding/punch-outs_en.js" async></script> + +</html> diff --git a/catalog-ui/src/main.ts b/catalog-ui/src/main.ts new file mode 100644 index 0000000000..7a321f7367 --- /dev/null +++ b/catalog-ui/src/main.ts @@ -0,0 +1,30 @@ +//import './app/app.ts'; +import {ng1appModule} from './app/app'; +import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; +import {enableProdMode} from '@angular/core'; +import {AppModule} from './app/ng2/app.module'; +import {UpgradeModule} from '@angular/upgrade/static'; +import {IAppConfigurtaion} from "./app/models/app-config"; + +declare var __ENV__: string; +export declare var sdc2Config: IAppConfigurtaion; + +if (__ENV__==='prod') { + sdc2Config = require('./../configurations/prod.js'); + enableProdMode(); +} else { + sdc2Config = require('./../configurations/dev.js'); +} + +// Ugliy fix because the cookie recieved from webseal change his value after some seconds. +declare var __ENV__: string; +let timeout:number = 5000; +if (__ENV__==='dev'){ + timeout=0; +} +window.setTimeout(()=>{ + platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { + const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule; + upgrade.bootstrap(document.body, [ng1appModule.name], {strictDi: true}); + }); +},timeout); diff --git a/catalog-ui/src/polyfills.ts b/catalog-ui/src/polyfills.ts new file mode 100644 index 0000000000..3a5bfc592a --- /dev/null +++ b/catalog-ui/src/polyfills.ts @@ -0,0 +1,39 @@ +// This file includes polyfills needed by Angular and is loaded before the app. +// You can add your own extra polyfills to this file. +import 'core-js/es6/symbol'; +import 'core-js/es6/object'; +import 'core-js/es6/function'; +import 'core-js/es6/parse-int'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/number'; +import 'core-js/es6/math'; +import 'core-js/es6/string'; +import 'core-js/es6/date'; +import 'core-js/es6/array'; +import 'core-js/es6/regexp'; +import 'core-js/es6/map'; +import 'core-js/es6/set'; +import 'core-js/es6/reflect'; + +import 'core-js/es7/reflect'; +import 'zone.js/dist/zone'; + + +// If you need to support the browsers/features below, uncomment the import +// and run `npm install import-name-here'; +// Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html + +// Needed for: IE9 +// import 'classlist.js'; + +// Animations +// Needed for: All but Chrome and Firefox, Not supported in IE9 +// import 'web-animations-js'; + +// Date, currency, decimal and percent pipes +// Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 +// import 'intl'; + +// NgClass on SVG elements +// Needed for: IE10, IE11 +// import 'classlist.js'; diff --git a/catalog-ui/src/styles.less b/catalog-ui/src/styles.less new file mode 100644 index 0000000000..795845e5fa --- /dev/null +++ b/catalog-ui/src/styles.less @@ -0,0 +1,11 @@ +/* You can add global styles to this file, and also import other style files */ +@import '../node_modules/bootstrap/dist/css/bootstrap.min.css'; +@import '../node_modules/angular-ui-bootstrap/dist/ui-bootstrap-csp.css'; +@import '../node_modules/angular-ui-notification/dist/angular-ui-notification.min.css'; +@import '../node_modules/perfect-scrollbar/dist/css/perfect-scrollbar.min.css'; +@import "../node_modules/qtip2/dist/jquery.qtip.min.css"; +@import '../node_modules/angular-resizable/angular-resizable.min.css'; +@import '../node_modules/angular-tooltips/dist/angular-tooltips.min.css'; +@import '../node_modules/animate.css/animate.min.css'; +@import './assets/styles/app.less'; + diff --git a/catalog-ui/app/third-party/PunchOutRegistry.js b/catalog-ui/src/third-party/PunchOutRegistry.js index bc93453dc1..db8e6875d6 100644 --- a/catalog-ui/app/third-party/PunchOutRegistry.js +++ b/catalog-ui/src/third-party/PunchOutRegistry.js @@ -95,4 +95,4 @@ window.PunchOutRegistry = PunchOutRegistry; -})(this); +})(window); diff --git a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js b/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js index 147f19ce54..2da6f786ea 100644 --- a/catalog-ui/non_bower_components/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js +++ b/catalog-ui/src/third-party/cytoscape.js-edge-editation/CytoscapeEdgeEditation.js @@ -121,7 +121,7 @@ } }); - scope.CytoscapeEdgeEditation = Class({ + exports.CytoscapeEdgeEditation = Class({ init: function (cy, handleSize) { this.DOUBLE_CLICK_INTERVAL = 300; @@ -551,4 +551,5 @@ } }); -})(this);
\ No newline at end of file +})(this); + diff --git a/catalog-ui/src/tsconfig.json b/catalog-ui/src/tsconfig.json new file mode 100644 index 0000000000..2890b9b73c --- /dev/null +++ b/catalog-ui/src/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "declaration": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "allowJs": true, + "mapRoot": "./", + "module": "commonjs", + "moduleResolution": "node", + "outDir": "../dist/out-tsc", + "lib": [ + "es6", + "dom" + ], + "sourceMap": true, + "target": "es5", + "typeRoots": [ + "../node_modules/@types", + "./typings" + ], + "types": [ + "jquery", + "core-js", + "node" + ] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts" + ] +}
\ No newline at end of file diff --git a/catalog-ui/typings/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/catalog-ui/src/typings/angular-ui-bootstrap/angular-ui-bootstrap.d.ts index 4062f141f1..61bccd0425 100644 --- a/catalog-ui/typings/angular-ui-bootstrap/angular-ui-bootstrap.d.ts +++ b/catalog-ui/src/typings/angular-ui-bootstrap/angular-ui-bootstrap.d.ts @@ -252,7 +252,7 @@ declare module angular.ui.bootstrap { /** * a controller for a modal instance - it can initialize scope used by modal. - * A controller can be injected with `$modalInstance` + * A controller can be injected with `$uibModalInstance` */ controller?: any; diff --git a/catalog-ui/typings/angular-ui-router/angular-ui-router.d.ts b/catalog-ui/src/typings/angular-ui-router/angular-ui-router.d.ts index c27425e39c..c27425e39c 100644 --- a/catalog-ui/typings/angular-ui-router/angular-ui-router.d.ts +++ b/catalog-ui/src/typings/angular-ui-router/angular-ui-router.d.ts diff --git a/catalog-ui/typings/angularjs/angular-mocks.d.ts b/catalog-ui/src/typings/angularjs/angular-mocks.d.ts index 65b0ac1a09..597c596024 100644 --- a/catalog-ui/typings/angularjs/angular-mocks.d.ts +++ b/catalog-ui/src/typings/angularjs/angular-mocks.d.ts @@ -51,7 +51,7 @@ declare module angular { interface IAngularStatic { mock: IMockStatic; } - + // see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject interface IInjectStatic { (...fns: Function[]): any; @@ -123,27 +123,27 @@ declare module angular { interface IHttpBackendService { /** * Flushes all pending requests using the trained responses. - * @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed. + * @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed. */ flush(count?: number): void; - + /** * Resets all request expectations, but preserves all backend definitions. */ resetExpectations(): void; - + /** * Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception. */ verifyNoOutstandingExpectation(): void; - + /** * Verifies that there are no outstanding requests that need to be flushed. */ verifyNoOutstandingRequest(): void; /** - * Creates a new request expectation. + * Creates a new request expectation. * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false. * Returns an object with respond method that controls how a matched request is handled. * @param method HTTP method. @@ -179,17 +179,17 @@ declare module angular { * @param headers HTTP headers object to be compared with the HTTP headers in the request. */ expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler; - + /** * Creates a new request expectation for JSONP requests. * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. - */ + */ expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler; /** - * Creates a new request expectation for PATCH requests. + * Creates a new request expectation for PATCH requests. * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. @@ -199,7 +199,7 @@ declare module angular { expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler; /** - * Creates a new request expectation for POST requests. + * Creates a new request expectation for POST requests. * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. @@ -209,7 +209,7 @@ declare module angular { expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler; /** - * Creates a new request expectation for PUT requests. + * Creates a new request expectation for PUT requests. * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. @@ -219,7 +219,7 @@ declare module angular { expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler; /** - * Creates a new backend definition. + * Creates a new backend definition. * Returns an object with respond method that controls how a matched request is handled. * @param method HTTP method. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. @@ -229,7 +229,7 @@ declare module angular { when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for DELETE requests. + * Creates a new backend definition for DELETE requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation. @@ -237,7 +237,7 @@ declare module angular { whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for GET requests. + * Creates a new backend definition for GET requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation. @@ -245,7 +245,7 @@ declare module angular { whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for HEAD requests. + * Creates a new backend definition for HEAD requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation. @@ -253,7 +253,7 @@ declare module angular { whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for JSONP requests. + * Creates a new backend definition for JSONP requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation. @@ -261,7 +261,7 @@ declare module angular { whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for PATCH requests. + * Creates a new backend definition for PATCH requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation. @@ -270,7 +270,7 @@ declare module angular { whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for POST requests. + * Creates a new backend definition for POST requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation. @@ -279,7 +279,7 @@ declare module angular { whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler; /** - * Creates a new backend definition for PUT requests. + * Creates a new backend definition for PUT requests. * Returns an object with respond method that controls how a matched request is handled. * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation. * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation. @@ -291,16 +291,16 @@ declare module angular { export module mock { // returned interface by the the mocked HttpBackendService expect/when methods interface IRequestHandler { - + /** - * Controls the response for a matched request using a function to construct the response. + * Controls the response for a matched request using a function to construct the response. * Returns the RequestHandler object for possible overrides. * @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text. */ respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler; /** - * Controls the response for a matched request using supplied static data to construct the response. + * Controls the response for a matched request using supplied static data to construct the response. * Returns the RequestHandler object for possible overrides. * @param status HTTP status code to add to the response. * @param data Data to add to the response. @@ -310,7 +310,7 @@ declare module angular { respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler; /** - * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response. + * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response. * Returns the RequestHandler object for possible overrides. * @param data Data to add to the response. * @param headers Headers object to add to the response. diff --git a/catalog-ui/typings/angularjs/angular-resource.d.ts b/catalog-ui/src/typings/angularjs/angular-resource.d.ts index 969997b1bc..969997b1bc 100644 --- a/catalog-ui/typings/angularjs/angular-resource.d.ts +++ b/catalog-ui/src/typings/angularjs/angular-resource.d.ts diff --git a/catalog-ui/typings/angularjs/angular.d.ts b/catalog-ui/src/typings/angularjs/angular.d.ts index a5f56c0ccd..a5f56c0ccd 100644 --- a/catalog-ui/typings/angularjs/angular.d.ts +++ b/catalog-ui/src/typings/angularjs/angular.d.ts diff --git a/catalog-ui/typings/angularjs/restangular.d.ts b/catalog-ui/src/typings/angularjs/restangular.d.ts index 3428b0493f..3428b0493f 100644 --- a/catalog-ui/typings/angularjs/restangular.d.ts +++ b/catalog-ui/src/typings/angularjs/restangular.d.ts diff --git a/catalog-ui/typings/cytoscape/cytoscape-extension.js b/catalog-ui/src/typings/cytoscape/cytoscape-extension.js index dbf22c37b9..dbf22c37b9 100644 --- a/catalog-ui/typings/cytoscape/cytoscape-extension.js +++ b/catalog-ui/src/typings/cytoscape/cytoscape-extension.js diff --git a/catalog-ui/typings/cytoscape/cytoscape-extension.ts b/catalog-ui/src/typings/cytoscape/cytoscape-extension.ts index 88843af088..88843af088 100644 --- a/catalog-ui/typings/cytoscape/cytoscape-extension.ts +++ b/catalog-ui/src/typings/cytoscape/cytoscape-extension.ts diff --git a/catalog-ui/typings/cytoscape/cytoscape.d.ts b/catalog-ui/src/typings/cytoscape/cytoscape.d.ts index e10b6273ae..3527281e5e 100644 --- a/catalog-ui/typings/cytoscape/cytoscape.d.ts +++ b/catalog-ui/src/typings/cytoscape/cytoscape.d.ts @@ -41,6 +41,8 @@ // - Cy.CollectionNodes // The output is a collection of node elements OR single node. +// import {CommonLinkBase} from "../../app/models/graph/graph-links/common-base-link"; +// import {CommonNodeBase} from "../../app/models/graph/nodes/base-common-node"; declare module Cy { /** * See http://js.cytoscape.org/#selectors for details about writing selectors. @@ -64,6 +66,7 @@ declare module Cy { type PositionDimension = string; /** + * * Usually temp or nonserialisable data can be stored. */ type Scratchpad = any; @@ -1885,15 +1888,15 @@ declare module Cy { } interface ElementsDefinition { - nodes: Sdc.Models.Graph.CommonNodeBase[]; - edges: Sdc.Models.CommonLinkBase[]; + nodes: any[]; + edges: any[]; } interface ElementDefinition { group?: ElementGroup; - data: Sdc.Models.Graph.CommonNodeBase| Sdc.Models.CommonLinkBase; + data: any; /** * Scratchpad data (usually temp or nonserialisable data) */ @@ -1932,7 +1935,7 @@ declare module Cy { */ css?: Css.ElementCss; } - + // interface ElementDataDefinition { // /** // * elided id => autogenerated id @@ -1943,7 +1946,7 @@ declare module Cy { // label?: string; // } interface EdgeDefinition extends ElementDefinition { - data: Sdc.Models.CommonLinkBase; + data: any; } // interface EdgeDataDefinition extends ElementDataDefinition { /** @@ -1958,7 +1961,7 @@ declare module Cy { // } interface NodeDefinition extends ElementDefinition { - data: Sdc.Models.Graph.CommonNodeBase; + data: any; } // interface NodeDataDefinition extends ElementDataDefinition { @@ -2161,6 +2164,9 @@ declare module Cy { * A convenience function to explicitly destroy the instance. */ destroy(): void; + + scratch(namespace?:string): any; + removeScratch(namespace:string):void; } interface EventObject { @@ -3092,4 +3098,4 @@ declare module "cytoscape" { export = cytoscape; } -declare var cytoscape: Cy.Static;
\ No newline at end of file +declare var cytoscape: Cy.Static; diff --git a/catalog-ui/typings/cytoscape/edge-editation.d.ts b/catalog-ui/src/typings/cytoscape/edge-editation.d.ts index e5ebd709b2..c4b5df0617 100644 --- a/catalog-ui/typings/cytoscape/edge-editation.d.ts +++ b/catalog-ui/src/typings/cytoscape/edge-editation.d.ts @@ -25,4 +25,3 @@ interface Handle { declare var CytoscapeEdgeEditation: CytoscapeEdgeEditation; -declare function require(name:string);
\ No newline at end of file diff --git a/catalog-ui/typings/d3/d3.d.ts b/catalog-ui/src/typings/d3/d3.d.ts index ff4335106c..ff4335106c 100644 --- a/catalog-ui/typings/d3/d3.d.ts +++ b/catalog-ui/src/typings/d3/d3.d.ts diff --git a/catalog-ui/typings/jasmine/jasmine.d.ts b/catalog-ui/src/typings/jasmine/jasmine.d.ts index 99ccb91fed..99ccb91fed 100644 --- a/catalog-ui/typings/jasmine/jasmine.d.ts +++ b/catalog-ui/src/typings/jasmine/jasmine.d.ts diff --git a/catalog-ui/typings/jquery/jquery.d.ts b/catalog-ui/src/typings/jquery/jquery.d.ts index cc20de588b..cc20de588b 100644 --- a/catalog-ui/typings/jquery/jquery.d.ts +++ b/catalog-ui/src/typings/jquery/jquery.d.ts diff --git a/catalog-ui/typings/jsMd5/md5.d.ts b/catalog-ui/src/typings/jsMd5/md5.d.ts index 3f06a6f509..3f06a6f509 100644 --- a/catalog-ui/typings/jsMd5/md5.d.ts +++ b/catalog-ui/src/typings/jsMd5/md5.d.ts diff --git a/catalog-ui/typings/lodash/lodash.d.ts b/catalog-ui/src/typings/lodash/lodash.d.ts index 9d23982103..72d35febb1 100644 --- a/catalog-ui/typings/lodash/lodash.d.ts +++ b/catalog-ui/src/typings/lodash/lodash.d.ts @@ -22946,4 +22946,4 @@ declare module "lodash.first" { interface Set<T> {} interface Map<K, V> {} interface WeakSet<T> {} -interface WeakMap<K, V> {}
\ No newline at end of file +//interface WeakMap<K extends object, V> {} diff --git a/catalog-ui/typings/notifyjs/notifyjs.d.ts b/catalog-ui/src/typings/notifyjs/notifyjs.d.ts index f72828fc06..f72828fc06 100644 --- a/catalog-ui/typings/notifyjs/notifyjs.d.ts +++ b/catalog-ui/src/typings/notifyjs/notifyjs.d.ts diff --git a/catalog-ui/typings/tsd.d.ts b/catalog-ui/src/typings/tsd.d.ts index 4fe638ef72..4fe638ef72 100644 --- a/catalog-ui/typings/tsd.d.ts +++ b/catalog-ui/src/typings/tsd.d.ts diff --git a/catalog-ui/tests/karma.unit.conf.js b/catalog-ui/tests/karma.unit.conf.js deleted file mode 100644 index 1b8277faed..0000000000 --- a/catalog-ui/tests/karma.unit.conf.js +++ /dev/null @@ -1,149 +0,0 @@ -// Karma configuration - -module.exports = function (config) { - config.set({ - - // base path, that will be used to resolve files and exclude - basePath: '../', - - - // frameworks to use - frameworks: ['jasmine'], - - // list of files / patterns to load in the browser - files: [ - 'bower_components/jquery/dist/jquery.js', - 'bower_components/angular/angular.js', - 'bower_components/angular-base64/angular-base64.js', - 'bower_components/angular-base64-upload/src/angular-base64-upload.js', - 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', - 'bower_components/jquery-ui/jquery-ui.js', - 'bower_components/angular-dragdrop/src/angular-dragdrop.js', - 'bower_components/angular-filter/dist/angular-filter.min.js', - 'bower_components/angular-md5/angular-md5.js', - 'bower_components/perfect-scrollbar/src/perfect-scrollbar.js', - 'bower_components/angular-perfect-scrollbar/src/angular-perfect-scrollbar.js', - 'bower_components/angular-mocks/angular-mocks.js', - 'bower_components/angular-resource/angular-resource.js', - 'bower_components/angular-sanitize/angular-sanitize.js', - 'bower_components/angular-tooltips/dist/angular-tooltips.min.js', - 'bower_components/angular-translate/angular-translate.js', - 'bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.js', - 'bower_components/angular-ui-router/release/angular-ui-router.js', - 'bower_components/angular-uuid4/angular-uuid4.js', - 'bower_components/bootstrap/dist/js/bootstrap.js', - 'bower_components/checklist-model/checklist-model.js', - 'bower_components/angular-clipboard/angular-clipboard.js', - 'bower_components/angular-resizable/src/angular-resizable.js', - 'bower_components/angular-ui-notification/src/angular-ui-notification.js', - 'bower_components/lodash/lodash.js', - 'bower_components/restangular/dist/restangular.js', - 'bower_components/jspdf/dist/jspdf.min.js', - 'app/scripts/utils/**/*.js', - 'app/scripts/services/**/*.js', - 'app/scripts/models/**/*.js', - 'app/scripts/view-models/**/*.js', - 'app/scripts/filters/**/*.js', - 'app/scripts/directives/**/*.js', - 'app/scripts/modules/**/*.js', - - 'app/scripts/app.js', - 'app/languages/**/*.js', - - 'app/scripts/templates.js', - - - - - - //'app/scripts/view-models/dashboard/dashboard-view-model-tests.js', - - - 'app/scripts/**/*-tests.js', - //'app/scripts/app.js', - - - //definition to allow to debug TS tests file in browser - {pattern: 'app/scripts/**/*-tests.ts', included: false}, - {pattern: 'app/scripts/**/*-tests.js.map', included: false}, - - - //definition to allow to debug TS sources files in browser - {pattern: 'app/scripts/**/*.ts', included: false}, - {pattern: 'app/scripts/**/*.js.map', included: false} - - ], - - // list of files to exclude - exclude: [ - - ], - - junitReporter: { - outputFile: 'tests/testOutput.xml', - suite: '' - }, - - //NOTE: This is handled from gruntfile.js - coverageReporter : { - type : 'html', - dir: 'tests/Coverage' - }, - // test results reporter to use - // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' - reporters: [ - 'mocha',//uncomment this line if you need to debug your unit test and print out the 'describe' of the test - 'junit', - 'dots', - 'progress', - 'coverage' - ], - - // web server port - port: 9876, - - - // enable / disable colors in the output (reporters and logs) - colors: true, - - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - // logLevel: config.LOG_INFO, - - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: true, - - preprocessors: { - '**/*.html': 'html2js', - 'app/scripts/**/!(*-tests|*Tests|*Test).js': 'coverage' - }, - - //ngHtml2JsPreprocessor: { - // stripPrefix: 'client/' - //}, - - // Start these browsers, currently available: - // - Chrome - // - ChromeCanary - // - Firefox - // - Opera (has to be installed with `npm install karma-opera-launcher`) - // - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) - // - PhantomJS - // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) - - //NOTE: This is handled from gruntfile.js - - browsers: ['Chrome'], - - - // If browser does not capture in given timeout [ms], kill it - captureTimeout: 60000, - - - // Continuous Integration mode - // if true, it capture browsers, run tests and exit - singleRun: false - }); -}; diff --git a/catalog-ui/tsd.json b/catalog-ui/tsd.json deleted file mode 100644 index 1f8ffec3cb..0000000000 --- a/catalog-ui/tsd.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "notifyjs/notifyjs.d.ts": { - "commit": "581563c4684d405afec14260ba79a89a52666c09" - }, - "jasmine/jasmine.d.ts": { - "commit": "14ab703f435375194360cdba3abab61afc879c18" - } - } -} diff --git a/catalog-ui/tslint.json b/catalog-ui/tslint.json index 2cd2dece6f..86bc1841f3 100644 --- a/catalog-ui/tslint.json +++ b/catalog-ui/tslint.json @@ -1,58 +1,116 @@ { - "rules": { - "class-name": true, - "comment-format": [ - false, - "check-space" - ], - "indent": [ - true, - "spaces" - ], - "no-duplicate-variable": true, - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-unsafe-finally": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - false, - "single" - ], - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": [ - true, - "ban-keywords" - ], - "whitespace": [ - false, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } -}
\ No newline at end of file + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "import-blacklist": [true, "rxjs"], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + + "directive-selector": [true, "attribute", "app", "camelCase"], + "component-selector": [true, "element", "app", "kebab-case"], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +} diff --git a/catalog-ui/typings/cytoscape/cytoscape-extension.js.map b/catalog-ui/typings/cytoscape/cytoscape-extension.js.map deleted file mode 100644 index 5eeda401dc..0000000000 --- a/catalog-ui/typings/cytoscape/cytoscape-extension.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"cytoscape-extension.js","sourceRoot":"","sources":["cytoscape-extension.ts"],"names":[],"mappings":""}
\ No newline at end of file diff --git a/catalog-ui/webpack.common.js b/catalog-ui/webpack.common.js new file mode 100644 index 0000000000..818d031776 --- /dev/null +++ b/catalog-ui/webpack.common.js @@ -0,0 +1,313 @@ +const path = require('path'); +const webpack = require('webpack'); +const ProgressPlugin = require('webpack/lib/ProgressPlugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const ExtractTextPlugin = require('extract-text-webpack-plugin'); +const CleanWebpackPlugin = require('clean-webpack-plugin'); +const autoprefixer = require('autoprefixer'); +const postcssUrl = require('postcss-url'); +const {GlobCopyWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack'); +const {CommonsChunkPlugin} = require('webpack').optimize; +const {AotPlugin} = require('@ngtools/webpack'); + +const nodeModules = path.join(process.cwd(), 'node_modules'); + +const bundledScripts = [ + "script-loader!./node_modules/jquery/dist/jquery.min.js", + "script-loader!./node_modules/lodash/lodash.min.js", + "script-loader!./node_modules/angular/angular.min.js", + "script-loader!./node_modules/restangular/dist/restangular.min.js", + "script-loader!./node_modules/jqueryui/jquery-ui.min.js", + "script-loader!./node_modules/angular-ui-router/release/angular-ui-router.min.js", + "script-loader!./node_modules/angular-filter/dist/angular-filter.min.js", + "script-loader!./node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js", + "script-loader!./node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js", + "script-loader!./node_modules/angular-resource/angular-resource.min.js", + "script-loader!./node_modules/angular-base64/angular-base64.min.js", + "script-loader!./node_modules/angular-uuid4/angular-uuid4.min.js", + "script-loader!./node_modules/angular-translate/dist/angular-translate.min.js", + "script-loader!./node_modules/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js", + "script-loader!./node_modules/angular-base64-upload/dist/angular-base64-upload.min.js", + "script-loader!./node_modules/angular-ui-notification/dist/angular-ui-notification.min.js", + "script-loader!./node_modules/cytoscape/dist/cytoscape.min.js", + "script-loader!./node_modules/checklist-model/checklist-model.js", + "script-loader!./node_modules/perfect-scrollbar/dist/js/perfect-scrollbar.jquery.min.js", + "script-loader!./node_modules/qtip2/dist/jquery.qtip.min.js", + "script-loader!./node_modules/cytoscape-qtip/cytoscape-qtip.js", + "script-loader!./node_modules/js-md5/build/md5.min.js", + "script-loader!./node_modules/angular-clipboard/angular-clipboard.js", + "script-loader!./node_modules/angular-resizable/angular-resizable.min.js", + "script-loader!./node_modules/angular-dragdrop/src/angular-dragdrop.min.js", + "script-loader!./node_modules/angular-tooltips/dist/angular-tooltips.min.js", + "script-loader!./node_modules/angular-sanitize/angular-sanitize.min.js" +]; +const baseHref = undefined; +const deployUrl = undefined; + +// Arguments pass from webpack +const prod = process.argv.indexOf('-p') !== -1; + +module.exports = function(params) { + + const webpackCommonConfig = { + resolve: { + extensions: [ + ".ts", + ".js", + ".less" + ], + modules: [ + "./node_modules" + ], + alias: { + directives: path.join(__dirname, 'app/directives/'), + } + }, + resolveLoader: { + modules: [ + "./node_modules" + ] + }, + entry: { + 'scripts/main': [ './src/main.ts' ], + 'scripts/polyfills': [ './src/polyfills.ts' ], + 'scripts/vendor': bundledScripts, + 'scripts/styles': [ "./src/styles.less" ] + }, + module: { + rules: [ + { + enforce: "pre", + test: /\.js$/, + loader: "source-map-loader", + exclude: [ /\/node_modules\// ] + }, + { test: /\.json$/, loader: "json-loader" }, + { test: /\.html$/, loader: "html-loader" }, + { + exclude: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.css$/, + loaders: [ + "exports-loader?module.exports.toString()", + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader" + ] + }, + { + exclude: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.scss$|\.sass$/, + loaders: [ + "exports-loader?module.exports.toString()", + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "sass-loader" + ] + }, + { + exclude: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.less$/, + loaders: [ + "exports-loader?module.exports.toString()", + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "less-loader" + ] + }, + { + exclude: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.styl$/, + loaders: [ + "exports-loader?module.exports.toString()", + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "stylus-loader?{\"sourceMap\":false,\"paths\":[]}" + ] + }, + { + include: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.css$/, + loaders: ExtractTextPlugin.extract({ + use: [ + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader" + ], + fallback: "style-loader", + publicPath: "" + }) + }, + { + include: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.scss$|\.sass$/, + loaders: ExtractTextPlugin.extract({ + use: [ + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "sass-loader" + ], + fallback: "style-loader", + publicPath: "" + }) + }, + { + include: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.less$/, + loaders: ExtractTextPlugin.extract({ + use: [ + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "less-loader" + ], + fallback: "style-loader", + publicPath: "" + }) + }, + { + include: [ path.join(process.cwd(), "src/styles.less") ], + test: /\.styl$/, + loaders: ExtractTextPlugin.extract({ + use: [ + "css-loader?{\"sourceMap\":false,\"importLoaders\":1}", + "postcss-loader", + "stylus-loader?{\"sourceMap\":false,\"paths\":[]}" + ], + fallback: "style-loader", + publicPath: "" + }) + }, + { test: /\.ts$/, loader: "@ngtools/webpack" } + ] + }, + plugins: [ + new CleanWebpackPlugin(['dist', 'build'], { + root: path.join(__dirname, ''), + verbose: true, + dry: false, + exclude: ['shared.js'] + }), + new webpack.LoaderOptionsPlugin({ + debug: false + }), + new webpack.DefinePlugin({ + process: { + env: { + sdcConfig: prod? '"production"': '"development"' + } + } + }), + new webpack.NoEmitOnErrorsPlugin(), + new ProgressPlugin(), + // new HtmlWebpackPlugin({ + // template: "./src/index.html", + // filename: "./index.html", + // hash: false, + // inject: true, + // compile: true, + // favicon: false, + // minify: false, + // cache: true, + // showErrors: true, + // chunks: "all", + // excludeChunks: [], + // title: "Webpack App", + // xhtml: true, + // chunksSortMode: function sort(left, right) { + // let paramsString = params.entryPoints + ''; + // let leftString = left.names[0].replace('scripts/',''); + // let rightString = right.names[0].replace('scripts/',''); + // let leftIndex = paramsString.indexOf(leftString); + // let rightindex = paramsString.indexOf(rightString); + // //console.log("left: " + leftString + " | leftIndex: " + leftIndex); + // //console.log("right: " + rightString + " | rightindex: " + rightindex); + // //console.log("result: " + leftIndex-rightindex); + // //console.log("----------------------------------------"); + // return leftIndex-rightindex; + // } + // }), + new GlobCopyWebpackPlugin({ + patterns: [ + "assets/languages", + "assets/styles/fonts", + "assets/styles/images", + "assets/styles/app.css" + ], + globOptions: { + cwd: path.join(process.cwd(), "src"), + dot: true, + ignore: "**/.gitkeep" + } + }), + new GlobCopyWebpackPlugin({ + patterns: [ + "configurations" + ], + globOptions: { + cwd: path.join(process.cwd(), ""), + dot: true, + ignore: "**/.gitkeep" + } + }), + new BaseHrefWebpackPlugin({}), + new CommonsChunkPlugin({ + name: "scripts/inline", + minChunks: null + }), + new CommonsChunkPlugin({ + name: "scripts/vendor", + minChunks: (module) => module.resource && module.resource.startsWith(nodeModules), + chunks: [ + "main" + ] + }), + new ExtractTextPlugin({ + filename: "[name].bundle.css", + disable: true + }), + new webpack.LoaderOptionsPlugin({ + sourceMap: false, + options: { + postcss: [ + autoprefixer(), + postcssUrl({ + url: (URL) => { + // Only convert absolute URLs, which CSS-Loader won't process into require(). + if (!URL.startsWith('/')) { + return URL; + } + // Join together base-href, deploy-url and the original URL. + // Also dedupe multiple slashes into single ones. + return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/'); + } + }) + ], + sassLoader: { + sourceMap: false, + includePaths: [] + }, + lessLoader: { + sourceMap: false + }, + context: "" + } + }), + new AotPlugin({ + mainPath: "main.ts", + exclude: [], + tsConfigPath: "src/tsconfig.json", + skipCodeGeneration: true + }) + ], + node: { + fs: "empty", + global: true, + crypto: "empty", + tls: "empty", + net: "empty", + process: true, + module: false, + clearImmediate: false, + setImmediate: false + } + } + + return webpackCommonConfig; +} diff --git a/catalog-ui/webpack.config.js b/catalog-ui/webpack.config.js new file mode 100644 index 0000000000..4f03b7c87c --- /dev/null +++ b/catalog-ui/webpack.config.js @@ -0,0 +1,64 @@ +'use strict'; + +const path = require('path'); +const merge = require('webpack-merge'); +const webpack = require('webpack'); +const ServerConfig = require('./webpack.server'); +const webpackCommonConfig = require('./webpack.common'); +const { BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); + +// Print server configuration +//process.stdout.write('webpack.server: ' + JSON.stringify(ServerConfig) + '\n'); +//process.stdout.write('webpack.common: ' + JSON.stringify(webpackCommonConfig) + '\n'); +const params = { + // entryPoints: [ + // '/scripts/inline', + // '/scripts/polyfills', + // '/scripts/vendor', + // '/scripts/main', + // '/scripts/sw-register', + // '/scripts/scripts', + // '/scripts/styles' + // ] +}; + +module.exports = function(env) { + + const webpackDevConfig = { + devtool: "source-map", + devServer: ServerConfig(env), + module: { + rules: [ + { test: /\.(eot|svg)$/, loader: "file-loader?name=scripts/fonts/[name].[hash:20].[ext]" }, + { test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/, loader: "url-loader?name=scripts/images/[name].[hash:20].[ext]&limit=10000" } + ] + }, + output: { + path: path.join(process.cwd(), "dist"), + filename: "[name].bundle.js", + chunkFilename: "[id].chunk.js" + //publicPath: "/" + }, + plugins: [ + // Replace /sdc1 inside index.html with '' (because /sdc1 is used only in production). + new CopyWebpackPlugin([ + { + from: './src/index.html', transform: function(content, path) { + content = (content+'').replace(/\/sdc1/g,''); + return content; + } + } + ]), + new webpack.DefinePlugin({ + __DEBUG__: JSON.stringify(true), + __ENV__: JSON.stringify('dev'), + __HMR__: JSON.stringify('HMR') + }), + new webpack.HotModuleReplacementPlugin() + ] + + }; + + return merge(webpackDevConfig, webpackCommonConfig(params)); +}
\ No newline at end of file diff --git a/catalog-ui/webpack.production.js b/catalog-ui/webpack.production.js new file mode 100644 index 0000000000..b93b8f2663 --- /dev/null +++ b/catalog-ui/webpack.production.js @@ -0,0 +1,59 @@ +'use strict'; + +const path = require('path'); +const merge = require('webpack-merge'); +const webpack = require('webpack'); +const ServerConfig = require('./webpack.server'); +const webpackCommonConfig = require('./webpack.common'); +const {GlobCopyWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); + +const params = { + // entryPoints: [ + // '/sdc1/scripts/inline', + // '/sdc1/scripts/polyfills', + // '/sdc1/scripts/vendor', + // '/sdc1/scripts/main', + // '/sdc1/scripts/sw-register', + // '/sdc1/scripts/scripts', + // '/sdc1/scripts/styles' + // ] +}; + +const webpackProdConfig = { + module: { + rules: [ + { test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]" }, + { test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/, loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000" } + ] + }, + output: { + path: path.join(process.cwd(), "dist"), + filename: "[name].bundle.js", + chunkFilename: "[id].chunk.js", + publicPath: "/sdc1" + }, + plugins: [ + new webpack.DefinePlugin({ + __DEBUG__: JSON.stringify(false), + __ENV__: JSON.stringify('prod') + }), + new CopyWebpackPlugin([ + { from: './src/index.html'} + ]), + new webpack.optimize.UglifyJsPlugin({ + beautify: false, + mangle: { + screw_ie8: true, + keep_fnames: true + }, + compress: { + warnings: false, + screw_ie8: true + }, + comments: false + }) + ] +}; + +module.exports = merge(webpackProdConfig, webpackCommonConfig(params)); diff --git a/catalog-ui/webpack.server.js b/catalog-ui/webpack.server.js new file mode 100644 index 0000000000..b8c79a6197 --- /dev/null +++ b/catalog-ui/webpack.server.js @@ -0,0 +1,80 @@ +let path = require('path'); + +const mockApis = require('./configurations/mock.json').sdcConfig; +const proxy = require('http-proxy-middleware'); +const devPort = 9000; +const fePort = 8181; + +module.exports = function(env) { + + // Set default role + if (!env) { + env = { + role: "designer" + }; + } + console.log("Starting dev server with role: " + env.role); + + const ServerConfig = { + port: devPort, + historyApiFallback: true, + inline: true, + stats: { + colors: true, + exclude: ['node_modules'] + }, + setup: server => { + let userType = mockApis.userTypes[env.role]; + + let middlewares = [ + (req, res, next) => { + res.cookie(mockApis.cookie.userIdSuffix, req.headers[mockApis.cookie.userIdSuffix] || userType.userId); + res.cookie(mockApis.cookie.userEmail, req.headers[mockApis.cookie.userEmail] || userType.email); + res.cookie(mockApis.cookie.userFirstName, req.headers[mockApis.cookie.userFirstName] || userType.firstName); + res.cookie(mockApis.cookie.userLastName, req.headers[mockApis.cookie.userLastName] || userType.lastName); + next(); + } + ]; + + // Redirect all '/sdc1/feProxy/rest' to feHost + middlewares.push( + proxy(['/sdc1/feProxy/rest'],{ + target: 'http://localhost:' + fePort, + changeOrigin: true, + secure: false + })); + + // Redirect dcae urls to feHost + middlewares.push( + proxy(['/dcae','/sdc1/feProxy/dcae-api'],{ + target: 'http://localhost:' + fePort, + changeOrigin: true, + secure: false, + onProxyRes: (proxyRes, req, res) => { + let setCookie = proxyRes.headers['set-cookie']; + if (setCookie) { + setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, ''); + } + } + })); + + // Redirect onboarding urls to feHost + middlewares.push( + proxy(['/onboarding','/sdc1/feProxy/onboarding-api'],{ + target: 'http://localhost:' + fePort, + changeOrigin: true, + secure: false, + onProxyRes: (proxyRes, req, res) => { + let setCookie = proxyRes.headers['set-cookie']; + if (setCookie) { + setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, ''); + } + } + })); + + server.use(middlewares); + } + }; + + return ServerConfig; +}
\ No newline at end of file |