raimund@548: /** raimund@548: * Copyright (C) 2013 by Bundesamt fuer Strahlenschutz raimund@548: * Software engineering by Intevation GmbH raimund@548: * raimund@548: * This file is Free Software under the GNU GPL (v>=3) raimund@548: * and comes with ABSOLUTELY NO WARRANTY! Check out raimund@548: * the documentation coming with IMIS-Labordaten-Application for details. raimund@548: */ raimund@548: Ext.Loader.setConfig({ raimund@548: enabled: true, raimund@548: paths: { raimund@548: 'Ext.i18n': 'resources/lib/i18n/' raimund@548: } raimund@548: }); raimund@548: raimund@548: Ext.application({ raimund@548: raimund@548: // Name of the application. Do not change as this name is used in raimund@548: // references! raimund@548: name: 'Lada', raimund@548: raimund@548: // Setting up translations. This is done using a ext-plgin which can be raimund@548: // found on https://github.com/elmasse/Ext.i18n.Bundle raimund@548: requires: [ raimund@548: 'Lada.override.Table', andre@608: 'Lada.override.RestProxy', raimund@570: 'Lada.override.RowEditor', raimund@548: 'Ext.i18n.Bundle', raimund@548: 'Ext.layout.container.Column', raimund@548: 'Lada.store.Datenbasis', raimund@548: 'Lada.store.Messeinheiten', raimund@548: 'Lada.store.Messgroessen', raimund@548: 'Lada.store.Messmethoden', raimund@548: 'Lada.store.Messstellen', raimund@548: 'Lada.store.Netzbetreiber', raimund@548: 'Lada.store.Locations', raimund@548: 'Lada.store.Pflichtmessgroessen', raimund@548: 'Lada.store.Probenarten', raimund@548: 'Lada.store.Probenzusaetze', raimund@548: 'Lada.store.Staaten', raimund@548: 'Lada.store.Umwelt', raimund@548: 'Lada.store.Verwaltungseinheiten' raimund@548: ], raimund@548: bundle: { raimund@548: bundle: 'Lada', raimund@548: lang: 'de-DE', raimund@548: path: 'resources/i18n', raimund@548: noCache: true raimund@548: }, raimund@548: raimund@548: // Setting this variable to true triggers loading the Viewport.js raimund@548: // file which sets ob the viewport. raimund@668: //autoCreateViewport: true, raimund@548: raimund@548: // Start the application. raimund@548: launch: function() { andre@608: var queryString = document.location.href.split('?')[1]; andre@608: if (queryString) { andre@608: Lada.openIDParams = queryString; andre@608: } andre@608: Ext.Ajax.request({ andre@608: url: 'lada-server/login?return_to=' + window.location.href, andre@608: method: 'GET', andre@608: headers: { andre@608: 'X-OPENID-PARAMS': Lada.openIDParams andre@608: }, andre@608: scope: this, andre@608: success: this.onLoginSuccess, andre@608: failure: this.onLoginFailure andre@608: }); andre@608: }, andre@608: raimund@669: onLoginFailure: function(response) { andre@608: try { andre@608: var json = Ext.decode(response.responseText); andre@608: if (json) { raimund@669: if (json.message === '699') { andre@608: /* This is the unauthorized message with the authentication andre@608: * redirect in the data */ andre@608: var authUrl = json.data; andre@608: location.href = authUrl; andre@608: return; andre@608: } raimund@669: if (json.message === '698') { andre@608: /* This is general authentication error */ andre@608: Ext.MessageBox.alert('Kommunikation mit dem Login Server fehlgeschlagen', andre@608: json.data); andre@608: return; andre@608: } andre@608: } raimund@669: } raimund@669: catch (e) { andre@608: // This is likely a 404 or some unknown error. Show general error then. andre@608: } andre@608: Ext.MessageBox.alert('Kommunikation mit dem Lada Server fehlgeschlagen', andre@608: 'Es konnte keine erfolgreiche Verbindung zum lada server aufgebaut werden.'); andre@608: }, andre@608: raimund@669: onLoginSuccess: function() { andre@608: /* Strip out the openid query params to look nicers. */ andre@608: window.history.pushState(this.name, this.name, window.location.pathname); andre@608: raimund@668: Ext.create('Lada.view.Viewport'); raimund@668: andre@608: /* Todo maybe parse username and such from login service response */ raimund@548: Ext.create('Lada.store.Datenbasis', { raimund@548: storeId: 'datenbasis' raimund@548: }); raimund@548: Ext.create('Lada.store.Messeinheiten', { raimund@548: storeId: 'messeinheiten' raimund@548: }); raimund@548: Ext.create('Lada.store.Messgroessen', { raimund@548: storeId: 'messgroessen' raimund@548: }); raimund@548: Ext.create('Lada.store.Messmethoden', { raimund@548: storeId: 'messmethoden' raimund@548: }); raimund@548: Ext.create('Lada.store.Messstellen', { raimund@548: storeId: 'messstellen' raimund@548: }); raimund@548: Ext.create('Lada.store.Netzbetreiber', { raimund@548: storeId: 'netzbetreiber' raimund@548: }); raimund@548: Ext.create('Lada.store.Locations', { raimund@548: storeId: 'locations' raimund@548: }); raimund@548: Ext.create('Lada.store.Pflichtmessgroessen', { raimund@548: storeId: 'pflichtmessgroessen' raimund@548: }); raimund@548: Ext.create('Lada.store.Probenarten', { raimund@548: storeId: 'probenarten' raimund@548: }); raimund@548: Ext.create('Lada.store.Probenzusaetze', { raimund@548: storeId: 'probenzusaetze' raimund@548: }); raimund@548: Ext.create('Lada.store.Staaten', { raimund@548: storeId: 'staaten' raimund@548: }); raimund@548: Ext.create('Lada.store.Umwelt', { raimund@548: storeId: 'umwelt' raimund@548: }); raimund@548: Ext.create('Lada.store.Verwaltungseinheiten', { raimund@548: storeId: 'verwaltungseinheiten' raimund@548: }); raimund@548: }, raimund@548: raimund@548: // Define the controllers of the application. They will be initialized raimund@548: // first before the application "launch" function is called. raimund@548: controllers: [ raimund@548: 'Lada.controller.Filter', raimund@548: 'Lada.controller.FilterResult', raimund@587: 'Lada.controller.form.Probe', dustin@611: 'Lada.controller.form.Messung', raimund@607: 'Lada.controller.form.Ort', raimund@587: 'Lada.controller.grid.Ort', raimund@587: 'Lada.controller.grid.Probenzusatzwert', raimund@587: 'Lada.controller.grid.PKommentar', raimund@597: 'Lada.controller.grid.MKommentar', raimund@588: 'Lada.controller.grid.Messung', raimund@595: 'Lada.controller.grid.Messwert', raimund@638: 'Lada.controller.grid.Status', raimund@638: 'Lada.controller.Map', raimund@638: 'Lada.controller.form.Location' raimund@548: ] raimund@548: });