_ControlSidebar.cshtml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. @using WeApp.Authorization
  2. @using WeApp.Configuration
  3. @using WeApp.Helpers
  4. @using WeApp.Views.Shared.Modals
  5. @{
  6. var settingName = new Func<string, string>((s) => L(s.Replace(".", "")));
  7. }
  8. <!-- Control Sidebar -->
  9. <aside class="control-sidebar control-sidebar-light" style="background:transparent; border: none;">
  10. <div class="card card-iwb card-tabs">
  11. <div class="card-header p-0 pt-1 border-bottom-0" style="border-radius: 0;padding-left: 5px !important;">
  12. <ul class="nav nav-tabs" id="" role="tablist">
  13. <li class="nav-item">
  14. <a class="nav-link active" id="" data-toggle="pill" href="#control-setting">@(L("UserSetting"))</a>
  15. </li>
  16. @if (AbpSession.UserType == UsersAndRolesTypeDefinition.Supper || AbpSession.UserType == UsersAndRolesTypeDefinition.System)
  17. {
  18. <li class="nav-item">
  19. <a class="nav-link" id="custom-tabs-two-messages-tab" data-toggle="pill" href="#control-other">@(L("UserCache"))</a>
  20. </li>
  21. }
  22. </ul>
  23. </div>
  24. <div class="card-body">
  25. <div class="tab-content" id="">
  26. <div class="tab-pane fade active show" id="control-setting">
  27. <button class="btn btn-iwb btn-block" id="LoginImage" type="button"> @(settingName(PermissionNames.PagesUserSysSettingLoginImage)) </button>
  28. <button class="btn btn-iwb btn-block" id="HomeImage" type="button"> @(settingName(PermissionNames.PagesUserSysSettingHomeImage)) </button>
  29. <button class="btn btn-iwb btn-block" id="" type="button" onclick="NotificationSetting()"> @(L("NotificationSetting")) </button>
  30. </div>
  31. @if (AbpSession.UserType == UsersAndRolesTypeDefinition.Supper || AbpSession.UserType == UsersAndRolesTypeDefinition.System)
  32. {
  33. <div class="tab-pane fade" id="control-other">
  34. <button class="btn btn-iwb btn-block" id="RefreshCache"> @(settingName(PermissionNames.PagesUserSysSettingRefreshCache)) </button>
  35. <button class="btn btn-iwb btn-block" id="RefreshLang"> @(settingName(PermissionNames.PagesUserSysSettingRefreshLang)) </button>
  36. </div>
  37. }
  38. </div>
  39. </div>
  40. <!-- /.card -->
  41. </div>
  42. </aside>
  43. <!-- /.control-sidebar -->
  44. @{
  45. var imageModal = new ModalViewModel(L("SettingImage"), "", new ModalBodyViewModel(new List<Input>()
  46. {
  47. new InputFile("image",L("SettingImagePath")).SetImageOption("ImageInfo","ImageName","ImageExt")
  48. },"image-form"), "image-modal");
  49. @Html.Partial("Modals/_Modal", imageModal)
  50. //超级管理员和管理员才可操作
  51. if (AbpSession.UserType == UsersAndRolesTypeDefinition.Supper)
  52. {
  53. var cacheModal = new ModalViewModel("清除缓存", "", new ModalBodyViewModel(new List<Input>()
  54. {
  55. new Input("id",L("SettingCacheName")).SetNotRequired().SetSelectOptions(IwbCacheNames.GetCacheList(),isAddBlank:false)
  56. },"cache-form"), "cache-modal");
  57. @Html.Partial("Modals/_Modal", cacheModal);
  58. }
  59. var notificationSettingModal = new ModalViewModel(L("NotificationSetting"), "",new ModalBodyViewModel(new List<Input>(),"notificationSetting-form"), "notificationSetting-modal",0,"");
  60. @Html.Partial("Modals/_Modal", notificationSettingModal)
  61. }
  62. @using (Html.BeginScripts())
  63. {
  64. <!-- Control Sidebar-->
  65. <script>
  66. $(function() {
  67. $('#LoginImage').on('click', function () {
  68. $('#image-modal .iwb-file-label').text('@L("SelectFile")');
  69. window.OpenModal({
  70. modal: 'image-modal',
  71. url: '@(IwbConsts.ApiAppUrl)'+'Settings/LoginImage'
  72. });
  73. });
  74. $('#HomeImage').on('click',function() {
  75. $('#image-modal .iwb-file-label').text('@L("SelectFile")');
  76. window.OpenModal({
  77. modal: 'image-modal',
  78. url: '@(IwbConsts.ApiAppUrl)'+'Settings/HomeImage'
  79. });
  80. });
  81. $('#RefreshCache').on('click',function() {
  82. window.OpenModal({
  83. modal: 'cache-modal',
  84. url: '@(IwbConsts.ApiAppUrl)'+'Settings/CacheRefresh'
  85. });
  86. });
  87. $('#RefreshLang').on('click',function() {
  88. $.iwbAjax1({ url: '@(IwbConsts.ApiAppUrl)' + 'Settings/LangRefresh' });
  89. });
  90. });
  91. function NotificationSetting() {
  92. $.iwbAjax4({
  93. url: abp.appUrl + 'Notification/GetNotificationSettings',
  94. success: function(res) {
  95. var template = $('#NotificationSettingTemplate').html();
  96. Mustache.parse(template);
  97. var rendered = Mustache.render(template, res);
  98. $('#notificationSetting-form').html(rendered);
  99. window.OpenModal({
  100. modal: 'notificationSetting-modal',
  101. table:null,
  102. url: abp.appUrl + 'Notification/UpdateNotificationSettings',
  103. dataFun:GetNotificationSetting
  104. });
  105. }
  106. });
  107. }
  108. function ReceiveNotification(that) {
  109. var $that = $(that);
  110. if ($that.is(':checked')) {
  111. $that.closest("form").find('.s-box').fadeIn();
  112. } else {
  113. $that.closest("form").find('.s-box').fadeOut();
  114. $('.sub').prop('checked',false);
  115. }
  116. }
  117. function GetNotificationSetting() {
  118. var data = {};
  119. data.ReceiveNotifications = $('input[name="receiveNotifications"]').is(":checked");
  120. data.Notifications = [];
  121. $('.sub').each(function() {
  122. var $this = $(this);
  123. data.Notifications.push({ name: $this.attr('name'), isSubscribed: $this.is(":checked") });
  124. });
  125. console.log(data);
  126. return data;
  127. }
  128. </script>
  129. <script id="NotificationSettingTemplate" type="x-tmpl-mustache">
  130. <div style=" padding:5px;">
  131. <div class="custom-control custom-switch custom-switch-off-danger custom-switch-on-success">
  132. <input type="checkbox" class="custom-control-input" id="receiveNotifications" name="receiveNotifications" {{#receiveNotifications}} checked {{/receiveNotifications}}>
  133. <label class="custom-control-label" for="receiveNotifications">@(L("ReceiveNotificationsSetting"))</label>
  134. </div>
  135. </div>
  136. <div class="s-box" style=" {{^receiveNotifications}} display:none; {{/receiveNotifications}}padding:2px;">
  137. <hr style=" margin-top:5px;margin-bottom:8px;" />
  138. <h6 class="text-d text-center" style="font-size:0.875rem;">@(L("TickNotificationsToSubscribe"))</h6>
  139. {{#notifications}}
  140. <div class="custom-control custom-switch" style="width:33%;float:left;">
  141. <input type="checkbox" class="custom-control-input sub" id="N_{{name}}" name="{{name}}" {{#isSubscribed}} checked {{/isSubscribed}}>
  142. <label class="custom-control-label" for="N_{{name}}">{{displayName}}</label>
  143. </div>
  144. {{/notifications}}
  145. </div>
  146. </script>
  147. <!-- /.Control Sidebar -->
  148. }