OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/frontend/app/init-app.js

176 lines
6.2 KiB

// -- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
// ++
// Globally exposed dependencies
require('./vendors');
// Styles for global dependencies
require('at.js/jquery.atwho.min.css');
require('select2/select2.css');
require('ui-select/dist/select.min.css');
require('ng-dialog/css/ngDialog.min.css');
require('jquery-ui/themes/base/core.css');
require('jquery-ui/themes/base/datepicker.css');
require('jquery-ui/themes/base/dialog.css');
Angular 4 support and upgraded timeline header directive (#5984) * Added Angular4 dependency and initial setup * Angular 4 transition: timeline header directive * removed superfluous require declaration * moved Angular4 dependencies to vendor.js * Angular4: upgraded timeline relations directive * Fixes karma tests. However, logging seems to be broken now. * Angular4: upgraded directive wpTimelineStaticElements * dev rebase * WIP Angular 4+ transition * converted WorkPackageTableTimelineGrid to Angular4+ * start migrating WorkPackageTimelineTableController to Angular4+ * completed migration of component tree WorkPackageTimelineTableController * Fix Pagination directive * set any to scope for TS warnings * Convert wp-table-pagination * merged changes from Oliver * begin migrating WorkPackagesTableController * begin migrating WorkPackagesTableController * Apply karma fix to PR * Fix pagination options * WIP Angular migration wp-table.directive * Angular4 migration - table sums * Angular4 migration: fixed error message when no sums are displayed * Angular4 migration: removed superfluous Angular1 registration * WIP Angular4 migration * WIP Angular4 migration - removed unused directives - start migartion sortHeader directive * WIP Angular4 migration - sortHeader directive * WIP Angular4 migration: sort header * Angular4 migration: implemented dropDown directive for Angular4 * merged origin/dev * updated package-lock.json * use shrinkwrap instead of package-lock * Angular4 migration: fixed accessible_by_keyboard directive * WIP #26714 * reformat code * fixes #26714 pass projectIdentifier to wpTable * cleanup * fixes #26716 * WIP Angular4 migration: added support for test execution * wpTablePagination: convertered reasonable tests to Angular4 * merged dev branch, updated dependencies * fixed #26727 * Replace openproject initialization in head * fixed #26728 * Replace time entries and messages ng1 controllers * Remove unused timeline reference * Fix OP Helpers for member page * Fix initial cached paged options * Fixed broken inlineCreate * Only nil-check for table, projectIdentifier CAN be null
7 years ago
// Global scripts previously part of the application.js
var requireGlobals = require.context('./globals/', true, /\.ts$/);
requireGlobals.keys().forEach(requireGlobals);
// load I18n, depending on the html element having a 'lang' attribute
var documentLang = (angular.element('html').attr('lang') || 'en').toLowerCase();
require('angular-i18n/angular-locale_' + documentLang + '.js');
var opApp = require('./angular-modules.ts').default;
window.appBasePath = jQuery('meta[name=app_base_path]').attr('content') || '';
Angular 4 support and upgraded timeline header directive (#5984) * Added Angular4 dependency and initial setup * Angular 4 transition: timeline header directive * removed superfluous require declaration * moved Angular4 dependencies to vendor.js * Angular4: upgraded timeline relations directive * Fixes karma tests. However, logging seems to be broken now. * Angular4: upgraded directive wpTimelineStaticElements * dev rebase * WIP Angular 4+ transition * converted WorkPackageTableTimelineGrid to Angular4+ * start migrating WorkPackageTimelineTableController to Angular4+ * completed migration of component tree WorkPackageTimelineTableController * Fix Pagination directive * set any to scope for TS warnings * Convert wp-table-pagination * merged changes from Oliver * begin migrating WorkPackagesTableController * begin migrating WorkPackagesTableController * Apply karma fix to PR * Fix pagination options * WIP Angular migration wp-table.directive * Angular4 migration - table sums * Angular4 migration: fixed error message when no sums are displayed * Angular4 migration: removed superfluous Angular1 registration * WIP Angular4 migration * WIP Angular4 migration - removed unused directives - start migartion sortHeader directive * WIP Angular4 migration - sortHeader directive * WIP Angular4 migration: sort header * Angular4 migration: implemented dropDown directive for Angular4 * merged origin/dev * updated package-lock.json * use shrinkwrap instead of package-lock * Angular4 migration: fixed accessible_by_keyboard directive * WIP #26714 * reformat code * fixes #26714 pass projectIdentifier to wpTable * cleanup * fixes #26716 * WIP Angular4 migration: added support for test execution * wpTablePagination: convertered reasonable tests to Angular4 * merged dev branch, updated dependencies * fixed #26727 * Replace openproject initialization in head * fixed #26728 * Replace time entries and messages ng1 controllers * Remove unused timeline reference * Fix OP Helpers for member page * Fix initial cached paged options * Fixed broken inlineCreate * Only nil-check for table, projectIdentifier CAN be null
7 years ago
const meta = jQuery('meta[name=openproject_initializer]');
I18n.locale = meta.data('defaultLocale');
I18n.locale = meta.data('locale');
opApp
.config([
'$compileProvider',
'$locationProvider',
'$httpProvider',
function($compileProvider, $locationProvider, $httpProvider) {
// Disable debugInfo outside development mode
Angular 4 support and upgraded timeline header directive (#5984) * Added Angular4 dependency and initial setup * Angular 4 transition: timeline header directive * removed superfluous require declaration * moved Angular4 dependencies to vendor.js * Angular4: upgraded timeline relations directive * Fixes karma tests. However, logging seems to be broken now. * Angular4: upgraded directive wpTimelineStaticElements * dev rebase * WIP Angular 4+ transition * converted WorkPackageTableTimelineGrid to Angular4+ * start migrating WorkPackageTimelineTableController to Angular4+ * completed migration of component tree WorkPackageTimelineTableController * Fix Pagination directive * set any to scope for TS warnings * Convert wp-table-pagination * merged changes from Oliver * begin migrating WorkPackagesTableController * begin migrating WorkPackagesTableController * Apply karma fix to PR * Fix pagination options * WIP Angular migration wp-table.directive * Angular4 migration - table sums * Angular4 migration: fixed error message when no sums are displayed * Angular4 migration: removed superfluous Angular1 registration * WIP Angular4 migration * WIP Angular4 migration - removed unused directives - start migartion sortHeader directive * WIP Angular4 migration - sortHeader directive * WIP Angular4 migration: sort header * Angular4 migration: implemented dropDown directive for Angular4 * merged origin/dev * updated package-lock.json * use shrinkwrap instead of package-lock * Angular4 migration: fixed accessible_by_keyboard directive * WIP #26714 * reformat code * fixes #26714 pass projectIdentifier to wpTable * cleanup * fixes #26716 * WIP Angular4 migration: added support for test execution * wpTablePagination: convertered reasonable tests to Angular4 * merged dev branch, updated dependencies * fixed #26727 * Replace openproject initialization in head * fixed #26728 * Replace time entries and messages ng1 controllers * Remove unused timeline reference * Fix OP Helpers for member page * Fix initial cached paged options * Fixed broken inlineCreate * Only nil-check for table, projectIdentifier CAN be null
7 years ago
$compileProvider.debugInfoEnabled(window.OpenProject.environment === 'development');
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$httpProvider.defaults.headers.common['X-CSRF-TOKEN'] = jQuery(
'meta[name=csrf-token]').attr('content');
$httpProvider.defaults.headers.common['X-Authentication-Scheme'] = 'Session';
// Add X-Requested-With for request.xhr?
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
// prepend a given base path to requests performed via $http
//
$httpProvider.interceptors.push(function($q) {
return {
'request': function(config) {
// OpenProject can run in a subpath e.g. https://mydomain/open_project.
// We append the path found as the base-tag value to all http requests
// to the server except:
// * when the path is already appended
// * when we are getting a template
if (!config.url.match('(^/templates|\\.html$|^' + window.appBasePath + ')')) {
config.url = window.appBasePath + config.url;
}
return config || $q.when(config);
}
};
});
// add global event handlers
angular.element('body').attr('global-drag-and-drop-handler','');
}
])
.run([
'$http',
'$rootScope',
'$window',
'TimezoneService',
'ExpressionService',
'CacheService',
'KeyboardShortcutService',
function($http,
$rootScope,
$window,
TimezoneService,
ExpressionService,
CacheService,
KeyboardShortcutService) {
$http.defaults.headers.common.Accept = 'application/json';
// Set the escaping target of opening double curly braces
// This is what returned by rails-angular-xss when it discoveres double open curly braces
// See https://github.com/opf/rails-angular-xss for more information.
$rootScope.DOUBLE_LEFT_CURLY_BRACE = ExpressionService.UNESCAPED_EXPRESSION;
if ($window.innerWidth < 680) {
// On mobile sized screens navigation shall allways be callapsed when
// window loads.
$rootScope.showNavigation = false
} else {
$rootScope.showNavigation =
$window.sessionStorage.getItem('openproject:navigation-toggle') !==
'collapsed';
}
TimezoneService.setupLocale();
KeyboardShortcutService.activate();
// Disable the CacheService for test environment
Angular 4 support and upgraded timeline header directive (#5984) * Added Angular4 dependency and initial setup * Angular 4 transition: timeline header directive * removed superfluous require declaration * moved Angular4 dependencies to vendor.js * Angular4: upgraded timeline relations directive * Fixes karma tests. However, logging seems to be broken now. * Angular4: upgraded directive wpTimelineStaticElements * dev rebase * WIP Angular 4+ transition * converted WorkPackageTableTimelineGrid to Angular4+ * start migrating WorkPackageTimelineTableController to Angular4+ * completed migration of component tree WorkPackageTimelineTableController * Fix Pagination directive * set any to scope for TS warnings * Convert wp-table-pagination * merged changes from Oliver * begin migrating WorkPackagesTableController * begin migrating WorkPackagesTableController * Apply karma fix to PR * Fix pagination options * WIP Angular migration wp-table.directive * Angular4 migration - table sums * Angular4 migration: fixed error message when no sums are displayed * Angular4 migration: removed superfluous Angular1 registration * WIP Angular4 migration * WIP Angular4 migration - removed unused directives - start migartion sortHeader directive * WIP Angular4 migration - sortHeader directive * WIP Angular4 migration: sort header * Angular4 migration: implemented dropDown directive for Angular4 * merged origin/dev * updated package-lock.json * use shrinkwrap instead of package-lock * Angular4 migration: fixed accessible_by_keyboard directive * WIP #26714 * reformat code * fixes #26714 pass projectIdentifier to wpTable * cleanup * fixes #26716 * WIP Angular4 migration: added support for test execution * wpTablePagination: convertered reasonable tests to Angular4 * merged dev branch, updated dependencies * fixed #26727 * Replace openproject initialization in head * fixed #26728 * Replace time entries and messages ng1 controllers * Remove unused timeline reference * Fix OP Helpers for member page * Fix initial cached paged options * Fixed broken inlineCreate * Only nil-check for table, projectIdentifier CAN be null
7 years ago
if (window.OpenProject.environment === 'test') {
CacheService.disableCaching();
}
$rootScope.$on('$stateChangeError',
function(event){
event.preventDefault();
// transitionTo() promise will be rejected with
// a 'transition prevented' error
});
}
]);
require('./helpers');
require('./layout');
require('./models');
require('./services');
require('./ui_components');
require('./work_packages');
// Run the browser detection
require('expose-loader?bowser!bowser');
var requireTemplate = require.context('./templates', true, /\.html$/);
requireTemplate.keys().forEach(requireTemplate);
var requireComponent = require.context('./components/', true, /^((?!\.(test|spec)).)*\.(js|ts|html)$/);
requireComponent.keys().forEach(requireComponent);
const debugOutput = require("./helpers/debug_output");
debugOutput.whenDebugging(function () {
const reactivestates = require("reactivestates");
reactivestates.enableReactiveStatesLogging();
});
Angular 4 support and upgraded timeline header directive (#5984) * Added Angular4 dependency and initial setup * Angular 4 transition: timeline header directive * removed superfluous require declaration * moved Angular4 dependencies to vendor.js * Angular4: upgraded timeline relations directive * Fixes karma tests. However, logging seems to be broken now. * Angular4: upgraded directive wpTimelineStaticElements * dev rebase * WIP Angular 4+ transition * converted WorkPackageTableTimelineGrid to Angular4+ * start migrating WorkPackageTimelineTableController to Angular4+ * completed migration of component tree WorkPackageTimelineTableController * Fix Pagination directive * set any to scope for TS warnings * Convert wp-table-pagination * merged changes from Oliver * begin migrating WorkPackagesTableController * begin migrating WorkPackagesTableController * Apply karma fix to PR * Fix pagination options * WIP Angular migration wp-table.directive * Angular4 migration - table sums * Angular4 migration: fixed error message when no sums are displayed * Angular4 migration: removed superfluous Angular1 registration * WIP Angular4 migration * WIP Angular4 migration - removed unused directives - start migartion sortHeader directive * WIP Angular4 migration - sortHeader directive * WIP Angular4 migration: sort header * Angular4 migration: implemented dropDown directive for Angular4 * merged origin/dev * updated package-lock.json * use shrinkwrap instead of package-lock * Angular4 migration: fixed accessible_by_keyboard directive * WIP #26714 * reformat code * fixes #26714 pass projectIdentifier to wpTable * cleanup * fixes #26716 * WIP Angular4 migration: added support for test execution * wpTablePagination: convertered reasonable tests to Angular4 * merged dev branch, updated dependencies * fixed #26727 * Replace openproject initialization in head * fixed #26728 * Replace time entries and messages ng1 controllers * Remove unused timeline reference * Fix OP Helpers for member page * Fix initial cached paged options * Fixed broken inlineCreate * Only nil-check for table, projectIdentifier CAN be null
7 years ago
// load Angular 4 modules
require("./angular4-modules");