Advertisement
Guest User

Untitled

a guest
May 19th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 10.36 KB | None | 0 0
  1. Index: js/HermesJS/modules.json
  2. ===================================================================
  3. --- js/HermesJS/modules.json    (revision 3474)
  4. +++ js/HermesJS/modules.json    (working copy)
  5. @@ -23,12 +23,16 @@
  6.          'portalispm.widget.Combobox'                : 'modules.portalispm.widget.combobox',
  7.          'portalispm.widget.Itemselector'            : 'modules.portalispm.widget.itemselector',
  8.          'portalispm.WidgetTest'                     : 'modules.portalispm.widgetTest',
  9. -        'portalispm.widget.TextField'             : 'modules.portalispm.widget.textField',
  10. -        'portalispm.widget.TextMulti'             : 'modules.portalispm.widget.textMulti',
  11. -      
  12. -       // System Templates
  13. -       'portalispm.system.templates.LocalTemplate' : 'modules.portalispm.system.templates.localTemplate',
  14. +        'portalispm.widget.TextField'               : 'modules.portalispm.widget.textField',
  15. +        'portalispm.widget.TextMulti'               : 'modules.portalispm.widget.textMulti',
  16. +        
  17. +        // System Templates
  18. +        'portalispm.system.templates.LocalTemplate'  : 'modules.portalispm.system.templates.localTemplate',
  19. +        'portalispm.system.templates.RemoteTemplate' : 'modules.portalispm.system.templates.remoteTemplate',
  20.  
  21. +        // System
  22. +        'system.RemoteSystem': 'modules.portalispm.system.remoteSystem',
  23. +
  24.          // Incident
  25.          'incident.ticket.Edit'                      : 'modules.incident.ticket.edit',
  26.          
  27. @@ -137,10 +141,7 @@
  28.          
  29.          //Ivreport
  30.          'performance.report.ViewReports'                  : 'modules.performance.report.viewReports'
  31. -        
  32. -        
  33. -        
  34. -        },
  35. +    },
  36.    
  37.     functions : {
  38.          'get'                                 : 'functions.global',
  39. Index: js/modules/portalispm/system/remoteSystem.js
  40. ===================================================================
  41. --- js/modules/portalispm/system/remoteSystem.js    (revision 0)
  42. +++ js/modules/portalispm/system/remoteSystem.js    (revision 0)
  43. @@ -0,0 +1,66 @@
  44. +Ext.namespace('system');
  45. +
  46. +/**
  47. + * Screen used per remote systems
  48. + *
  49. + * @author Felipe Cardoso Martins
  50. + *
  51. + * @class portalispm.system.RemoteSystems
  52. + */
  53. +system.RemoteSystem = Ext.extend(
  54. +    function() {},
  55. +    {
  56. +        /**
  57. +         * Do login
  58. +         */
  59. +        doLogin: function()
  60. +        {
  61. +            if (this._config.authenticationType == 'htmlForm') {
  62. +                
  63. +                // create form
  64. +                var loginForm = new NExt.form.FormPanel({
  65. +                    name: 'form_'  + this._config.formName,
  66. +                    standardSubmit: true,
  67. +                    hidden: true,
  68. +                    defaults: { forceLayout: false },
  69. +                    defaultType: 'textfield',
  70. +                    items: [
  71. +                        {
  72. +                            name: this._config.usernameField,
  73. +                            value: this._config.username
  74. +                        },
  75. +                        {
  76. +                            name: this._config.passwordField,
  77. +                            value: this._config.password
  78. +                        }
  79. +                    ]
  80. +                });
  81. +                
  82. +                this._tab.add(loginForm);
  83. +                
  84. +                // create iframe
  85. +                var frameName = "iframe_" + this._config.formName;
  86. +                var targetClass = new portalispm.system.templates.RemoteTemplate(this._config.url, frameName);
  87. +                var instance = new targetClass(this._tab);
  88. +                
  89. +                // submit form to iframe
  90. +                loginForm.getForm().getEl().dom.target = frameName;
  91. +                loginForm.getForm().getEl().dom.action = this._config.url;
  92. +                loginForm.getForm().submit({});
  93. +                
  94. +                return instance;
  95. +            }
  96. +        },
  97. +        
  98. +        /**
  99. +         * Constructor
  100. +         */
  101. +        constructor: function(config, tab)
  102. +        {
  103. +            this._config = config;
  104. +            this._tab = tab;
  105. +            
  106. +            return this.doLogin();
  107. +        }
  108. +    }
  109. +);
  110. \ No newline at end of file
  111. Index: js/modules/portalispm/system/templates/remoteTemplate.js
  112. ===================================================================
  113. --- js/modules/portalispm/system/templates/remoteTemplate.js    (revision 0)
  114. +++ js/modules/portalispm/system/templates/remoteTemplate.js    (revision 0)
  115. @@ -0,0 +1,72 @@
  116. +Ext.namespace( 'portalispm.system.templates' );
  117. +
  118. +/**
  119. + * Template de sistema RemoteTemplate
  120. + *
  121. + * +--------------------------+
  122. + * |           TOP            |
  123. + * +---+----------------------+
  124. + * |                          |
  125. + * |                          |
  126. + * |           Frame          |
  127. + * |                          |
  128. + * +---+----------------------+
  129. + *
  130. + * @author Felipe Cardoso Martins
  131. + * @class portalispm.system.templates.RemoteTemplate
  132. + * @extends portalispm.System
  133. + */
  134. +portalispm.system.templates.RemoteTemplate = Ext.extend(
  135. +    function() {},
  136. +    {
  137. +        /**
  138. +         * Create template
  139. +         * @function
  140. +         * @private
  141. +         */
  142. +        _createTemplate: function(url, name)
  143. +        {
  144. +            portalispm.system.templates.RemoteTemplate.template = Ext.extend(
  145. +                portalispm.System,
  146. +                {
  147. +                    /**
  148. +                     * Cria o Layout
  149. +                     * @function
  150. +                     * @private
  151. +                     */
  152. +                    _createLayout: function(tab)
  153. +                    {
  154. +                        tab.add(
  155. +                            new Ext.Panel({
  156. +                                html: '<iframe src="'+url+'" name="'+name+'" width="100%" height="100%"></iframe>'
  157. +                            })
  158. +                        );
  159. +                        tab.doLayout();
  160. +                    },
  161. +                    
  162. +                    /**
  163. +                     * Construtor
  164. +                     * @function
  165. +                     * @private
  166. +                     */
  167. +                    constructor : function(tab)
  168. +                    {
  169. +                        portalispm.system.templates.RemoteTemplate.template.superclass.constructor.call(this);
  170. +                        this._createLayout(tab);
  171. +                    }
  172. +                }
  173. +            );
  174. +        },
  175. +        
  176. +        /**
  177. +         * Constructor
  178. +         * @function
  179. +         * @private
  180. +         */
  181. +        constructor: function(url, name)
  182. +        {
  183. +            this._createTemplate(url, name);
  184. +            return portalispm.system.templates.RemoteTemplate.template;
  185. +        }
  186. +    }
  187. +);
  188. \ No newline at end of file
  189. Index: js/modules/portalispm/portalispm.js
  190. ===================================================================
  191. --- js/modules/portalispm/portalispm.js (revision 3474)
  192. +++ js/modules/portalispm/portalispm.js (working copy)
  193. @@ -256,14 +256,17 @@
  194.      this.initTab = function( tab ){
  195.          tab.un( 'activate', $this.initTab );
  196.          
  197. -        if( typeof tab.portal[ 'class' ] == 'string' ){
  198. -            var targetClass = eval( tab.portal[ 'class' ] );
  199. -        }else{
  200. -            var targetClass = tab.portal[ 'class' ];
  201. +        if (tab.portal['remoteSystem']['url'] == '') {
  202. +            if( typeof tab.portal[ 'class' ] == 'string' ) {
  203. +                var targetClass = eval( tab.portal[ 'class' ] );
  204. +            }else{
  205. +                var targetClass = tab.portal[ 'class' ];
  206. +            }
  207. +            tab.instance = new targetClass(tab);
  208. +        } else {
  209. +            tab.instance = new system.RemoteSystem(tab.portal['remoteSystem'], tab);
  210.          }
  211.          
  212. -        tab.instance = new targetClass( tab );
  213. -        
  214.          if( tab.portal.system ){
  215.              tab.instance.setID( tab.portal.system.id );
  216.              tab.instance.setName( tab.portal.system.name );
  217. @@ -286,18 +289,36 @@
  218.              url : '/access/listMySystems',
  219.              disableCaching : false,
  220.              success : function( data, config ){
  221. -                for( var i = 0; i < data.results.length; i++ ){
  222. -                    var className = String( data.results[ i ].name || '' );
  223. -                    $this.addTab( {
  224. -                        title : data.results[ i ].name,
  225. -                        portal : {
  226. -                            'class' : className.toLowerCase() + '.' + className,
  227. -                            system : {
  228. -                                id : data.results[ i ].id,
  229. -                                name : data.results[ i ].name
  230. -                            }
  231. -                        }
  232. -                    } );
  233. +                for( var i = 0; i < data.results.length; i++ ) {
  234. +                    
  235. +                    var className = String(data.results[ i ].name || '');
  236. +                    var url = String(data.results[i].url || '');
  237. +                    var username = String(data.results[i].username || '');
  238. +                    var password = String(data.results[i].password || '');
  239. +                    var formName = String(data.results[i].formName || '');
  240. +                    var usernameField = String(data.results[i].usernameField || '');
  241. +                    var passwordField = String(data.results[i].passwordField || '');
  242. +                    var authenticationType = String(data.results[i].authenticationType || '');
  243. +                    
  244. +                    $this.addTab({
  245. +                        title: data.results[ i ].name,
  246. +                        portal: {
  247. +                            'class': className.toLowerCase() + '.' + className,
  248. +                            remoteSystem: {
  249. +                                url: url,
  250. +                                username: username,
  251. +                                password: password,
  252. +                                formName: formName,
  253. +                                usernameField: usernameField,
  254. +                                passwordField: passwordField,
  255. +                                authenticationType: authenticationType
  256. +                            },
  257. +                            system: {
  258. +                                id: data.results[ i ].id,
  259. +                                name: data.results[ i ].name
  260. +                            }
  261. +                        }
  262. +                    });
  263.                  }
  264.                  
  265.                  $this.unmask();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement