Permalink
Browse files

RAXAJSS-49 Create a Dashboard to Link Different modules

  • Loading branch information...
Tushar Tushar
Tushar authored and Tushar committed May 21, 2012
1 parent 64454ee commit f48ad1523a4a575f5e054e4ad7906d2400182fe2
@@ -1,9 +1,7 @@
Ext.define('RaxaEmr.controller.Session', {
extend: 'Ext.app.Controller',
config: {
- before: {
- showDashboard: 'loginSuccess'
- },
+
routes: {
'Login': 'showLogin',
@@ -31,6 +29,17 @@ Ext.define('RaxaEmr.controller.Session', {
},
showDashboard: function () {
+ var privileges = localStorage.getItem("privileges");
+ var allModules = Util.getModules();
+ var userModules = [];
+ //starting at index=1 here, don't need app button for 'login'
+ for(i=1;i<allModules.length;i++){
+ //checking if user is allows to view the module
+ if(privileges.indexOf('RaxaEmrView '+allModules[i])!==-1){
+ userModules[userModules.length] = allModules[i];
+ }
+ }
+ Ext.getCmp('appGrid').addModules(userModules);
window.location.hash = 'Dashboard';
Ext.getCmp('mainView').setActiveItem(1);
},
View
@@ -1,62 +1,58 @@
-/*
- * This view contains a grid of buttons that allow the user to choose a module
- * The module icons are located at src/resources/img/*.png
- */
-Ext.define('RaxaEmr.view.AppGrid', {
- extend: 'Ext.Container',
- id: 'appGrid',
- config: {
- layout: 'fit'
- },
- initialize: function (args) {
- this.callParent();
- },
-
- //addModules takes in a string array of the modules for the current user, populates dashboard icon grid
- addModules: function (args) {
- //must destroy our panel if we ever call again (if the user logs out for example)
- if (Ext.getCmp('modulesPanel')) {
- Ext.getCmp('modulesPanel').destroy();
- }
- //finding the number of rows for icon grid for best fit
- var numRows = Math.ceil(Math.sqrt(args.length));
- var modulesPanel = Ext.create('Ext.Container', {
- centered: true,
- id: 'modulesPanel'
- });
- var appRows = [];
- for (var i = 0; i < args.length / numRows; i++) {
- appRows[i] = Ext.create('Ext.Panel', {
- layout: {
- type: 'hbox',
- pack: 'center'
- }
- });
- }
- for (var j = 0; j < args.length; j++) {
- var cell = Ext.create('Ext.Panel', {
- items: [{
- layout: 'vbox',
- xtype: 'button',
- id: args[j],
- //TODO: add in various icons for the modules
- //icon: 'resources/img/' + args[j] + 'Logo.png',
- icon: 'resources/img/moduleLogo.png',
- width: '250px',
- height: '80px',
- text: args[j],
- listeners: {
- tap: function () {
- window.location = this.id;
- }
- }
- }]
- });
- appRows[Math.floor(j / numRows)].add(cell);
- }
- for (var i = 0; i < numRows; i++) {
- modulesPanel.add(appRows[i]);
- }
- this.add(modulesPanel);
- }
+/*
+ * This view contains a grid of buttons that allow the user to choose a module
+ * The module icons are located at src/resources/img/*.png
+ */
+Ext.define('RaxaEmr.view.AppGrid', {
+ extend: 'Ext.Container',
+ id: 'appGrid',
+ config: {
+ layout: 'fit'
+ },
+ initialize: function (args) {
+ this.callParent();
+ },
+
+ //addModules takes in a string array of the modules for the current user, populates dashboard icon grid
+ addModules: function (args) {
+ //must destroy our panel if we ever call again (if the user logs out for example)
+ if (Ext.getCmp('modulesPanel')) {
+ Ext.getCmp('modulesPanel').destroy();
+ }
+ //finding the number of rows for icon grid for best fit
+ var numRows = Math.ceil(Math.sqrt(args.length));
+ var modulesPanel = Ext.create('Ext.Container', {
+ centered: true,
+ id: 'modulesPanel'
+ });
+ var appRows = [];
+ for (var i = 0; i < args.length / numRows; i++) {
+ appRows[i] = Ext.create('Ext.Panel', {
+ layout: {
+ type: 'hbox',
+ pack: 'center'
+ }
+ });
+ }
+ for (var j = 0; j < args.length; j++) {
+ var cell = Ext.create('Ext.Panel', {
+ items: [{
+ layout: 'vbox',
+ xtype: 'button',
+ id: args[j],
+ html: '<div style="text-align:center;"><img src="resources/img/' +args[j] + '.png" width="180" height="180"/></div>',
+
+ listeners: {
+ tap: function () {
+ window.location = this.id;
+ }
+ }
+ }]
+ });
+ appRows[Math.floor(j / numRows)].add(cell);
+ }
+ for (var i = 0; i < numRows; i++) {
+ modulesPanel.add(appRows[i]);
+ }
+ this.add(modulesPanel);
+ }
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,74 +1,76 @@
-/*
- * This class provides util methods that are shared by the core, apps and modules
- */
-if (localStorage.getItem("host") == null) {
- var HOST = 'http://raxaemr.jelastic.dogado.eu';
-} else HOST = localStorage.getItem("host");
-
-var username = 'admin';
-var password = 'Hello123';
-
-var Util = {
- /**
- * Returns all the headers required for Basic Authenticated REST calls
- * @return headers object that includes Authorization, Accept and Content-Type
- */
- getBasicAuthHeaders: function () {
- var headers = {
- "Authorization": localStorage.getItem("basicAuthHeader"),
- "Accept": "application/json",
- "Content-Type": "application/json"
- }
- return headers;
- },
-
- /**
- * Logout the current user. Ends the current session
- */
- logoutUser: function () {
- Ext.Ajax.request({
- url: HOST + '/ws/rest/v1/session',
- withCredentials: true,
- useDefaultXhrHeader: false,
- method: 'DELETE',
- success: function () {
- // do nothing
- }
- });
- },
-
- /**
- * Saves the Basic Authentication header to Localstorage
- * Verifies if username + password is valid on server and saves as Base64 encoded string of user:pass
- */
- saveBasicAuthHeader: function (username, password) {
- Util.logoutUser(); // Delete existing logged in sessions
- // Check login and save to localStorage if valid
- Ext.Ajax.request({
- url: HOST + '/ws/rest/v1/session',
- withCredentials: true,
- useDefaultXhrHeader: false,
- headers: {
- "Accept": "application/json",
- "Authorization": "Basic " + window.btoa(username + ":" + password)
- },
- success: function (response) {
- var authenticated = Ext.decode(response.responseText).authenticated;
- if (authenticated) {
- localStorage.setItem("basicAuthHeader", "Basic " + window.btoa(username + ":" + password));
- } else {
- localStorage.removeItem("basicAuthHeader");
- }
- }
- });
- },
-
- /**
- * Returns all the modules in Raxa
- * @return [ 'login', 'screener', ....]
- */
- getModules: function () {
- //always keep login at first position as its app path is different
- return ['login', 'screener', 'registration', 'registrationextjs4'];
- }
-}
+/*
+ * This class provides util methods that are shared by the core, apps and modules
+ */
+if (localStorage.getItem("host") == null) {
+ var HOST = 'http://raxaemr.jelastic.dogado.eu';
+} else HOST = localStorage.getItem("host");
+
+var username = 'admin';
+var password = 'Hello123';
+
+var Util = {
+ /**
+ * Returns all the headers required for Basic Authenticated REST calls
+ * @return headers object that includes Authorization, Accept and Content-Type
+ */
+ getBasicAuthHeaders: function () {
+ var headers = {
+ "Authorization": localStorage.getItem("basicAuthHeader"),
+ "Accept": "application/json",
+ "Content-Type": "application/json"
+ }
+ return headers;
+ },
+
+ /**
+ * Logout the current user. Ends the current session
+ */
+ logoutUser: function () {
+ Ext.Ajax.request({
+ url: HOST + '/ws/rest/v1/session',
+ withCredentials: true,
+ useDefaultXhrHeader: false,
+ method: 'DELETE',
+ success: function () {
+ // do nothing
+ }
+ });
+ },
+
+ /**
+ * Saves the Basic Authentication header to Localstorage
+ * Verifies if username + password is valid on server and saves as Base64 encoded string of user:pass
+ */
+ saveBasicAuthHeader: function (username, password) {
+ Util.logoutUser(); // Delete existing logged in sessions
+ // Check login and save to localStorage if valid
+ Ext.Ajax.request({
+ url: HOST + '/ws/rest/v1/session',
+ withCredentials: true,
+ useDefaultXhrHeader: false,
+ headers: {
+ "Accept": "application/json",
+ "Authorization": "Basic " + window.btoa(username + ":" + password)
+ },
+ success: function (response) {
+ var authenticated = Ext.decode(response.responseText).authenticated;
+ if (authenticated) {
+ localStorage.setItem("basicAuthHeader", "Basic " + window.btoa(username + ":" + password));
+ } else {
+ localStorage.removeItem("basicAuthHeader");
+ }
+ }
+ });
+ },
+
+ /**
+ * Returns all the modules in Raxa
+ * @return [ 'login', 'screener', ....]
+ */
+ getModules: function () {
+ //always keep login at first position as its app path is different
+ return ['login', 'screener', 'registration', 'registrationextjs4'];
+ //TO DO:Add the line below instead the above one
+ //return ['login', 'screener', 'registration','opd','inpatient','pharmacy','radiology','laboratory','billing'];
+ }
+}

0 comments on commit f48ad15

Please sign in to comment.