diff --git a/Dockerfile b/Dockerfile index b93c3c453..4cb6270c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ ################################################################################ # Dockerfile # -# Josh Kaplan -# joshua.d.kaplan@lmco.com +# Enquier +# openmbee@gmail.com # # This is the Dockerfile for View Editor (VE). # To build the container, run the following command: `docker build -t ve .` @@ -11,7 +11,7 @@ ################################################################################ FROM node:8 -MAINTAINER Josh Kaplan +ENV VE_ENV 'example' WORKDIR /opt/mbee/ve COPY . /opt/mbee/ve @@ -58,4 +58,4 @@ EXPOSE 9000 # When the container runs, we run grunt. The second argument should reference a # server defined in the angular-mms-grunt-servers.json file. -CMD ["grunt", "server:dev"] +CMD ["sh", "-c", "grunt release:docker --env=${VE_ENV}"] diff --git a/Documents/ViewEditorUserGuide-OpenMBEE.pdf b/Documents/ViewEditorUserGuide-OpenMBEE.pdf new file mode 100644 index 000000000..f7f30c714 Binary files /dev/null and b/Documents/ViewEditorUserGuide-OpenMBEE.pdf differ diff --git a/Gruntfile.js b/Gruntfile.js index 93c131783..47d604116 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -7,6 +7,8 @@ module.exports = function(grunt) { configureProxies: 'grunt-connect-proxy-updated', artifactory: 'grunt-artifactory-artifact' }); + // Project configuration. + var env = grunt.option('env') || 'example'; var jsFiles = ['app/js/**/*.js', 'src/directives/**/*.js', 'src/services/*.js']; @@ -20,105 +22,99 @@ module.exports = function(grunt) { var connectObject = { docs: { options: { - hostname: 'localhost', + hostname: '*', port: 10000, base: './dist/docs' } } }; - if (grunt.file.exists('angular-mms-grunt-servers.json')) { - var servers = grunt.file.readJSON('angular-mms-grunt-servers.json'); - - // Set proxie info for server list - for (var key in servers) { - var serverPort = 443; - var serverHttps = true; - if (key === "localhost") { - serverPort = 8080; - serverHttps = false; - } - connectObject[key] = { + //if (grunt.file.exists('angular-mms-grunt-servers.json')) { + //var server = grunt.file.readJSON('angular-mms-grunt-servers.json'); + //ar serverPort = server.mms_port; + //var serverHttps = true; + var serveStatic = require('serve-static'); + var modRewrite = require('connect-modrewrite'); + connectObject["docker"] = { + options: { + hostname: '0.0.0.0', + port: 9000, + protocol: 'http', + //open: true, + //key: grunt.file.read('/run/secrets/server.key').toString(), + //cert: grunt.file.read('/run/secrets/server.crt').toString(), + debug: true, + base: { + path: './dist', options: { - hostname: '*', - port: 9000, - open: true, - base: { - path: './dist', - options: { - // Add this so that the browser doesn't re-validate static resources - // Also, we have cache-busting, so we don't have to worry about stale resources - maxAge: 31536000000 - } - }, - middleware: function (connect, options, middlewares) { - middlewares.unshift( - require('grunt-connect-proxy-updated/lib/utils').proxyRequest, - // add gzip compression to local server to reduce static resources' size and improve load speed - require('compression')(), - // need to add livereload as a middleware at this specific order to avoid issues with other middlewares - require('connect-livereload')()); - return middlewares; - } - }, - proxies: [ - { - context: '/mms-ts', - host: 'mms-ts-uat.jpl.nasa.gov',//'localhost',//'100.64.243.161', - port: 8080 - }, - { - context: '/xlrapi', - https: serverHttps, - host: servers[key], - port: serverPort - }, - { - context: '/api', - host: servers[key], - changeOrigin: true, - https: serverHttps, - port: serverPort, - rewrite: { '^/api': ''} - } - ] - }; + index: 'mms.html', + // Add this so that the browser doesn't re-validate static resources + // Also, we have cache-busting, so we don't have to worry about stale resources + maxAge: 31536000000 + } + }, + middleware: function(connect, options) { + var middlewares; + middlewares = []; + if (!Array.isArray(options.base)) { + options.base = [options.base]; + } + middlewares.push( + require('grunt-connect-proxy-updated/lib/utils').proxyRequest, + // add gzip compression to local server to reduce static resources' size and improve load speed + require('compression')() + //require('connect-modrewrite')(['!\\.html|\\.js|\\.css|\\.svg|\\.jp(e?)g|\\.png|\\.gif$ /mms.html']), + + // need to add livereload as a middleware at this specific order to avoid issues with other middlewares + ); + middlewares.push( modRewrite( ['^[^\\.]*$ /mms.html [L]'] ) ); + options.base.forEach(function(base) { + // Serve static files. + var path = base.path || base; + var staticOptions = base.options || defaultStaticOptions; + middlewares.push(serveStatic(path, staticOptions)); + }); + return middlewares; + } } - } + }; + //} var combineCustomJS = { - options: { - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %> */\n', - wrap: 'mms', - mangle: true, - sourceMap: { - includeSources: true - } - }, - files: { - 'dist/js/ve-mms.min.js': [ - - // mms module - 'src/mms.js', - 'src/services/*.js', - 'src/filters/*.js', - - // mms.directives module (need mms, mms.directives.tpls.js module ) - 'dist/jsTemp/mms.directives.tpls.js', - 'src/mms.directives.js', - 'src/directives/**/*.js', - - // app module ( need app.tpls.js, mms, mms.directives module ) - 'dist/jsTemp/app.tpls.js', - 'app/js/mms/app.js', - 'app/js/mms/controllers/*.js', - 'app/js/mms/directives/*.js' - ] - } + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd HH:MM:ss") %> */\n', + wrap: 'mms', + mangle: true, + sourceMap: { + includeSources: true + } + }, + files: { + 'dist/js/ve-mms.min.js': [ + + // mms module + 'src/mms.js', + 'src/services/*.js', + 'src/filters/*.js', + + // mms.directives module (need mms, mms.directives.tpls.js module ) + 'dist/jsTemp/mms.directives.tpls.js', + 'src/mms.directives.js', + 'src/directives/**/*.js', + + // app module ( need app.tpls.js, mms, mms.directives module ) + 'dist/jsTemp/app.tpls.js', + 'app/js/mms/app.js', + 'app/js/mms/controllers/*.js', + 'app/js/mms/directives/*.js', + + // config files + 'app/config/config.' + env + '.js' + ] + } }; - // Project configuration. - grunt.initConfig({ + grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), concurrent: { @@ -262,7 +258,7 @@ module.exports = function(grunt) { // concat only (no minification ) concat: { - combineCustomJS: combineCustomJS + combineCustomJS: combineCustomJS }, /** Concat + Minify JS files **/ @@ -300,6 +296,7 @@ module.exports = function(grunt) { evil: true, //allow eval for plot integration globalstrict: true, validthis: true, + esversion: 6, globals: { angular: true, window: true, @@ -335,15 +332,15 @@ module.exports = function(grunt) { watch: { dev: { - files: ['app/**/*', '!app/bower_components/**', 'src/**/*'], + files: ['app/env.js', 'app/**/*', '!app/bower_components/**', 'src/**/*'], tasks: ['dev-build'] }, release: { - files: ['app/**/*', '!app/bower_components/**', 'src/**/*'], + files: ['app/env.js', 'app/**/*', '!app/bower_components/**', 'src/**/*'], tasks: ['release-build'] }, docs: { - files: ['app/**/*', '!app/bower_components/**', 'src/**/*'], + files: ['app/env.js', 'app/**/*', '!app/bower_components/**', 'src/**/*'], tasks: ['ngdocs'] }, options: { @@ -354,7 +351,7 @@ module.exports = function(grunt) { artifactory: { options: { url: artifactoryUrl, - repository: snapshotRepo, //releaseRepo, + repository: releaseRepo, username: artifactoryUser, password: artifactoryPassword }, @@ -365,7 +362,7 @@ module.exports = function(grunt) { options: { publish: [{ id: groupId + ':ve:zip', - version: '3.6.1-SNAPSHOT', + version: '3.7.0-SNAPSHOT', path: 'deploy/' }] } @@ -373,13 +370,13 @@ module.exports = function(grunt) { }, karma: { - unit:{ - configFile:'config/develop/karma.develop.conf.js' - }, - continuous:{ - configFile:'config/develop/karma.develop.conf.js', - logLevel: 'ERROR' - } + unit:{ + configFile:'config/develop/karma.develop.conf.js' + }, + continuous:{ + configFile:'config/develop/karma.develop.conf.js', + logLevel: 'ERROR' + } }, protractor: { @@ -430,11 +427,11 @@ module.exports = function(grunt) { grunt.registerTask('e2e-test', ['protractor']); grunt.registerTask('release', function(arg1) { - grunt.task.run('release-build'); - if (arguments.length !== 0) - grunt.task.run('launch:release:' + arg1); - else - grunt.task.run('launch:release'); + grunt.task.run('release-build'); + if (arguments.length !== 0) + grunt.task.run('launch:release:' + arg1); + else + grunt.task.run('launch:release'); }); grunt.registerTask('server', function(arg1) { @@ -446,9 +443,9 @@ module.exports = function(grunt) { }); grunt.registerTask('docs', function() { - grunt.task.run('ngdocs'); - grunt.task.run('connect:docs'); - grunt.task.run('watch:docs'); + grunt.task.run('ngdocs'); + grunt.task.run('connect:docs'); + grunt.task.run('watch:docs'); }); grunt.registerTask('launch', function(build, arg1) { @@ -463,8 +460,8 @@ module.exports = function(grunt) { }); grunt.registerTask('debug', function () { - grunt.log.writeln("Launching Karma"); - grunt.task.run('test'); + grunt.log.writeln("Launching Karma"); + grunt.task.run('test'); }); grunt.registerTask('e2e',function(arg1) { diff --git a/README.md b/README.md index e02eab12e..07d5c88d3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,28 @@ https://github.com/Open-MBEE/ve/blob/develop/Documents/ViewEditorUserGuide.pdf * /src/directives/templates - html templates for our directives plus common styling * /app - MDEV developed application, this will be separated out in the future +## Configuration +_(View Editor 3.7.0 and newer)_ +You can now configure view editor to work with external sites without using Grunt. This file also allows the configuration +of certain branding and other features that will be expanded in future versions + +1. In the `app/config` directory copy `config.example.js` into a new file and rename it to `config..js` +2. You should update the `baseUrl` and `apiUrl` fields to point to your MMS server (eg. `apiURL: 'https://localhost:8080'` +& (`baseUrl: ''`) +3. To deploy view editor using this custom file, use `--env ` + appended to your `grunt` command (e.g. `grunt release:docker --env=prod`). +3. For more information regarding the available configuration options see [Config](docs/Config.md). + +_Versions Prior to 3.7.0_ +5. Create a file named `angular-mms-grunt-servers.json`. This is where you will add server mappings. + * The _grunt_ command will build with these default and fake values, but will not be runnable. + * You should update "ems" key to point to the value of the **actual** hostname serving the Model Management Server (MMS). +```json +{ + "ems": "hostnameurl" +} +``` ## Installation and Building 1. Install the latest stable version of Node ( at the time of this writing 8.9.4 ) @@ -24,17 +45,9 @@ https://github.com/Open-MBEE/ve/blob/develop/Documents/ViewEditorUserGuide.pdf 4. to install all node module dependencies specified in package.json npm install - -5. Create a file named `angular-mms-grunt-servers.json`. This is where you will add server mappings. - * The _grunt_ command will build with these default and fake values, but will not be runnable. - * You should update "ems" key to point to the value of the **actual** hostname serving the Model Management Server (MMS). -```json -{ - "ems": "hostnameurl" -} -``` -6. In the angular-mms directory, run. . . + +6. In the root directory, run. . . * . . .to build and bundle the app in development mode. The final artifact will be available in the dist folder: grunt @@ -47,17 +60,21 @@ https://github.com/Open-MBEE/ve/blob/develop/Documents/ViewEditorUserGuide.pdf grunt server -* . . .to build a proxied service. "hostnameurl" is the key from the angular-mms-grunt-servers.json. Its value is the server's base url that you would like the proxy to forward requests to: +* . . .to build a proxied service in develop mode with default configuration: - grunt server:hostnameurl + grunt server:docker * . . .to build and bundle the app in production mode as well as launching a web server locally and a proxy: grunt release -* . . .to builid and bundle the app in production mode as well as launching a webserver locally and a psroxy, where the server url pertains to a different url you want. Make sure that "hostnameurl" exists in the angular-mms-grunt-servers.json: +* . . .to build and bundle the app in production mode as well as launching a webserver locally with default configuration: + + grunt release:docker - grunt release:hostnameurl +* . . .to build and bundle the app with a custom configuration in dev/production mode as well as launching a webserver locally (defaults to `example`): + + grunt :docker --env= * . . .to build and bundle the app in production modes, generate documentation and publish the final artifact to Artifactory: @@ -71,10 +88,15 @@ https://github.com/Open-MBEE/ve/blob/develop/Documents/ViewEditorUserGuide.pdf For more information, please consult the Gruntfile.js and the links at the bottom. + ## Building and Running with Docker To build the container, run the following command: `docker build -t ve .`. To run the container, run `docker run -it -p 80:9000 --name ve ve`. +#### After View Editor 4.7 +To use a custom configuration file with the docker container you can mount the desired file using a docker config or volume. +Using your custom configuration can be done by specifying `--env VE_ENV=` or adding `VE_ENV` to your compose file. + ## Problems? If you see some error after updating, try cleaning out the bower_components and bower_components_target folders under /app and do a _grunt clean_ diff --git a/app/assets/logo.svg b/app/assets/logo.svg deleted file mode 100644 index 0dd59dc63..000000000 --- a/app/assets/logo.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - logo2 copy 2 - Created with Sketch. - - - - - - - - - - \ No newline at end of file diff --git a/app/assets/mmsplus copy.png b/app/assets/mmsplus copy.png deleted file mode 100644 index 914cf6c1e..000000000 Binary files a/app/assets/mmsplus copy.png and /dev/null differ diff --git a/app/assets/openmbee.svg b/app/assets/openmbee.svg new file mode 100644 index 000000000..3efdd76dc --- /dev/null +++ b/app/assets/openmbee.svg @@ -0,0 +1 @@ +sdfArtboard 1 \ No newline at end of file diff --git a/app/assets/styles/ve/base/_globals.scss b/app/assets/styles/ve/base/_globals.scss index 04802c91a..440d32547 100644 --- a/app/assets/styles/ve/base/_globals.scss +++ b/app/assets/styles/ve/base/_globals.scss @@ -10,3 +10,6 @@ $background_hover_transition: background-color .2s linear; $background_easeout_transition: background-color .1s ease-out; $navHeight: 36px; +$navBanner: 20px; +$navProject: 56px; +$navTotal: 92px; diff --git a/app/assets/styles/ve/layout/_login-select.scss b/app/assets/styles/ve/layout/_login-select.scss index b33dbb1d3..da2f324d1 100644 --- a/app/assets/styles/ve/layout/_login-select.scss +++ b/app/assets/styles/ve/layout/_login-select.scss @@ -6,6 +6,7 @@ 3. UI Elements 3.1 Text Input 4. Animation +5. Branding -------------------------------------------------------------------*/ @@ -18,8 +19,8 @@ #ve-login { background-color: $ve-slate-darker-2; - height:100%; margin: 0; + height:100vh; .account-wall { min-width: 320px; @@ -125,4 +126,27 @@ .fade-in{ animation: .7s ease-out 0s 1 fadeIn; +} + +/*------------------------------------------------------------------ +5. Branding +-------------------------------------------------------------------*/ +#ve-origin-select, +#ve-login { + .login-banner { + width: 100%; + text-align: center; + } + .login-box { + margin: auto; + padding: 20px 5px; + width: auto; + border: 1px solid #fff; + } + + .login-banner ul { + list-style-type: none; + padding: 0; + } + } \ No newline at end of file diff --git a/app/assets/styles/ve/layout/_panes.scss b/app/assets/styles/ve/layout/_panes.scss index 302424c27..7da226a2c 100644 --- a/app/assets/styles/ve/layout/_panes.scss +++ b/app/assets/styles/ve/layout/_panes.scss @@ -91,9 +91,9 @@ } #main-pane { - top: 72px; + top: $navTotal; } .content-container { - top: $navHeight; + top: $navTotal; } diff --git a/app/assets/styles/ve/layout/_ve-footer.scss b/app/assets/styles/ve/layout/_ve-footer.scss index 78d8f8c3d..914d34787 100644 --- a/app/assets/styles/ve/layout/_ve-footer.scss +++ b/app/assets/styles/ve/layout/_ve-footer.scss @@ -1,5 +1,4 @@ -ve-footer { - .footer { + footer.footer { width: 100%; height: 13px; border-top: 1px solid $tertiary_grey; @@ -13,5 +12,4 @@ ve-footer { cursor: default; bottom: 0px; padding-top: 1px; - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/app/assets/styles/ve/layout/_ve-nav.scss b/app/assets/styles/ve/layout/_ve-nav.scss index a2383286f..8933f219d 100644 --- a/app/assets/styles/ve/layout/_ve-nav.scss +++ b/app/assets/styles/ve/layout/_ve-nav.scss @@ -30,6 +30,7 @@ // position: relative; width: 100%; height: $navHeight; + top: $navBanner; min-height: 30px; border: 0; background-color: $ve-slate-base; @@ -70,7 +71,7 @@ a.switch-org:hover { img{ height: 26px; - border-radius: 50%; + //border-radius: 50%; @include transition($background_hover_transition); &:hover{ @@ -213,7 +214,7 @@ ul.global-menu { background:$ve-accent; text-align: center; color:white; - + &:hover { background-color:$ve-accent-darker; } @@ -226,7 +227,7 @@ ul.global-menu { nav.project-level-header { background-color: $ve-slate-darker-2; - top: $navHeight; + top: $navProject; z-index: 150; .navbar-nav { @@ -370,3 +371,21 @@ nav.project-level-header { word-wrap: break-word; } } + +/*------------------------------------------------------------------ +4. Banner Header +-------------------------------------------------------------------*/ +nav.nav-level-banner { + background-color: $ve-slate-darker-2; + color: white; + float: none; + height: $navBanner; + + .navbar-nav { + margin: 0; + } + .navbar-banner-header { + display: flex; + justify-content: center; + } +} \ No newline at end of file diff --git a/app/config/.gitignore b/app/config/.gitignore new file mode 100644 index 000000000..12971dcae --- /dev/null +++ b/app/config/.gitignore @@ -0,0 +1,2 @@ +config.*.js +!config.example.js \ No newline at end of file diff --git a/app/config/config.example.js b/app/config/config.example.js new file mode 100644 index 000000000..3a228139e --- /dev/null +++ b/app/config/config.example.js @@ -0,0 +1,40 @@ +(function () { + //Examples of commonly used banner statements + var label = { + pi: 'PROPRIETARY: Proprietary Information', + export_ctrl: 'EXPORT WARNING: No export controlled documents allowed on this server', + no_public_release: 'Not for Public Release or Redistribution', + unclassified: 'CLASSIFICATION: This system is UNCLASSIFIED' + }; + + //Do not modify, this is necessary to initialize the config + window.__env = window.__env || {}; + + //Do not modify the structure of this + window.__env = { + // View Editor Version + version: '3.7.0', + // API url + apiUrl: 'http://localhost:8080', + // Base url + baseUrl: '', + enableDebug: true, + // Configuration for the banner below the login modal (only visible at login) + loginBanner: { + labels: [ + label.unclassified, + label.pi + ' - ' + label.no_public_release + ], + background: '#0D47A1', + color: '#e8e8e8' + }, + // Configure the banner that is placed above all content (always visible) + banner: { + message: label.pi + }, + footer: { + message: "OpenMBEE View Editor | Licensed under Apache 2.0" + } + } + +}()); \ No newline at end of file diff --git a/app/index.html b/app/index.html index e9adbd3df..d3a6b4922 100644 --- a/app/index.html +++ b/app/index.html @@ -6,6 +6,7 @@ MMS Module App + Model Management System App diff --git a/app/js/mms/app.js b/app/js/mms/app.js index 663e15038..4d1dba7c5 100644 --- a/app/js/mms/app.js +++ b/app/js/mms/app.js @@ -23,7 +23,7 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor }]); $locationProvider.hashPrefix(''); - + $urlRouterProvider.rule(function ($injector, $location) { var $state = $injector.get('$state'); var locationPath = $location.url(); @@ -47,9 +47,23 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor $location.url(locationPath); }); - var mmsHost = window.location.protocol + '//' + window.location.host; - URLServiceProvider.setMmsUrl(mmsHost); - //URLServiceProvider.setMmsUrl('https://opencae-uat.jpl.nasa.gov'); + if(window.__env.baseUrl) { + URLServiceProvider.setBaseUrl(window.__env.baseUrl); + } + else { + URLServiceProvider.setBaseUrl(''); + } + + if(window.__env.apiUrl) { + URLServiceProvider.setMmsUrl(window.__env.apiUrl); + } + else { + var mmsHost = window.location.protocol + '//' + window.location.host; + URLServiceProvider.setMmsUrl(mmsHost); + } + + + $httpProvider.defaults.withCredentials = true; // Check if user is logged in, if so redirect to select page otherwise go to login if the url isn't mapped @@ -75,23 +89,39 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor $stateProvider .state('login', { url: '/login', - resolve: { }, + resolve: { + bannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getBanner(); + }], + loginBannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getLoginBanner(); + }] + }, views: { + 'banner@': { + template: '', + controller: ['$scope', 'bannerOb', function($scope, bannerOb){ + $scope.banner = bannerOb; + }] + }, 'login@': { templateUrl: 'partials/mms/login.html', - controller: ['$scope', '$rootScope', '$state', 'AuthService', 'growl', function ($scope, $rootScope, $state, AuthService, growl) { + controller: ['$scope', '$rootScope', '$state', 'AuthService', 'loginBannerOb', 'growl', function ($scope, $rootScope, $state, AuthService, loginBannerOb, growl) { $scope.credentials = { username: '', password: '' }; $rootScope.ve_title = 'Login'; $scope.pageTitle = 'View Editor'; + $scope.loginBanner = loginBannerOb; $scope.spin = false; $scope.login = function (credentials) { + console.log(credentials.username); $scope.spin = true; var credentialsJSON = {"username":credentials.username, "password":credentials.password}; AuthService.getAuthorized(credentialsJSON) .then(function(user) { + console.log(user); if ($rootScope.ve_redirect) { var toState = $rootScope.ve_redirect.toState; var toParams = $rootScope.ve_redirect.toParams; @@ -111,12 +141,12 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('login.redirect', { url: '/redirect', resolve: { - ticket: ['$window', 'URLService', 'AuthService', '$q', '$cookies', 'ApplicationService', function($window, URLService, AuthService, $q, $cookies, ApplicationService) { + token: ['$window', 'URLService', 'AuthService', '$q', '$cookies', 'ApplicationService', function($window, URLService, AuthService, $q, $cookies, ApplicationService) { var deferred = $q.defer(); AuthService.checkLogin().then(function(data) { ApplicationService.setUserName(data); - URLService.setTicket($window.localStorage.getItem('ticket')); - deferred.resolve($window.localStorage.getItem('ticket')); + URLService.setToken($window.localStorage.getItem('token')); + deferred.resolve($window.localStorage.getItem('token')); $cookies.put('com.tomsawyer.web.license.user', data, {path: '/'}); }, function(rejection) { deferred.reject(rejection); @@ -134,29 +164,43 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('login.select', { url: '/select?fromLogin', resolve: { - ticket: ['$window', 'URLService', 'AuthService', '$q', 'ApplicationService', function($window, URLService, AuthService, $q, ApplicationService) { + token: ['$window', 'URLService', 'AuthService', '$q', 'ApplicationService', function($window, URLService, AuthService, $q, ApplicationService) { var deferred = $q.defer(); AuthService.checkLogin().then(function(data) { + console.error('select-fromlogin'); ApplicationService.setUserName(data); - URLService.setTicket($window.localStorage.getItem('ticket')); - deferred.resolve($window.localStorage.getItem('ticket')); + URLService.setToken($window.localStorage.getItem('token')); + deferred.resolve($window.localStorage.getItem('token')); }, function(rejection) { deferred.reject(rejection); }); return deferred.promise; }], - orgObs: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + bannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getBanner(); + }], + loginBannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getLoginBanner(); + }], + orgObs: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getOrgs(); }] }, views: { + 'banner@': { + template: '', + controller: ['$scope', 'bannerOb', function($scope, bannerOb){ + $scope.banner = bannerOb; + }] + }, 'login@': { templateUrl: 'partials/mms/select.html', - controller: ['$scope', '$rootScope', '$state', '$stateParams', 'orgObs', 'ProjectService', 'AuthService', 'growl', '$localStorage', function($scope, $rootScope, $state, $stateParams, orgObs, ProjectService, AuthService, growl, $localStorage) { + controller: ['$scope', '$rootScope', '$state', '$stateParams', 'orgObs', 'ProjectService', 'AuthService','loginBannerOb', 'growl', '$localStorage', function($scope, $rootScope, $state, $stateParams, orgObs, ProjectService, AuthService, loginBannerOb, growl, $localStorage) { $rootScope.ve_title = 'Projects'; $scope.pageTitle = 'View Editor'; $scope.fromLogin = $stateParams.fromLogin; $localStorage.$default({org: orgObs[0]}); + $scope.loginBanner = loginBannerOb; $scope.spin = false; $scope.orgs = orgObs; var orgId, projectId; @@ -223,31 +267,31 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('project', { //TODO this will be the ui to diff and merge and manage refs url: '/projects/:projectId', resolve: { - ticket: ['$window', 'URLService', 'AuthService', '$q', 'ApplicationService', '$cookies', function($window, URLService, AuthService, $q, ApplicationService, $cookies) { + token: ['$window', 'URLService', 'AuthService', '$q', 'ApplicationService', '$cookies', function($window, URLService, AuthService, $q, ApplicationService, $cookies) { var deferred = $q.defer(); AuthService.checkLogin().then(function(data) { ApplicationService.setUserName(data); - URLService.setTicket($window.localStorage.getItem('ticket')); - deferred.resolve($window.localStorage.getItem('ticket')); + URLService.setToken($window.localStorage.getItem('token')); + deferred.resolve($window.localStorage.getItem('token')); $cookies.put('com.tomsawyer.web.license.user', data, {path: '/'}); }, function(rejection) { deferred.reject(rejection); }); return deferred.promise; }], - //orgObs: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + //orgObs: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { // return ProjectService.getOrgs(); //}], - projectOb: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + projectOb: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getProject($stateParams.projectId); }], - projectObs: ['$stateParams', 'ProjectService', 'ticket', 'projectOb', function($stateParams, ProjectService, ticket, projectOb) { + projectObs: ['$stateParams', 'ProjectService', 'token', 'projectOb', function($stateParams, ProjectService, token, projectOb) { return ProjectService.getProjects(projectOb.orgId); }], - orgOb: ['ProjectService', 'projectOb', 'ticket', function(ProjectService, projectOb, ticket) { + orgOb: ['ProjectService', 'projectOb', 'token', function(ProjectService, projectOb, token) { return ProjectService.getOrg(projectOb.orgId); }], - refObs: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + refObs: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getRefs($stateParams.projectId); }], tagObs: ['refObs', function(refObs) { @@ -266,6 +310,9 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor } return ret; }], + bannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getBanner(); + }], refOb: function() { return null;}, tagOb: function() { return null;}, branchOb: function() { return null;}, @@ -274,6 +321,12 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor search: function(){ return null;} }, views: { + 'banner@': { + template: '', + controller: ['$scope', 'bannerOb', function($scope, bannerOb){ + $scope.banner = bannerOb; + }] + }, 'nav@': { template: '', controller: ['$scope', '$rootScope', 'orgOb', 'projectOb', 'projectObs', 'refOb', 'branchOb', 'branchObs', 'tagOb', 'tagObs', 'search', function ($scope, $rootScope, orgOb, projectOb, projectObs, refOb, branchOb, branchObs, tagOb, tagObs, search) { @@ -314,10 +367,10 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('project.ref', { // equivalent to old sites and documents page url: '/:refId?search', resolve: { - projectOb: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + projectOb: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getProjectMounts($stateParams.projectId, $stateParams.refId); }], - refOb: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + refOb: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getRef($stateParams.refId, $stateParams.projectId); }], tagOb: ['refOb', function(refOb) { @@ -334,11 +387,11 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor return []; } }], - groupObs: ['$stateParams', 'ProjectService', 'ticket', function($stateParams, ProjectService, ticket) { + groupObs: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { return ProjectService.getGroups($stateParams.projectId, $stateParams.refId); }], groupOb: function(){ return null;}, - documentOb: ['$stateParams', '$q', 'ElementService', 'ViewService', 'refOb', 'projectOb', 'ticket', function($stateParams, $q, ElementService, ViewService, refOb, projectOb, ticket) { + documentOb: ['$stateParams', '$q', 'ElementService', 'ViewService', 'refOb', 'projectOb', 'token', function($stateParams, $q, ElementService, ViewService, refOb, projectOb, token) { var deferred = $q.defer(); var eid = $stateParams.projectId + '_cover'; ElementService.getElement({ @@ -409,12 +462,18 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor viewOb: ['documentOb', function(documentOb) { return documentOb; }], - search: ['$stateParams', 'ElementService', 'ticket', function($stateParams, ElementService, ticket) { + search: ['$stateParams', 'ElementService', 'token', function($stateParams, ElementService, token) { if ($stateParams.search === undefined) { return null; } return $stateParams.search; }], + bannerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getBanner(); + }], + footerOb: ['BrandingService', function(BrandingService) { + return BrandingService.getFooter(); + }], docMeta: [function(){ return {}; }], @@ -423,6 +482,12 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor }] }, views: { + 'banner@': { + template: '', + controller: ['$scope', 'bannerOb', function($scope, bannerOb){ + $scope.banner = bannerOb; + }] + }, 'nav@': { template: '', controller: ['$scope', '$rootScope', 'orgOb', 'projectOb', 'projectObs', 'refOb', 'branchOb', 'branchObs', 'tagOb', 'tagObs', 'search', function ($scope, $rootScope, orgOb, projectOb, projectObs, refOb, branchOb, branchObs, tagOb, tagObs, search) { @@ -470,13 +535,19 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor 'toolbar-right@': { template: '', controller: 'ToolbarCtrl' + }, + 'footer@': { + template: '', + controller: ['$scope', 'footerOb', function ($scope, footerOb) { + $scope.footer = footerOb; + }] } } }) .state('project.ref.groupReorder', { url: '/group-reorder', resolve: { - documentObs: ['ViewService', '$stateParams', 'ticket', function(ViewService, $stateParams, ticket) { + documentObs: ['ViewService', '$stateParams', 'token', function(ViewService, $stateParams, token) { return ViewService.getProjectDocuments({ projectId: $stateParams.projectId, refId: $stateParams.refId @@ -496,7 +567,10 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('project.ref.preview', { url: '/document/:documentId', resolve: { - documentOb: ['$stateParams', '$q', 'ElementService', 'ViewService', 'refOb', 'ticket', function($stateParams, $q, ElementService, ViewService, refOb, ticket) { + projectOb: ['$stateParams', 'ProjectService', 'token', function($stateParams, ProjectService, token) { + return ProjectService.getProjectMounts($stateParams.projectId, $stateParams.refId); + }], + documentOb: ['$stateParams', '$q', 'ElementService', 'ViewService', 'refOb', 'token', function($stateParams, $q, ElementService, ViewService, refOb, token) { var deferred = $q.defer(); var eid = $stateParams.documentId; var coverIndex = eid.indexOf('_cover'); @@ -555,7 +629,7 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor viewOb: ['documentOb', function(documentOb) { return documentOb; }], - groupOb: ['groupObs', 'documentOb', 'ProjectService', 'ticket', function(groupObs, documentOb, ProjectService, ticket) { + groupOb: ['groupObs', 'documentOb', 'ProjectService', 'token', function(groupObs, documentOb, ProjectService, token) { var group = null; if (documentOb) { for (var i = 0; i < groupObs.length; i++) { @@ -600,7 +674,7 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('project.ref.document', { url: '/documents/:documentId', resolve: { - documentOb: ['$stateParams', 'ElementService', 'ticket', function($stateParams, ElementService, ticket) { + documentOb: ['$stateParams', 'ElementService', 'token', function($stateParams, ElementService, token) { return ElementService.getElement({ projectId: $stateParams.projectId, refId: $stateParams.refId, @@ -671,7 +745,7 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor .state('project.ref.document.view', { url: '/views/:viewId', resolve: { - viewOb: ['$stateParams', 'ElementService', 'ticket', function($stateParams, ElementService, ticket) { + viewOb: ['$stateParams', 'ElementService', 'token', function($stateParams, ElementService, token) { return ElementService.getElement({ projectId: $stateParams.projectId, refId: $stateParams.refId, @@ -740,7 +814,7 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor $httpProvider.interceptors.push(['$q', '$location', '$rootScope', '$injector', 'URLService', function($q, $location, $rootScope, $injector, URLService) { return { request: function(config) { - config.headers = URLService.getAuthorizationHeader(config.headers); + config.headers = URLService.getAuthorizationHeader(config.headers); return config; }, 'responseError': function(rejection) { diff --git a/app/js/mms/controllers/main.controller.js b/app/js/mms/controllers/main.controller.js index 239dd4b92..1c598efb3 100644 --- a/app/js/mms/controllers/main.controller.js +++ b/app/js/mms/controllers/main.controller.js @@ -8,18 +8,12 @@ function($scope, $timeout, $location, $rootScope, $state, _, $window, $uibModal, $rootScope.ve_viewContentLoading = false; $rootScope.ve_treeInitial = ''; $rootScope.ve_title = ''; - $rootScope.ve_footer = ''; + //TODO: Figure out why this needs to be set here for VE footer to work + $rootScope.ve_footer = "ALWAYS REPLACED"; $rootScope.ve_fn = false; var modalOpen = false; - var host = $location.host(); - // if (host.indexOf('europaems') !== -1 || host.indexOf('arrmems') !== -1 || host.indexOf('msmems') !== -1) { - // $rootScope.ve_footer = 'The technical data in this document is controlled under the U.S. Export Regulations, release to foreign persons may require an export authorization.'; - // } - if (host.indexOf('fn') !== -1){ - $rootScope.ve_footer = 'JPL/Caltech PROPRIETARY — Not for Public Release or Redistribution. No export controlled documents allowed on this server. More'; - $rootScope.ve_fn = true; - } + $window.addEventListener('beforeunload', function(event) { if ($rootScope.ve_edits && !_.isEmpty($rootScope.ve_edits)) { @@ -46,7 +40,7 @@ function($scope, $timeout, $location, $rootScope, $state, _, $window, $uibModal, //check if error is ticket error if (!error || error.status === 401 || (error.status === 404 && error.config && error.config.url && - error.config.url.indexOf('/login/ticket') !== -1)) { //check if 404 if checking valid ticket + error.config.url.indexOf('/authentication') !== -1)) { //check if 404 if checking valid ticket event.preventDefault(); $rootScope.ve_redirect = {toState: toState, toParams: toParams}; $state.go('login', {notify: false}); @@ -70,10 +64,10 @@ function($scope, $timeout, $location, $rootScope, $state, _, $window, $uibModal, return; modalOpen = true; $uibModal.open({ - template: '', scope: $scope, backdrop: 'static', diff --git a/app/js/mms/controllers/tool.controller.js b/app/js/mms/controllers/tool.controller.js index c5d103a8c..f1b361bfe 100644 --- a/app/js/mms/controllers/tool.controller.js +++ b/app/js/mms/controllers/tool.controller.js @@ -4,10 +4,10 @@ angular.module('mmsApp') .controller('ToolCtrl', ['$scope', '$rootScope', '$state', '$uibModal', '$q', '$timeout', 'hotkeys', - 'ElementService', 'JobService', 'ProjectService', 'growl', 'projectOb', 'refOb', 'tagObs', 'branchObs', 'documentOb', 'viewOb', 'Utils', + 'ElementService', 'ProjectService', 'growl', 'projectOb', 'refOb', 'tagObs', 'branchObs', 'documentOb', 'viewOb', 'Utils', 'PermissionsService', function($scope, $rootScope, $state, $uibModal, $q, $timeout, hotkeys, - ElementService, JobService, ProjectService, growl, projectOb, refOb, tagObs, branchObs, documentOb, viewOb, Utils, PermissionsService) { + ElementService, ProjectService, growl, projectOb, refOb, tagObs, branchObs, documentOb, viewOb, Utils, PermissionsService) { $scope.specInfo = { refId: refOb.id, @@ -39,8 +39,7 @@ function($scope, $rootScope, $state, $uibModal, $q, $timeout, hotkeys, element: true, history: false, tags: false, - reorder: false, - jobs: false + reorder: false }; $scope.tracker = {}; if (!$rootScope.ve_edits) @@ -84,10 +83,6 @@ function($scope, $rootScope, $state, $uibModal, $q, $timeout, hotkeys, } }; - $scope.$on('jobs', function() { - showPane('jobs'); - }); - $scope.$on('element-history', function() { showPane('history'); }); diff --git a/app/js/mms/controllers/toolbar.controller.js b/app/js/mms/controllers/toolbar.controller.js index 421f8c60e..6df7120a3 100644 --- a/app/js/mms/controllers/toolbar.controller.js +++ b/app/js/mms/controllers/toolbar.controller.js @@ -25,9 +25,6 @@ function($scope, $rootScope, $state, UxService, refOb, documentOb, PermissionsSe var editable = false; tbApi.addButton(UxService.getToolbarButton("element-history")); tbApi.addButton(UxService.getToolbarButton("tags")); - // if ($state.includes('project.ref.document')) { - tbApi.addButton(UxService.getToolbarButton("jobs")); - // } if ($state.includes('project.ref') && !$state.includes('project.ref.document')) { editable = refOb.type === 'Branch' && PermissionsService.hasBranchEditPermission(refOb); tbApi.setPermission('element-editor', editable); diff --git a/app/js/mms/directives/veFooter.js b/app/js/mms/directives/veFooter.js index 6cc093323..6466e2435 100644 --- a/app/js/mms/directives/veFooter.js +++ b/app/js/mms/directives/veFooter.js @@ -1,25 +1,17 @@ 'use strict'; -angular.module('mmsApp') -.directive('veFooter', ['$templateCache', veFooter]); +angular.module('mmsApp').directive('veFooter', [ '$templateCache', veFooter]); -/** -* @ngdoc directive -* @name mmsApp.directive:veFooter -* -* @restrict E -* -* @description -* Displays VE footer -* Customize by updating partials/mms/veFooter.html -* -*/ function veFooter($templateCache) { var template = $templateCache.get('partials/mms/veFooter.html'); + var veFooterLink = function(scope) { + scope.ve_footer = scope.footer; + }; + + return { - restrict: 'E', template: template, - transclude: true + link: veFooterLink }; } \ No newline at end of file diff --git a/app/js/mms/directives/veNav.js b/app/js/mms/directives/veNav.js index 094bc9aa8..fa6906e1a 100644 --- a/app/js/mms/directives/veNav.js +++ b/app/js/mms/directives/veNav.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('mmsApp') -.directive('veNav', ['$templateCache', '$rootScope', '$state', 'hotkeys', 'growl', '$location', '$uibModal', 'ApplicationService','AuthService', 'ProjectService', veNav]); +.directive('veNav', ['$templateCache', '$rootScope', '$state', 'hotkeys', 'growl', '$location', '$uibModal', '$window', 'ApplicationService','AuthService', 'ProjectService', veNav]); /** * @ngdoc directive @@ -18,7 +18,7 @@ angular.module('mmsApp') * The navbar is mobile friendly. * */ -function veNav($templateCache, $rootScope, $state, hotkeys, growl, $location, $uibModal, ApplicationService, AuthService, ProjectService) { +function veNav($templateCache, $rootScope, $state, hotkeys, growl, $location, $uibModal, $window, ApplicationService, AuthService, ProjectService) { var template = $templateCache.get('partials/mms/veNav.html'); var veNavLink = function(scope, element, attrs) { @@ -87,7 +87,13 @@ function veNav($templateCache, $rootScope, $state, hotkeys, growl, $location, $u hotkeys.toggleCheatSheet(); }; scope.toggleAbout = function() { - scope.veV = '3.6.1'; + if ($window.__env.version) { + scope.veV = window.__env.version; + } + else { + scope.veV = '3.6.1'; + } + scope.mmsV = 'Loading...'; ApplicationService.getMmsVersion().then(function(data) { scope.mmsV = data; @@ -132,10 +138,17 @@ function veNav($templateCache, $rootScope, $state, hotkeys, growl, $location, $u var address = "https://uatlinkhere"; if (hostName !== 'localhost' && hostName.split('.')[0].substr(-3) !== 'uat') address = 'https://' + hostName.split('.')[0] + '-uat.jpl.nasa.gov'; + // TODO (jk) - Move branding into config. + address = "https://mms.openmbee.org"; window.open(address ,'_blank'); }; AuthService.checkLogin().then(function(data) { - scope.username = data; + scope.username = data.username; + AuthService.getUserData(data.username).then(function(userData){ + scope.user = userData.users[0]; + }, function() { + scope.user = data.username; + }); }); }; diff --git a/app/js/mms/directives/veSystemBanner.js b/app/js/mms/directives/veSystemBanner.js new file mode 100644 index 000000000..d423d09f5 --- /dev/null +++ b/app/js/mms/directives/veSystemBanner.js @@ -0,0 +1,22 @@ +'use strict'; + +angular.module('mmsApp').directive('veSystemBanner', [ '$templateCache', veSystemBanner]); + +function veSystemBanner($templateCache) { + var template = $templateCache.get('partials/mms/veBanner.html'); + + //var no_banner = { template: '' }; + //if ( !BrandingService.hasOwnProperty('banner') || + // !BrandingService.banner.hasOwnProperty('message') ) { + // return no_banner; + //}; + var veBannerLink = function(scope) { + scope.ve_banner = scope.banner; + }; + + + return { + template: template, + link: veBannerLink + }; +} \ No newline at end of file diff --git a/app/mms.html b/app/mms.html index ad0dee18c..cffcb2e67 100644 --- a/app/mms.html +++ b/app/mms.html @@ -11,7 +11,7 @@ - + @@ -23,9 +23,13 @@
-
+ +
+
+
+
@@ -49,9 +53,7 @@
- - - +
diff --git a/app/partials/mms/login.html b/app/partials/mms/login.html index 87f9139d7..18aa099c9 100644 --- a/app/partials/mms/login.html +++ b/app/partials/mms/login.html @@ -1,7 +1,7 @@
+ diff --git a/app/partials/mms/pane-center.html b/app/partials/mms/pane-center.html index 764d69462..b4a641891 100644 --- a/app/partials/mms/pane-center.html +++ b/app/partials/mms/pane-center.html @@ -5,9 +5,11 @@ DocLib +
diff --git a/app/partials/mms/pane-right.html b/app/partials/mms/pane-right.html index 0d9da3f8f..99b3a6fc1 100644 --- a/app/partials/mms/pane-right.html +++ b/app/partials/mms/pane-right.html @@ -40,9 +40,4 @@

Project Branches/Tags

mms-commit-id="{{viewCommitId}}" mms-order="true" mms-ref-id="{{viewOb._refId}}" mms-view-reorder-api="viewContentsOrderApi">
- -
- -
diff --git a/app/partials/mms/select.html b/app/partials/mms/select.html index d4955a1f2..7ffe4a72e 100644 --- a/app/partials/mms/select.html +++ b/app/partials/mms/select.html @@ -40,7 +40,7 @@

Please navigate to your document by selecting the corresponding organization - \ No newline at end of file + diff --git a/app/partials/mms/veBanner.html b/app/partials/mms/veBanner.html new file mode 100644 index 000000000..08eaf6354 --- /dev/null +++ b/app/partials/mms/veBanner.html @@ -0,0 +1,7 @@ + diff --git a/app/partials/mms/veFooter.html b/app/partials/mms/veFooter.html index c0cac9e06..ba2f61f62 100644 --- a/app/partials/mms/veFooter.html +++ b/app/partials/mms/veFooter.html @@ -1 +1,7 @@ - \ No newline at end of file +
+
+ +
+
diff --git a/app/partials/mms/veNav.html b/app/partials/mms/veNav.html index e38ea9aa8..bce6b1345 100644 --- a/app/partials/mms/veNav.html +++ b/app/partials/mms/veNav.html @@ -7,7 +7,7 @@ - View Editor Logo + View Editor Logo {{ org.name }} {{ org.name }} @@ -36,10 +36,10 @@
  • - View Editor User Guide + View Editor Help
  • - Report Issue + Report Issue
  • @@ -51,11 +51,12 @@