Web Interface For Lite Argus Control modules
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.

68 lines
3.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. /**
  8. * @class Ext.data.MemoryProxy
  9. * @extends Ext.data.DataProxy
  10. * An implementation of Ext.data.DataProxy that simply passes the data specified in its constructor
  11. * to the Reader when its load method is called.
  12. * @constructor
  13. * @param {Object} data The data object which the Reader uses to construct a block of Ext.data.Records.
  14. */
  15. Ext.data.MemoryProxy = function(data){
  16. // Must define a dummy api with "read" action to satisfy DataProxy#doRequest and Ext.data.Api#prepare *before* calling super
  17. var api = {};
  18. api[Ext.data.Api.actions.read] = true;
  19. Ext.data.MemoryProxy.superclass.constructor.call(this, {
  20. api: api
  21. });
  22. this.data = data;
  23. };
  24. Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
  25. /**
  26. * @event loadexception
  27. * Fires if an exception occurs in the Proxy during data loading. Note that this event is also relayed
  28. * through {@link Ext.data.Store}, so you can listen for it directly on any Store instance.
  29. * @param {Object} this
  30. * @param {Object} arg The callback's arg object passed to the {@link #load} function
  31. * @param {Object} null This parameter does not apply and will always be null for MemoryProxy
  32. * @param {Error} e The JavaScript Error object caught if the configured Reader could not read the data
  33. */
  34. /**
  35. * MemoryProxy implementation of DataProxy#doRequest
  36. * @param {String} action
  37. * @param {Ext.data.Record/Ext.data.Record[]} rs If action is load, rs will be null
  38. * @param {Object} params An object containing properties which are to be used as HTTP parameters
  39. * for the request to the remote server.
  40. * @param {Ext.data.DataReader} reader The Reader object which converts the data
  41. * object into a block of Ext.data.Records.
  42. * @param {Function} callback The function into which to pass the block of Ext.data.Records.
  43. * The function must be passed <ul>
  44. * <li>The Record block object</li>
  45. * <li>The "arg" argument from the load function</li>
  46. * <li>A boolean success indicator</li>
  47. * </ul>
  48. * @param {Object} scope The scope (<code>this</code> reference) in which the callback function is executed. Defaults to the browser window.
  49. * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
  50. */
  51. doRequest : function(action, rs, params, reader, callback, scope, arg) {
  52. // No implementation for CRUD in MemoryProxy. Assumes all actions are 'load'
  53. params = params || {};
  54. var result;
  55. try {
  56. result = reader.readRecords(this.data);
  57. }catch(e){
  58. // @deprecated loadexception
  59. this.fireEvent("loadexception", this, null, arg, e);
  60. this.fireEvent('exception', this, 'response', action, arg, null, e);
  61. callback.call(scope, null, arg, false);
  62. return;
  63. }
  64. callback.call(scope, result, arg, true);
  65. }
  66. });