main.js 9.37 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

require.config({
    /* starting point for application */
21 22 23
    'hbs': {
        'disableI18n': true, // This disables the i18n helper and doesn't require the json i18n files (e.g. en_us.json)
        'helperPathCallback': // Callback to determine the path to look for helpers
24 25 26
            function(name) { // ('/template/helpers/'+name by default)
            return 'modules/Helpers';
        },
27 28
        'templateExtension': 'html', // Set the extension automatically appended to templates
        'compileOptions': {} // options object which is passed to Handlebars compiler
29 30 31 32 33 34 35 36
    },
    /**
     * Requested as soon as the loader has processed the configuration. It does
     * not block any other require() calls from starting their requests for
     * modules, it is just a way to specify some modules to load asynchronously
     * as part of a config block.
     * @type {Array} An array of dependencies to load.
     */
37
    'deps': ['marionette'],
38 39 40 41 42 43

    /**
     * The number of seconds to wait before giving up on loading a script.
     * @default 7 seconds
     * @type {Number}
     */
44
    'waitSeconds': 30,
45

46 47 48 49
    'shim': {
        'backbone': {
            'deps': ['underscore', 'jquery'],
            'exports': 'Backbone'
50
        },
51
        'jquery-ui': {
52
            'deps': ['jquery']
53
        },
54 55 56
        'asBreadcrumbs': {
            'deps': ['jquery'],
            'exports': 'asBreadcrumbs'
57
        },
58 59 60
        'bootstrap': {
            'deps': ['jquery'],
            'exports': 'jquery'
61
        },
62 63
        'underscore': {
            'exports': '_'
64
        },
65 66
        'marionette': {
            'deps': ['backbone']
67
        },
68 69 70
        'backgrid': {
            'deps': ['backbone'],
            'exports': 'Backgrid'
71 72
        },
        'backgrid-paginator': {
73
            'deps': ['backbone', 'backgrid']
74 75
        },
        'backgrid-filter': {
76
            'deps': ['backbone', 'backgrid']
77 78
        },
        'backgrid-orderable': {
79
            'deps': ['backbone', 'backgrid'],
80 81
        },
        'backgrid-sizeable': {
82
            'deps': ['backbone', 'backgrid'],
83
        },
84
        'backgrid-select-all': {
85
            'deps': ['backbone', 'backgrid']
86
        },
87 88 89
        'backgrid-columnmanager': {
            'deps': ['backbone', 'backgrid'],
        },
90 91
        'hbs': {
            'deps': ['underscore', 'handlebars']
92
        },
93 94
        'd3': {
            'exports': ['d3']
95 96
        },
        'd3-tip': {
97 98
            'deps': ['d3'],
            'exports': ['d3-tip']
99
        },
100 101 102
        'dagreD3': {
            'deps': ['d3'],
            'exports': ['dagreD3']
103
        },
104 105 106 107 108
        'pnotify': {
            'exports': ['pnotify']
        },
        'jquery-placeholder': {
            'deps': ['jquery']
109 110 111 112 113 114
        },
        'query-builder': {
            'deps': ['jquery']
        },
        'daterangepicker': {
            'deps': ['jquery', 'moment']
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
        }
    },

    paths: {
        'jquery': 'libs/jquery/js/jquery.min',
        'underscore': 'libs/underscore/underscore-min',
        'bootstrap': 'libs/bootstrap/js/bootstrap.min',
        'backbone': 'libs/backbone/backbone-min',
        'backbone.babysitter': 'libs/backbone.babysitter/lib/backbone.babysitter.min',
        'marionette': 'libs/backbone-marionette/backbone.marionette.min',
        'backbone.paginator': 'libs/backbone-paginator/backbone.paginator.min',
        'backbone.wreqr': 'libs/backbone-wreqr/backbone.wreqr.min',
        'backgrid': 'libs/backgrid/js/backgrid',
        'backgrid-filter': 'libs/backgrid-filter/js/backgrid-filter.min',
        'backgrid-orderable': 'libs/backgrid-orderable-columns/js/backgrid-orderable-columns',
        'backgrid-paginator': 'libs/backgrid-paginator/js/backgrid-paginator.min',
        'backgrid-sizeable': 'libs/backgrid-sizeable-columns/js/backgrid-sizeable-columns',
132
        'backgrid-columnmanager': 'libs/backgrid-columnmanager/js/Backgrid.ColumnManager',
133 134 135 136 137
        'asBreadcrumbs': 'libs/jquery-asBreadcrumbs/js/jquery-asBreadcrumbs.min',
        'd3': 'libs/d3/d3.min',
        'd3-tip': 'libs/d3/index',
        'tmpl': 'templates',
        'requirejs.text': 'libs/requirejs-text/text',
138 139 140
        'handlebars': 'external_lib/require-handlebars-plugin/js/handlebars',
        'hbs': 'external_lib/require-handlebars-plugin/js/hbs',
        'i18nprecompile': 'external_lib/require-handlebars-plugin/js/i18nprecompile',
141
        'dagreD3': 'libs/dagre-d3/dagre-d3.min',
142
        'select2': 'libs/select2/select2.full.min',
143
        'backgrid-select-all': 'libs/backgrid-select-all/backgrid-select-all.min',
144
        'moment': 'libs/moment/js/moment.min',
145
        'jquery-ui': 'external_lib/jquery-ui/jquery-ui.min',
146 147 148
        'pnotify': 'external_lib/pnotify/pnotify.custom.min',
        'pnotify.buttons': 'external_lib/pnotify/pnotify.custom.min',
        'pnotify.confirm': 'external_lib/pnotify/pnotify.custom.min',
149
        'jquery-placeholder': 'libs/jquery-placeholder/js/jquery.placeholder',
150 151 152
        'platform': 'libs/platform/platform',
        'query-builder': 'libs/jQueryQueryBuilder/js/query-builder.standalone.min',
        'daterangepicker': 'libs/bootstrap-daterangepicker/js/daterangepicker'
153 154 155 156 157 158 159 160
    },

    /**
     * If set to true, an error will be thrown if a script loads that does not
     * call define() or have a shim exports string value that can be checked.
     * To get timely, correct error triggers in IE, force a define/shim export.
     * @type {Boolean}
     */
161
    'enforceDefine': false
162 163 164 165
});

require(['App',
    'router/Router',
166 167
    'utils/CommonViewFunction',
    'utils/Globals',
168
    'utils/UrlLinks',
169
    'collection/VEntityList',
170
    'collection/VTagList',
171 172
    'utils/Overrides',
    'bootstrap',
173
    'd3',
174
    'select2'
175
], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
176
    var that = this;
177
    this.asyncFetchCounter = 5;
178
    this.entityDefCollection = new VEntityList();
179 180 181
    this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
    this.typeHeaders = new VTagList();
    this.typeHeaders.url = UrlLinks.typesApiUrl();
182 183 184
    this.enumDefCollection = new VTagList();
    this.enumDefCollection.url = UrlLinks.enumDefApiUrl();
    this.enumDefCollection.modelAttrName = "enumDefs";
185
    this.classificationDefCollection = new VTagList();
186 187

    App.appRouter = new Router({
188
        entityDefCollection: this.entityDefCollection,
189
        typeHeaders: this.typeHeaders,
190 191
        enumDefCollection: this.enumDefCollection,
        classificationDefCollection: this.classificationDefCollection
192 193 194 195 196 197 198
    });

    var startApp = function() {
        if (that.asyncFetchCounter === 0) {
            App.start();
        }
    };
199
    CommonViewFunction.userDataFetch({
200
        url: UrlLinks.sessionApiUrl(),
201 202 203 204 205
        callback: function(response) {
            if (response && response.userName) {
                Globals.userLogedIn.status = true;
                Globals.userLogedIn.response = response;
            }
206 207 208
            if (response && response['atlas.feature.taxonomy.enable'] !== undefined) {
                Globals.taxonomy = response['atlas.feature.taxonomy.enable']
            }
209 210 211 212 213 214
            if (response && response['atlas.entity.create.allowed'] !== undefined) {
                Globals.entityCreate = response['atlas.entity.create.allowed'];
            }
            if (response && response['atlas.entity.update.allowed'] !== undefined) {
                Globals.entityUpdate = response['atlas.entity.update.allowed'];
            }
215 216 217 218 219 220 221 222 223 224
            if (response && response['atlas.ui.editable.entity.types'] !== undefined) {
                var entityTypeList = response['atlas.ui.editable.entity.types'].trim().split(",");
                if (entityTypeList.length) {
                    if (entityTypeList[0] === "*") {
                        Globals.entityTypeConfList = [];
                    } else if (entityTypeList.length > 0) {
                        Globals.entityTypeConfList = entityTypeList;
                    }
                }
            }
225 226 227 228
            --that.asyncFetchCounter;
            startApp();
        }
    });
229 230 231 232 233 234 235 236 237
    this.entityDefCollection.fetch({
        skipDefaultError: true,
        complete: function() {
            --that.asyncFetchCounter;
            startApp();
        }
    });
    this.typeHeaders.fetch({
        skipDefaultError: true,
238 239 240
        complete: function() {
            --that.asyncFetchCounter;
            startApp();
241 242
        }
    });
243 244 245 246 247 248 249
    this.enumDefCollection.fetch({
        skipDefaultError: true,
        complete: function() {
            --that.asyncFetchCounter;
            startApp();
        }
    });
250 251 252 253 254 255 256
    this.classificationDefCollection.fetch({
        skipDefaultError: true,
        complete: function() {
            --that.asyncFetchCounter;
            startApp();
        }
    });
257
});