bemsconfigdata-view-model.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. 
  2. (function () {
  3. BemsWebApplication.BemsConfigDataViewModel = function (data) {
  4. this.SiteId = ko.observable();
  5. this.LoadDBIP = ko.observable();
  6. this.LoadDBUserID = ko.observable();
  7. this.LoadDBUserPW = ko.observable();
  8. this.LoadDBName = ko.observable();
  9. this.TargetDBIP = ko.observable();
  10. this.TargetDBUserID = ko.observable();
  11. this.TargetDBUserPW = ko.observable();
  12. this.TargetDBName = ko.observable();
  13. if (data)
  14. this.fromJS(data);
  15. };
  16. $.extend(BemsWebApplication.BemsConfigDataViewModel.prototype, {
  17. toJS: function () {
  18. return {
  19. SiteId: this.SiteId(),
  20. LoadDBIP: this.LoadDBIP(),
  21. LoadDBUserID: this.LoadDBUserID(),
  22. LoadDBUserPW: this.LoadDBUserPW(),
  23. LoadDBName: this.LoadDBName(),
  24. TargetDBIP: this.TargetDBIP(),
  25. TargetDBUserID: this.TargetDBUserID(),
  26. TargetDBUserPW: this.TargetDBUserPW(),
  27. TargetDBName: this.TargetDBName()
  28. };
  29. },
  30. fromJS: function (data) {
  31. if (data) {
  32. this.SiteId(data.SiteId);
  33. this.LoadDBIP(data.LoadDBIP);
  34. this.LoadDBUserID(data.LoadDBUserID);
  35. this.LoadDBUserPW(data.LoadDBUserPW);
  36. this.LoadDBName(data.LoadDBName);
  37. this.TargetDBIP(data.TargetDBIP);
  38. this.TargetDBUserID(data.TargetDBUserID);
  39. this.TargetDBUserPW(data.TargetDBUserPW);
  40. this.TargetDBName(data.TargetDBName);
  41. }
  42. }
  43. });
  44. })();