odant-work 1.0.90 → 1.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/#system/package-manifest.json +275 -246
  2. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  3. package/$server/$folder/$class/$data/$catalog/$folder/$class/$data/$catalog/class.js +4 -0
  4. package/$server/$folder/$class/$data/$catalog/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +4 -0
  5. package/$server/$folder/$class/$data/$catalog/$virtual/class.js +8 -0
  6. package/{MODULES/Register/CATALOGS/$catalog/$folder/$class → $server/$folder/$class/$data}/$catalog/class.js +1 -0
  7. package/$server/$folder/$class/$data/$operation/$folder/$class/$data/$operation/class.js +4 -0
  8. package/{MODULES/Register/OPERATIONS/$operation/$folder/$class → $server/$folder/$class/$data}/$operation/class.js +1 -0
  9. package/$server/$folder/$class/$data/$register/$account/$folder/$class/$data/$register/$account/class.js +4 -0
  10. package/$server/$folder/$class/$data/$register/$account/class.js +8 -0
  11. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/$account/class.js +4 -0
  12. package/$server/$folder/$class/$data/$register/$folder/$class/$data/$register/class.js +4 -0
  13. package/$server/$folder/$class/$data/$register/class.js +8 -0
  14. package/$server/$folder/$class/$data/$struct/$folder/$class/$data/$struct/class.js +4 -0
  15. package/$server/$folder/$class/$data/$struct/class.js +5 -0
  16. package/$server/$folder/$class/$data/class.js +5 -0
  17. package/$server/$folder/$class/$data/handlers/pages/form/objects/$handler/class.js +2158 -0
  18. package/$server/$folder/$class/$data/handlers/pages/form/objects/object/$handler/class.js +1377 -0
  19. package/$server/$folder/$class/$domain/$folder/$class/$domain/class.js +4 -0
  20. package/$server/$folder/$class/$domain/handlers/methods/restore/$handler/class.js +5 -5
  21. package/$server/$folder/$class/$domain/readme.md +1 -1
  22. package/$server/$folder/$class/$handler/$method/class.js +4 -0
  23. package/$server/$folder/$class/$handler/$timer/class.js +4 -0
  24. package/$server/$folder/$class/$module/$folder/$class/$data/$catalog/class.js +4 -0
  25. package/$server/$folder/$class/$module/$folder/$class/$data/$operation/class.js +4 -0
  26. package/$server/$folder/$class/$module/$folder/$class/$data/$register/class.js +4 -0
  27. package/$server/$folder/$class/$module/$folder/$class/$data/$struct/class.js +4 -0
  28. package/$server/$folder/$class/$module/$folder/$class/$domain/class.js +4 -0
  29. package/$server/$folder/$class/$module/$folder/$class/$module/class.js +4 -0
  30. package/$server/$folder/$class/$module/class.js +418 -6
  31. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/mcp.js → $module/handlers/pages/form/system/mcp/$handler/class.js} +261 -220
  32. package/$server/$folder/$class/$module/handlers/pages/form/system/modules/$handler/class.js +7 -0
  33. package/$server/$folder/$class/$structure/$folder/$class/$structure/class.js +4 -0
  34. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$catalog/class.js +4 -0
  35. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$operation/class.js +4 -0
  36. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$register/class.js +4 -0
  37. package/$server/$folder/$class/$structure/$organization/$folder/$class/$data/$struct/class.js +4 -0
  38. package/$server/$folder/$class/$structure/$organization/$folder/$class/$domain/class.js +4 -0
  39. package/$server/$folder/$class/$structure/$organization/$folder/$class/$module/class.js +4 -0
  40. package/{ORGANIZATIONS/$domain/$folder/$class/$base → $server/$folder/$class/$structure/$organization/$folder/$class/$structure/$organization}/class.js +4 -5
  41. package/$server/$folder/$class/$structure/$organization/$folder/$class/$structure/class.js +4 -0
  42. package/{ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base → $server/$folder/$class/$structure/$organization}/class.js +19 -17
  43. package/$server/$folder/$class/$structure/$organization/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  44. package/$server/$folder/$class/$structure/{$base/handlers/pages/site/$handler/site.js → $organization/handlers/pages/site/$handler/class.js} +352 -365
  45. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$catalog/class.js +4 -0
  46. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$operation/class.js +4 -0
  47. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$register/class.js +4 -0
  48. package/$server/$folder/$class/$structure/$project/$folder/$class/$data/$struct/class.js +4 -0
  49. package/$server/$folder/$class/$structure/$project/$folder/$class/$domain/class.js +4 -0
  50. package/$server/$folder/$class/$structure/$project/$folder/$class/$module/class.js +4 -0
  51. package/$server/$folder/$class/$structure/$project/class.js +1 -0
  52. package/$server/$folder/$class/$structure/$project/readme.md +1 -1
  53. package/$server/$folder/$class/$structure/$server/$folder/$class/$domain/class.js +4 -0
  54. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/database/$handler/class.js +3 -0
  55. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/license.js → $structure/$server/handlers/pages/form/system/license/$handler/class.js} +104 -103
  56. package/$server/$folder/$class/$structure/$server/handlers/pages/site/$handler/{site.js → class.js} +45 -30
  57. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +3 -0
  58. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +3 -0
  59. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/modules/$handler/class.js +3 -0
  60. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +18 -0
  61. package/$server/$folder/$class/$structure/ai/system.md +1 -1
  62. package/$server/$folder/$class/$structure/class.js +1 -1
  63. package/$server/$folder/$class/$structure/handlers/methods/archive/$handler/class.js +3 -3
  64. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/class.js +309 -8
  65. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +15 -4
  66. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/class.js +1281 -7
  67. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +2216 -6
  68. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/class.js +1304 -6
  69. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/methods/refresh/$method/class.js +1 -1
  70. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/class.js +305 -9
  71. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/agent.js → $structure/handlers/pages/form/system/agent/$handler/class.js} +329 -320
  72. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/database.js → $structure/handlers/pages/form/system/database/$handler/class.js} +510 -577
  73. package/$server/$folder/$class/{handlers/pages/form/system/$handler/tabs/messengers.js → $structure/handlers/pages/form/system/messengers/$handler/class.js} +143 -144
  74. package/$server/$folder/$class/$structure/handlers/pages/form/system/modules/$handler/class.js +270 -0
  75. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +2114 -0
  76. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/class.js +229 -4
  77. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +1 -1
  78. package/$server/$folder/$class/$structure/readme.md +3 -3
  79. package/$server/$folder/$class/$users/$folder/$class/$structure/$user/class.js +4 -0
  80. package/$server/$folder/$class/$users/class.js +4 -0
  81. package/$server/$folder/$class/ai/agents/integrator-1c.md +1 -1
  82. package/$server/$folder/$class/ai/agents/it-admin.md +1 -1
  83. package/$server/$folder/$class/ai/agents/org-architect.md +4 -4
  84. package/$server/$folder/$class/ai/agents/readme.md +1 -1
  85. package/$server/$folder/$class/ai/agents/schema-validator.md +2 -2
  86. package/$server/$folder/$class/ai/skills/lan-inventory.md +2 -2
  87. package/$server/$folder/$class/ai/skills/org-structure.md +1 -1
  88. package/$server/$folder/$class/ai/skills/printer-setup.md +1 -1
  89. package/$server/$folder/$class/ai/skills/telegram-notify.md +2 -2
  90. package/$server/$folder/$class/ai/skills/work-scenarios.md +3 -3
  91. package/$server/$folder/$class/ai/system.md +14 -8
  92. package/$server/$folder/$class/class.js +2 -6
  93. package/$server/$folder/$class/handlers/pages/form/folder/$handler/class.js +3 -0
  94. package/$server/$folder/$class/handlers/pages/form/system/$handler/class.js +2 -4
  95. package/$server/$folder/$class/handlers/pages/form/system/files/$handler/class.js +7 -0
  96. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +100 -0
  97. package/$server/$folder/$class/handlers/pages/storage/$handler/class.js +25 -6
  98. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +32 -5
  99. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +31 -3
  100. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +11 -3
  101. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +83 -3
  102. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +61 -3
  103. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/class.js +1699 -2
  104. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +827 -2
  105. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/readme.md +1 -1
  106. package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +33 -3
  107. package/$server/$folder/$file/handlers/pages/form/folder/$handler/class.js +3 -0
  108. package/$server/$folder/handlers/methods/create/$handler/class.js +5 -5
  109. package/$server/$folder/handlers/pages/form/$handler/class.js +2467 -3
  110. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +22 -0
  111. package/$server/$folder/handlers/readme.md +1 -1
  112. package/$server/$folder/lib/chat-item/chat-item.js +5 -10
  113. package/$server/$folder/lib/consultant/consultant.js +7 -10
  114. package/$server/$folder/lib/explorer/explorer.js +1 -1
  115. package/$server/$folder/lib/icon/icon.js +1 -1
  116. package/$server/$folder/lib/menu/menu.js +3 -2
  117. package/$server/$folder/lib/messenger-settings/messenger-settings.js +4 -4
  118. package/$server/$folder/lib/node/node.js +3 -3
  119. package/$server/$folder/lib/prompt-bar/prompt-bar.js +2 -2
  120. package/$server/$folder/lib/role/role.js +1 -2
  121. package/$server/$folder/lib/security/admin/admin.js +3 -3
  122. package/$server/$folder/lib/security/security.js +4 -4
  123. package/$server/$folder/lib/security/users/users.js +2 -5
  124. package/$server/$folder/lib/site-loc/site-loc.js +3 -3
  125. package/$server/$folder/lib/tree/tree.js +14 -22
  126. package/$server/class.js +1 -0
  127. package/AGENTS.md +21 -13
  128. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-model.js → MODELS/$ai/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js} +385 -425
  129. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-provider.js → MODELS/$ai/$folder/$class/$provider/handlers/pages/form/system/ai/$handler/class.js} +157 -161
  130. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-root.js → MODELS/$ai/handlers/pages/form/system/ai/$handler/class.js} +34 -33
  131. package/{$server/$folder/$class/handlers/pages/form/system/$handler/tabs/ai-local.js → MODELS/Local/$provider/handlers/pages/form/system/ai/$handler/class.js} +572 -622
  132. package/MODULES/$domain/class.js +85 -4
  133. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +7 -0
  134. package/MODULES/$domain/readme.md +7 -6
  135. package/{SERVICES/1C/$service → MODULES/1C/$module}/class.js +7 -1
  136. package/MODULES/2GIS/$module/class.js +32 -0
  137. package/MODULES/2GIS/$module/readme.md +57 -0
  138. package/{SERVICES/Bitrix24/$service → MODULES/Bitrix24/$module}/class.js +7 -2
  139. package/{SERVICES/CBR/$service → MODULES/CBR/$module}/class.js +5 -0
  140. package/{SERVICES/DaData/$service → MODULES/DaData/$module}/class.js +9 -3
  141. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/class.js +648 -21
  142. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/class.js +140 -6
  143. package/{SERVICES/Marketplaces/$service → MODULES/Marketplaces/$domain}/class.js +1 -1
  144. package/{SERVICES/Marketplaces/Ozon/$service → MODULES/Marketplaces/Ozon/$module}/class.js +1 -1
  145. package/{SERVICES/Marketplaces/Wildberries/$service → MODULES/Marketplaces/Wildberries/$module}/class.js +1 -1
  146. package/{SERVICES/Marketplaces/YandexMarket/$service → MODULES/Marketplaces/YandexMarket/$module}/class.js +1 -1
  147. package/MODULES/Process/$module/readme.md +1 -1
  148. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/class.js" +305 -6
  149. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/class.js" +241 -6
  150. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/class.js" +515 -16
  151. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual → $data/$catalog/$virtual}/class.js +3 -0
  152. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/$virtual/handlers/pages/form/objects/$handler/class.js +3 -0
  153. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/handlers/pages/form/virtual/$handler/virtual.js → $data/$catalog/$virtual/handlers/pages/form/virtual/$handler/class.js} +413 -390
  154. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$data/$catalog/class.js +14 -0
  155. package/MODULES/Register/CATALOGS/$catalog/class.js +7 -14
  156. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/$folder/$class/$data/$catalog/$virtual/class.js +9 -0
  157. package/MODULES/Register/CATALOGS//320/241/320/276/321/202/321/200/321/203/320/264/320/275/320/270/320/272/320/270/$virtual/class.js +0 -7
  158. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/$folder/$class/$data/$catalog/class.js +11 -0
  159. package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213/$catalog/class.js +0 -9
  160. package/MODULES/Register/OPERATIONS/$operation/$folder/$class/$data/$operation/class.js +16 -0
  161. package/MODULES/Register/OPERATIONS/$operation/class.js +0 -9
  162. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/$folder/$class/$data/$operation/class.js +8 -0
  163. package/MODULES/Register/OPERATIONS//320/232/320/260/320/264/321/200/321/213/$operation/class.js +4 -10
  164. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/$folder/$class/$data/$operation/class.js +8 -0
  165. package/MODULES/Register/OPERATIONS//320/232/320/260/321/201/321/201/320/260/$operation/class.js +0 -6
  166. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/$folder/$class/$data/$operation/class.js +8 -0
  167. package/MODULES/Register/OPERATIONS//320/232/320/276/320/274/320/274/321/203/320/275/320/270/320/272/320/260/321/206/320/270/320/270/$operation/class.js +4 -10
  168. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  169. package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/class.js" +4 -12
  170. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/$folder/$class/$data/$operation/class.js" +10 -0
  171. package/MODULES/Register/OPERATIONS//320/237/320/276/321/201/321/202/321/203/320/277/320/273/320/265/320/275/320/270/321/217 /320/275/320/260 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/321/213/320/271 /321/201/321/207/321/221/321/202/$operation/class.js" +4 -12
  172. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/$folder/$class/$data/$operation/class.js +24 -0
  173. package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217/$operation/class.js +0 -22
  174. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/analysis/$handler/analysis.js → $data/$register/$account/handlers/pages/form/analysis/$handler/class.js} +9 -4
  175. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/postings/$handler/postings.js → $data/$register/$account/handlers/pages/form/postings/$handler/class.js} +845 -753
  176. package/MODULES/Register/REGISTER/$register/$folder/$class/{$account/handlers/pages/form/turnovers/$handler/turnovers.js → $data/$register/$account/handlers/pages/form/turnovers/$handler/class.js} +9 -4
  177. package/MODULES/Register/REGISTER/$register/{$folder/$class/$register/handlers/pages/form/journal/$handler/journal.js → handlers/pages/form/journal/$handler/class.js} +382 -329
  178. package/MODULES/Register/REGISTER/$register/handlers/pages/form/sheet/$handler/class.js +807 -0
  179. package/MODULES/Register/REGISTER/10/$account/$folder/$class/$data/$register/$account/class.js +21 -0
  180. package/MODULES/Register/REGISTER/10/$account/class.js +0 -19
  181. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/$folder/$class/$data/$register/$account/class.js +14 -0
  182. package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213/$account/class.js +4 -16
  183. package/{SERVICES/SearXNG/$service → MODULES/SearXNG/$module}/class.js +5 -0
  184. package/{SERVICES/Yandex/$service → MODULES/Yandex/$module}/class.js +7 -0
  185. package/{SERVICES/YandexDisk/$service → MODULES/YandexDisk/$module}/class.js +8 -2
  186. package/NODES/$node/handlers/pages/form/network/$handler/class.js +122 -5
  187. package/ORGANIZATIONS/$domain/$folder/$class/$structure/$organization/class.js +5 -0
  188. package/ORGANIZATIONS/$domain/class.js +5 -5
  189. package/oda/components/inputs/link/link.js +1 -1
  190. package/package.json +1 -1
  191. package/readme.md +6 -7
  192. package/scripts/check-architecture.mjs +541 -0
  193. package/scripts/cleanup-storage.mjs +1 -1
  194. package/scripts/demo-seed.mjs +3 -3
  195. package/scripts/import-bis.mjs +33 -15
  196. package/scripts/import-delovaya.mjs +26 -14
  197. package/sources/client/class.js +19 -10
  198. package/sources/client/folder.js +10 -22
  199. package/sources/client/handler.js +75 -33
  200. package/sources/data/api.js +9 -10
  201. package/sources/data/classes.js +85 -9
  202. package/sources/data/db.js +10 -6
  203. package/sources/data/print.js +15 -41
  204. package/sources/data/readme.md +5 -5
  205. package/sources/data/schema.js +206 -118
  206. package/sources/data/sql-inspector.js +7 -7
  207. package/sources/host/auth-methods.js +2 -5
  208. package/sources/host/auto-updater.js +1 -2
  209. package/sources/host/babel-merge.js +174 -129
  210. package/sources/host/prewarm.js +1 -1
  211. package/sources/host/watch.js +1 -1
  212. package/sources/index.html +1 -1
  213. package/sources/modules/agent/extensions.js +48 -38
  214. package/sources/modules/agent/index.js +1 -1
  215. package/sources/modules/agent/node-rules.js +69 -41
  216. package/sources/modules/agent/permissions.js +1 -1
  217. package/sources/modules/agent/plugins.js +11 -11
  218. package/sources/modules/agent/resources.js +96 -52
  219. package/sources/modules/agent/tools/net.js +1 -1
  220. package/sources/modules/agent/tools/services.js +7 -7
  221. package/sources/modules/agent/tools/work/access.js +10 -8
  222. package/sources/modules/agent/tools/work/classes.js +26 -47
  223. package/sources/modules/agent/tools/work/common.js +8 -10
  224. package/sources/modules/agent/tools/work/data.js +4 -4
  225. package/sources/modules/agent/triggers.js +1 -1
  226. package/sources/modules/agent/twin-bus.js +4 -4
  227. package/sources/modules/agent/voice.js +1 -1
  228. package/sources/modules/call/call.js +4 -4
  229. package/sources/modules/kladr/index.js +3 -3
  230. package/sources/modules/lan/register.js +7 -7
  231. package/sources/modules/mcp-marketplaces/ozon.js +1 -1
  232. package/sources/modules/mcp-marketplaces/wildberries.js +1 -1
  233. package/sources/modules/mcp-marketplaces/yandex-market.js +1 -1
  234. package/sources/modules/nodes/mount.js +2 -4
  235. package/sources/modules/notify/index.js +18 -18
  236. package/sources/modules/rag/extract.js +9 -2
  237. package/sources/modules/rag/indexer.js +1 -1
  238. package/sources/modules/rag/scope.js +7 -33
  239. package/sources/modules/trainer/dataset.js +2 -2
  240. package/sources/modules/trainer/local-engine.js +1 -1
  241. package/sources/page.html +2 -2
  242. package/sources/readme.md +1 -1
  243. package/sources/server/access/gateway.js +19 -19
  244. package/sources/server/access/invites.js +4 -5
  245. package/sources/server/access/links.js +10 -8
  246. package/sources/server/access/policy.js +65 -39
  247. package/sources/server/access/workplaces.js +20 -14
  248. package/sources/server/chat-threads.js +4 -4
  249. package/sources/server/class/archive.js +15 -15
  250. package/sources/server/class/base-template.js +13 -9
  251. package/sources/server/class/distro.js +3 -4
  252. package/sources/server/class/feed.js +3 -3
  253. package/sources/server/class/mail-calendar.js +9 -8
  254. package/sources/server/class/scaffold.js +110 -60
  255. package/sources/server/class/search.js +2 -2
  256. package/sources/server/class/security.js +76 -94
  257. package/sources/server/class.js +181 -64
  258. package/sources/server/file.js +2 -2
  259. package/sources/server/folder.js +376 -191
  260. package/sources/server/handler.js +52 -13
  261. package/sources/server/logs.js +7 -7
  262. package/sources/server/node.js +12 -43
  263. package/sources/server/server.js +16 -17
  264. package/$server/$folder/$class/$device/class.js +0 -3
  265. package/$server/$folder/$class/$handler/$task/class.js +0 -3
  266. package/$server/$folder/$class/$service/$class/$service/class.js +0 -4
  267. package/$server/$folder/$class/$structure/$base/class.js +0 -10
  268. package/$server/$folder/$class/$structure/$base/roots_1/roots.test +0 -0
  269. package/$server/$folder/$class/$structure/handlers/pages/data/$handler/data.js +0 -313
  270. package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/explorer.js +0 -16
  271. package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/calendar.js +0 -1226
  272. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/chat.js +0 -2217
  273. package/$server/$folder/$class/$structure/handlers/pages/form/email/$handler/email.js +0 -1188
  274. package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +0 -289
  275. package/$server/$folder/$class/$structure/handlers/pages/site/$handler/site.js +0 -240
  276. package/$server/$folder/$class/handlers/pages/form/object/$handler/class.js +0 -33
  277. package/$server/$folder/$class/handlers/pages/form/object/$handler/object.js +0 -1371
  278. package/$server/$folder/$class/handlers/pages/form/objects/$handler/class.js +0 -33
  279. package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +0 -2130
  280. package/$server/$folder/$class/handlers/pages/form/system/$handler/system.js +0 -384
  281. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/modules.js +0 -244
  282. package/$server/$folder/$class/handlers/pages/form/system/$handler/tabs/staff.js +0 -2126
  283. package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +0 -21
  284. package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +0 -27
  285. package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +0 -31
  286. package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +0 -10
  287. package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/file.js +0 -72
  288. package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +0 -63
  289. package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +0 -1845
  290. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/file.js +0 -785
  291. package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +0 -29
  292. package/$server/$folder/handlers/pages/form/$handler/form.js +0 -2122
  293. package/MODULES/Geo//320/232/320/260/321/200/321/202/320/260/$catalog/handlers/pages/form/map/$handler/map.js +0 -623
  294. package/MODULES/KLADR/$module/handlers/pages/form/kladr/$handler/kladr.js +0 -134
  295. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/gantt/$handler/gantt.js" +0 -293
  296. package/MODULES/Process//320/227/320/260/320/264/320/260/321/207/320/270 /320/270 /321/215/321/202/320/260/320/277/321/213/$catalog/handlers/pages/form/scheduler/$handler/scheduler.js" +0 -234
  297. package/MODULES/Process//320/241/321/205/320/265/320/274/321/213 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/320/276/320/262/$catalog/handlers/pages/form/bpmn/$handler/bpmn.js" +0 -406
  298. package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/handlers/pages/form/virtual/$handler/class.js +0 -6
  299. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/analysis/$handler/class.js +0 -9
  300. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/postings/$handler/class.js +0 -9
  301. package/MODULES/Register/REGISTER/$register/$folder/$class/$account/handlers/pages/form/turnovers/$handler/class.js +0 -9
  302. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/journal/$handler/class.js +0 -6
  303. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/class.js +0 -6
  304. package/MODULES/Register/REGISTER/$register/$folder/$class/$register/handlers/pages/form/sheet/$handler/sheet.js +0 -808
  305. package/NODES/$node/handlers/pages/form/network/$handler/network.js +0 -110
  306. package/SERVICES/$service/$folder/$storage/$service/class.js +0 -8
  307. package/SERVICES/$service/class.js +0 -442
  308. package/SERVICES/readme.md +0 -36
  309. /package/$server/$folder/$class/$structure/{$base → $organization}/icon.png +0 -0
  310. /package/{SERVICES/DuckDuckGo/$service → MODULES/DuckDuckGo/$module}/class.js +0 -0
  311. /package/MODULES/KLADR/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  312. /package/MODULES/Process/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  313. /package/MODULES/Register/$module/$folder/$class/{$catalog → $data/$catalog}/class.js +0 -0
  314. /package/MODULES/Register/$module/$folder/$class/{$operation → $data/$operation}/class.js +0 -0
  315. /package/MODULES/Register/$module/$folder/$class/{$register → $data/$register}/class.js +0 -0
  316. /package/MODULES/Register/$module/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  317. /package/MODULES/Register/CATALOGS/$catalog/$folder/$class/{$virtual/$folder/$class → $data/$catalog/$virtual/$folder/$class/$data/$catalog}/$virtual/class.js +0 -0
  318. /package/MODULES/Register/OPERATIONS//320/237/320/273/320/260/321/202/320/265/320/266/320/270 /321/201 /321/200/320/260/321/201/321/207/321/221/321/202/320/275/320/276/320/263/320/276 /321/201/321/207/321/221/321/202/320/260/$operation/{print → $folder/$class/$data/$operation/print}//320/237/320/273/320/260/321/202/321/221/320/266/320/275/320/276/320/265 /320/277/320/276/321/200/321/203/321/207/320/265/320/275/320/270/320/265.html" +0 -0
  319. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/class.js +0 -0
  320. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$account → $data/$register/$account}/readme.md +0 -0
  321. /package/MODULES/Register/REGISTER/$register/$folder/$class/{$register → $data/$register}/class.js +0 -0
  322. /package/MODULES/Register/STRUCTS/$struct/$folder/$class/{$struct → $data/$struct}/class.js +0 -0
  323. /package/{SERVICES/RuCalendar/$service → MODULES/RuCalendar/$module}/class.js +0 -0
  324. /package/{SERVICES/Telegram/$service → MODULES/Telegram/$module}/class.js +0 -0
  325. /package/{SERVICES/Weather/$service → MODULES/Weather/$module}/class.js +0 -0
  326. /package/PROJECTS/$domain/$folder/$class/{$project → $structure/$project}/class.js +0 -0
@@ -1,1188 +0,0 @@
1
- const EMPTY_DRAFT = () => ({ uid: '', origTime: 0, from: '', to: '', cc: '', subject: '', body: '', inReplyTo: '', attachments: [] });
2
-
3
- function parseJson(value) {
4
- if (value && typeof value === 'object') return value;
5
- if (typeof value !== 'string' || !value) return null;
6
- try {
7
- const parsed = JSON.parse(value);
8
- return parsed && typeof parsed === 'object' ? parsed : null;
9
- }
10
- catch {
11
- return null;
12
- }
13
- }
14
-
15
- function formatMailShortDate(value) {
16
- if (!value) return '';
17
- const d = new Date(value);
18
- if (isNaN(d.getTime())) return String(value);
19
- const now = new Date();
20
- const sameDay = d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate();
21
- if (sameDay)
22
- return d.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' });
23
- return d.toLocaleDateString('ru-RU', { day: '2-digit', month: '2-digit' });
24
- }
25
-
26
- function formatMailFullDate(value) {
27
- if (!value) return '';
28
- const d = new Date(value);
29
- if (isNaN(d.getTime())) return String(value);
30
- return d.toLocaleString('ru-RU', {
31
- day: '2-digit', month: 'short', year: 'numeric',
32
- hour: '2-digit', minute: '2-digit',
33
- });
34
- }
35
-
36
- function htmlToText(html) {
37
- try {
38
- return new DOMParser().parseFromString(html, 'text/html').body?.textContent || '';
39
- }
40
- catch {
41
- return '';
42
- }
43
- }
44
-
45
- function quoteBody(msg) {
46
- const text = msg.body || htmlToText(msg.html || '');
47
- const quoted = String(text).split(/\r?\n/).map(line => '> ' + line).join('\n');
48
- return `\n\n${formatMailFullDate(msg.date)}, ${msg.from || ''} пишет:\n${quoted}`;
49
- }
50
-
51
- function htmlDocument(html) {
52
- return '<!doctype html><html><head><meta charset="utf-8"><base target="_blank">'
53
- + '<style>body{margin:0;padding:8px;font-family:sans-serif;font-size:13.5px;line-height:1.45;word-wrap:break-word;}img{max-width:100%;height:auto;}</style>'
54
- + '</head><body>' + String(html || '') + '</body></html>';
55
- }
56
-
57
- function mailboxesToAccounts(mailboxes = {}) {
58
- return Object.entries(mailboxes).map(([address, box]) => ({
59
- address,
60
- smtp: { host: '', port: 465, secure: true, ...box.smtp },
61
- imap: { host: '', port: 993, secure: true, ...box.imap },
62
- auth: { user: address, pass: '', ...box.auth },
63
- }));
64
- }
65
-
66
- function accountsToMailboxes(accounts = [], previousMailboxes = {}) {
67
- const mailboxes = Object.create(null);
68
- for (const acc of accounts) {
69
- const address = String(acc.auth?.user || '').trim();
70
- if (!address) continue;
71
- const prev = previousMailboxes?.[address] || {};
72
- mailboxes[address] = {
73
- ...prev,
74
- smtp: { host: acc.smtp?.host || '', port: Number(acc.smtp?.port) || 465, secure: acc.smtp?.secure !== false },
75
- imap: { host: acc.imap?.host || '', port: Number(acc.imap?.port) || 993, secure: acc.imap?.secure !== false },
76
- auth: { user: address, pass: acc.auth?.pass || '' },
77
- };
78
- }
79
- return mailboxes;
80
- }
81
-
82
- async function openEmailSettingsDialog($context) {
83
- if (openEmailSettingsDialog.opening || !$context) return null;
84
- openEmailSettingsDialog.opening = true;
85
- let el, settings;
86
- try {
87
- settings = await $context.fetch('read_secret', { filename: 'email.json' });
88
- el = ODA.createElement('oda-email-settings', {
89
- accounts: mailboxesToAccounts(settings?.mailboxes),
90
- });
91
- if (!el.accounts.length) el.addAccount();
92
- else el.index = 0;
93
- }
94
- catch (e) {
95
- ODA.showMessage?.(e.message || String(e));
96
- return null;
97
- }
98
- finally {
99
- openEmailSettingsDialog.opening = false;
100
- }
101
- try {
102
- await WORK.showDialog(el, {
103
- TITLE: { label: 'Почтовые ящики', icon: 'enterprise:email' },
104
- OK: { label: 'Сохранить', icon: 'icons:save' },
105
- CANCEL: { label: 'Отмена', icon: 'icons:close' },
106
- });
107
- }
108
- catch {
109
- return null;
110
- }
111
- try {
112
- el.validate();
113
- const mailboxes = accountsToMailboxes(el.accounts, settings?.mailboxes);
114
- await $context.fetch('save_secret', { filename: 'email.json' }, JSON.stringify({ mailboxes }));
115
- return mailboxes;
116
- }
117
- catch (e) {
118
- ODA.showMessage?.(e.message || String(e));
119
- return null;
120
- }
121
- }
122
-
123
- ODA({
124
- is: 'oda-email-settings',
125
- imports: 'oda//button, oda//checkbox, oda//icon',
126
- template: /* html */ `
127
- <style>
128
- :host {
129
- @apply --horizontal;
130
- @apply --flex;
131
- width: min(680px, calc(100vw - 24px));
132
- max-width: 100%;
133
- min-height: min(320px, 50dvh);
134
- box-sizing: border-box;
135
- overflow: hidden;
136
- }
137
- .accounts {
138
- width: 220px;
139
- min-width: 170px;
140
- flex-shrink: 0;
141
- @apply --light;
142
- border-right: 1px solid var(--subtle-border);
143
- overflow-y: auto;
144
- }
145
- @media (max-width: 640px) {
146
- :host {
147
- flex-direction: column;
148
- }
149
- .accounts {
150
- width: 100%;
151
- min-width: 0;
152
- border-right: none;
153
- border-bottom: 1px solid var(--subtle-border);
154
- max-height: 32dvh;
155
- }
156
- }
157
- .accounts-toolbar {
158
- padding: 6px var(--space-m);
159
- gap: var(--space-s);
160
- @apply --header;
161
- align-items: center;
162
- }
163
- .account-item {
164
- padding: 10px var(--space-m) 10px 12px;
165
- cursor: pointer;
166
- border-bottom: 1px solid var(--subtle-border);
167
- }
168
- .account-item:not([info-invert]):hover { @apply --hover; }
169
- .account-title {
170
- font-weight: 500;
171
- overflow: hidden;
172
- text-overflow: ellipsis;
173
- white-space: nowrap;
174
- }
175
- .account-sub { font-size: x-small; @apply --muted; }
176
- [info-invert] .account-sub { color: inherit; fill: inherit; opacity: .75; }
177
- .editor {
178
- padding: 12px var(--space-l);
179
- gap: var(--space-m);
180
- overflow: auto;
181
- }
182
- fieldset {
183
- border: 1px solid var(--subtle-border);
184
- border-radius: var(--radius-s);
185
- padding: var(--space-s) var(--space-m);
186
- margin: 0;
187
- }
188
- legend { font-size: x-small; padding: 0 var(--space-s); }
189
- input {
190
- border: none;
191
- outline: none;
192
- background: transparent;
193
- color: inherit;
194
- width: 100%;
195
- padding: var(--space-s) 0;
196
- box-sizing: border-box;
197
- font: inherit;
198
- }
199
- .row { gap: 12px; align-items: center; }
200
- .port { max-width: 72px; }
201
- .empty { padding: var(--space-l); @apply --muted; }
202
- </style>
203
- <div class="accounts" vertical>
204
- <div class="accounts-toolbar" horizontal>
205
- <span flex>Ящики</span>
206
- <oda-button icon="icons:add" @tap="addAccount" title="Добавить ящик"></oda-button>
207
- <oda-button icon="icons:delete" :disabled="!current" @tap="removeAccount" title="Удалить ящик"></oda-button>
208
- </div>
209
- <div class="account-item" ~for="accounts"
210
- :info-invert="index === $for.index"
211
- @tap="index = $for.index">
212
- <div class="account-title">{{$for.item.auth.user || 'Новый ящик'}}</div>
213
- <div class="account-sub">{{$for.item.smtp.host || 'SMTP не задан'}}</div>
214
- </div>
215
- <div ~if="!accounts.length" class="empty">Нажмите «+» чтобы добавить ящик</div>
216
- </div>
217
- <div class="editor" vertical flex ~if="current">
218
- <fieldset>
219
- <legend>Учётная запись</legend>
220
- <input placeholder="user@example.com" ::value="current.auth.user">
221
- <input type="password" placeholder="Пароль или пароль приложения" ::value="current.auth.pass">
222
- </fieldset>
223
- <fieldset>
224
- <legend>Исходящая почта (SMTP)</legend>
225
- <div class="row" horizontal>
226
- <input flex placeholder="smtp.yandex.ru" ::value="current.smtp.host">
227
- <input class="port" type="number" placeholder="465" ::value="current.smtp.port">
228
- <oda-checkbox ::value="current.smtp.secure"></oda-checkbox><span>TLS</span>
229
- </div>
230
- </fieldset>
231
- <fieldset>
232
- <legend>Входящая почта (IMAP)</legend>
233
- <div class="row" horizontal>
234
- <input flex placeholder="imap.yandex.ru" ::value="current.imap.host">
235
- <input class="port" type="number" placeholder="993" ::value="current.imap.port">
236
- <oda-checkbox ::value="current.imap.secure"></oda-checkbox><span>TLS</span>
237
- </div>
238
- </fieldset>
239
- </div>
240
- <div ~if="!current" class="empty" flex>Выберите или добавьте ящик</div>
241
- `,
242
- accounts: [],
243
- index: -1,
244
- get current() { return this.accounts[this.index] ?? null; },
245
- addAccount() {
246
- this.accounts = [...this.accounts, {
247
- address: '',
248
- smtp: { host: '', port: 465, secure: true },
249
- imap: { host: '', port: 993, secure: true },
250
- auth: { user: '', pass: '' },
251
- }];
252
- this.index = this.accounts.length - 1;
253
- },
254
- removeAccount() {
255
- if (this.index < 0) return;
256
- const next = [...this.accounts];
257
- next.splice(this.index, 1);
258
- this.accounts = next;
259
- this.index = next.length ? Math.min(this.index, next.length - 1) : -1;
260
- },
261
- validate() {
262
- const seen = new Set();
263
- for (const acc of this.accounts) {
264
- const addr = String(acc.auth?.user || '').trim();
265
- if (!addr) throw new Error('Укажите адрес (логин) для каждого ящика');
266
- if (seen.has(addr)) throw new Error('Повторяющийся ящик: ' + addr);
267
- seen.add(addr);
268
- }
269
- },
270
- });
271
-
272
- export default {
273
- icon: 'enterprise:email',
274
- imports: 'oda//button, oda//icon',
275
- template: /* html */`
276
- <style>
277
- :host {
278
- @apply --horizontal;
279
- @apply --flex;
280
- overflow: hidden;
281
- background: var(--content-background, #ffffff);
282
- color: var(--content-color, #1e293b);
283
- font-size: 13px;
284
- }
285
- .mail-sidebar {
286
- @apply --vertical;
287
- width: 212px;
288
- flex-shrink: 0;
289
- padding: 12px 10px;
290
- gap: 6px;
291
- border-right: 1px solid var(--subtle-border, #e2e8f0);
292
- background: var(--subtle-background, #f8fafc);
293
- overflow-y: auto;
294
- }
295
- .compose-btn {
296
- @apply --horizontal;
297
- align-items: center;
298
- justify-content: center;
299
- gap: 7px;
300
- padding: 9px 14px;
301
- border-radius: 9px;
302
- border: none;
303
- background: var(--accent-color, #2563eb);
304
- color: var(--accent-back, #ffffff);
305
- font: inherit;
306
- font-size: 13.5px;
307
- font-weight: 600;
308
- cursor: pointer;
309
- margin-bottom: 6px;
310
- box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
311
- }
312
- .compose-btn:hover { filter: brightness(1.06); }
313
- .nav-btn {
314
- @apply --horizontal;
315
- align-items: center;
316
- gap: 9px;
317
- width: 100%;
318
- padding: 8px 11px;
319
- border-radius: 8px;
320
- border: 1px solid transparent;
321
- background: transparent;
322
- color: inherit;
323
- font: inherit;
324
- font-size: 13.5px;
325
- font-weight: 500;
326
- text-align: left;
327
- cursor: pointer;
328
- user-select: none;
329
- }
330
- .nav-btn:hover {
331
- background: color-mix(in srgb, var(--accent-color, #2563eb) 6%, transparent);
332
- }
333
- .nav-btn.active {
334
- background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
335
- border-color: color-mix(in srgb, var(--accent-color, #2563eb) 50%, transparent);
336
- color: var(--accent-color, #2563eb);
337
- font-weight: 600;
338
- }
339
- .nav-badge {
340
- margin-left: auto;
341
- padding: 1px 7px;
342
- border-radius: 999px;
343
- font-size: 11px;
344
- font-weight: 700;
345
- background: var(--accent-color, #2563eb);
346
- color: #ffffff;
347
- }
348
- .nav-count {
349
- margin-left: auto;
350
- font-size: 11.5px;
351
- color: var(--muted-color, #64748b);
352
- }
353
- .side-sep {
354
- height: 1px;
355
- margin: 4px 6px;
356
- background: var(--subtle-border, #e2e8f0);
357
- }
358
- .side-label {
359
- padding: 2px 10px;
360
- font-size: 11px;
361
- font-weight: 700;
362
- text-transform: uppercase;
363
- letter-spacing: 0.04em;
364
- color: var(--muted-color, #64748b);
365
- }
366
- .acc-pill {
367
- font-size: 12.5px;
368
- padding: 6px 10px;
369
- overflow: hidden;
370
- text-overflow: ellipsis;
371
- white-space: nowrap;
372
- }
373
- .mail-list-pane {
374
- @apply --vertical;
375
- width: 335px;
376
- min-width: 260px;
377
- flex-shrink: 0;
378
- border-right: 1px solid var(--subtle-border, #e2e8f0);
379
- background: var(--content-background, #ffffff);
380
- overflow: hidden;
381
- }
382
- .list-toolbar {
383
- @apply --horizontal;
384
- align-items: center;
385
- gap: 6px;
386
- padding: 10px 10px 8px;
387
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
388
- background: var(--content-background, #ffffff);
389
- }
390
- .search-input {
391
- @apply --flex;
392
- min-width: 0;
393
- padding: 6px 10px;
394
- border-radius: 7px;
395
- border: 1px solid var(--subtle-border, #cbd5e1);
396
- background: var(--subtle-background, #f8fafc);
397
- color: inherit;
398
- font: inherit;
399
- font-size: 12.5px;
400
- outline: none;
401
- }
402
- .search-input:focus {
403
- border-color: var(--accent-color, #2563eb);
404
- background: var(--content-background, #ffffff);
405
- }
406
- .icon-btn {
407
- @apply --horizontal;
408
- align-items: center;
409
- justify-content: center;
410
- padding: 6px 8px;
411
- border-radius: 7px;
412
- border: 1px solid var(--subtle-border, #cbd5e1);
413
- background: var(--content-background, #ffffff);
414
- color: inherit;
415
- cursor: pointer;
416
- font-size: 12px;
417
- }
418
- .icon-btn:hover { background: var(--accent-soft); }
419
- .icon-btn.active {
420
- border-color: var(--accent-color, #2563eb);
421
- color: var(--accent-color, #2563eb);
422
- background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
423
- font-weight: 600;
424
- }
425
- .msg-scroll {
426
- @apply --vertical;
427
- @apply --flex;
428
- overflow-y: auto;
429
- }
430
- .msg-row {
431
- display: flex;
432
- flex-direction: column;
433
- gap: 3px;
434
- padding: 10px 12px;
435
- border-bottom: 1px solid var(--subtle-border, #f1f5f9);
436
- cursor: pointer;
437
- position: relative;
438
- transition: background 0.1s ease;
439
- }
440
- .msg-row:hover {
441
- background: var(--subtle-background, #f8fafc);
442
- }
443
- .msg-row.selected {
444
- background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, var(--content-background, #ffffff));
445
- border-left: 3px solid var(--accent-color, #2563eb);
446
- padding-left: 9px;
447
- }
448
- .msg-row.unread .msg-peer,
449
- .msg-row.unread .msg-subj {
450
- font-weight: 700;
451
- }
452
- .msg-top {
453
- display: flex;
454
- align-items: center;
455
- gap: 6px;
456
- min-width: 0;
457
- }
458
- .unread-dot {
459
- width: 7px;
460
- height: 7px;
461
- border-radius: 50%;
462
- background: var(--accent-color, #2563eb);
463
- flex-shrink: 0;
464
- }
465
- .msg-peer {
466
- flex: 1;
467
- min-width: 0;
468
- overflow: hidden;
469
- text-overflow: ellipsis;
470
- white-space: nowrap;
471
- font-size: 13px;
472
- font-weight: 500;
473
- }
474
- .msg-time {
475
- font-size: 11px;
476
- color: var(--muted-color, #64748b);
477
- white-space: nowrap;
478
- }
479
- .msg-subj {
480
- font-size: 12.5px;
481
- overflow: hidden;
482
- text-overflow: ellipsis;
483
- white-space: nowrap;
484
- display: flex;
485
- align-items: center;
486
- gap: 5px;
487
- }
488
- .msg-snip {
489
- font-size: 11.5px;
490
- color: var(--muted-color, #64748b);
491
- overflow: hidden;
492
- text-overflow: ellipsis;
493
- white-space: nowrap;
494
- }
495
- .status-tag {
496
- font-size: 10.5px;
497
- padding: 1px 6px;
498
- border-radius: 999px;
499
- background: var(--subtle-background, #f1f5f9);
500
- color: var(--muted-color, #64748b);
501
- }
502
- .status-tag.err { background: #fef2f2; color: #dc2626; }
503
- .status-tag.draft { background: #fffbeb; color: #b45309; }
504
- .mail-view-pane {
505
- @apply --vertical;
506
- @apply --flex;
507
- min-width: 0;
508
- overflow: hidden;
509
- background: var(--content-background, #ffffff);
510
- }
511
- .empty-pane {
512
- @apply --vertical;
513
- @apply --flex;
514
- align-items: center;
515
- justify-content: center;
516
- gap: 10px;
517
- color: var(--muted-color, #64748b);
518
- padding: 24px;
519
- text-align: center;
520
- }
521
- .view-actions {
522
- @apply --horizontal;
523
- align-items: center;
524
- gap: 6px;
525
- padding: 10px 16px;
526
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
527
- background: var(--subtle-background, #f8fafc);
528
- flex-wrap: wrap;
529
- }
530
- .view-head {
531
- @apply --vertical;
532
- gap: 4px;
533
- padding: 14px 18px 10px;
534
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
535
- }
536
- .view-subject {
537
- font-size: 17px;
538
- font-weight: 700;
539
- }
540
- .view-meta {
541
- font-size: 12.5px;
542
- color: var(--muted-color, #475569);
543
- }
544
- .att-bar {
545
- display: flex;
546
- flex-wrap: wrap;
547
- gap: 6px;
548
- padding: 8px 18px;
549
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
550
- background: var(--subtle-background, #f8fafc);
551
- }
552
- .att-chip {
553
- @apply --horizontal;
554
- align-items: center;
555
- gap: 5px;
556
- padding: 4px 10px;
557
- border-radius: 6px;
558
- border: 1px solid var(--subtle-border, #cbd5e1);
559
- background: var(--content-background, #ffffff);
560
- font-size: 12px;
561
- cursor: pointer;
562
- }
563
- .view-body {
564
- @apply --flex;
565
- overflow: auto;
566
- padding: 16px 18px;
567
- white-space: pre-wrap;
568
- line-height: 1.5;
569
- user-select: text;
570
- }
571
- .view-iframe {
572
- @apply --flex;
573
- width: 100%;
574
- border: none;
575
- background: #ffffff;
576
- }
577
- .compose-wrap {
578
- @apply --vertical;
579
- @apply --flex;
580
- padding: 14px 18px;
581
- gap: 10px;
582
- overflow-y: auto;
583
- }
584
- .compose-field {
585
- display: flex;
586
- align-items: center;
587
- gap: 8px;
588
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
589
- padding: 4px 0;
590
- }
591
- .compose-field label {
592
- width: 68px;
593
- font-size: 12.5px;
594
- color: var(--muted-color, #64748b);
595
- flex-shrink: 0;
596
- }
597
- .compose-field input,
598
- .compose-field select {
599
- flex: 1;
600
- border: none;
601
- outline: none;
602
- background: transparent;
603
- color: inherit;
604
- font: inherit;
605
- padding: 4px 0;
606
- }
607
- .compose-body {
608
- @apply --flex;
609
- min-height: 180px;
610
- border: 1px solid var(--subtle-border, #e2e8f0);
611
- border-radius: 8px;
612
- padding: 10px 12px;
613
- outline: none;
614
- background: var(--content-background, #ffffff);
615
- color: inherit;
616
- font: inherit;
617
- line-height: 1.5;
618
- resize: none;
619
- }
620
- .compose-footer {
621
- @apply --horizontal;
622
- align-items: center;
623
- flex-wrap: wrap;
624
- gap: 8px;
625
- padding-top: 4px;
626
- }
627
- .mail-back-btn {
628
- display: none;
629
- }
630
- @media (max-width: 960px) {
631
- .mail-sidebar {
632
- width: 176px;
633
- }
634
- .mail-list-pane {
635
- width: 270px;
636
- min-width: 210px;
637
- }
638
- }
639
- @media (max-width: 768px) {
640
- :host {
641
- flex-direction: column;
642
- }
643
- .mail-sidebar {
644
- width: 100%;
645
- flex-direction: row;
646
- align-items: center;
647
- overflow-x: auto;
648
- overflow-y: hidden;
649
- border-right: none;
650
- border-bottom: 1px solid var(--subtle-border, #e2e8f0);
651
- padding: 6px 8px;
652
- gap: 6px;
653
- box-sizing: border-box;
654
- }
655
- .compose-btn {
656
- margin-bottom: 0;
657
- padding: 7px 11px;
658
- white-space: nowrap;
659
- flex-shrink: 0;
660
- }
661
- .nav-btn {
662
- width: auto;
663
- white-space: nowrap;
664
- flex-shrink: 0;
665
- padding: 6px 10px;
666
- }
667
- .side-sep, .side-label, .mail-side-spacer {
668
- display: none;
669
- }
670
- .mail-list-pane {
671
- width: 100%;
672
- min-width: 0;
673
- flex: 1 1 auto;
674
- border-right: none;
675
- }
676
- .mail-list-pane.mobile-hidden {
677
- display: none;
678
- }
679
- .mail-view-pane {
680
- width: 100%;
681
- flex: 1 1 auto;
682
- min-height: 0;
683
- }
684
- .mail-view-pane.mobile-hidden {
685
- display: none;
686
- }
687
- .mail-back-btn {
688
- display: inline-flex;
689
- }
690
- .view-head, .view-body, .compose-wrap {
691
- padding-left: 12px;
692
- padding-right: 12px;
693
- }
694
- }
695
- </style>
696
-
697
- <aside class="mail-sidebar">
698
- <button type="button" class="compose-btn" @tap="createEmail()">
699
- <oda-icon icon="icons:add" icon-size="16"></oda-icon>
700
- <span>Написать</span>
701
- </button>
702
-
703
- <button type="button" class="nav-btn" ~for="folders"
704
- ~class="{ active: activeBox === $for.item.id }"
705
- @tap="selectBox($for.item.id)">
706
- <oda-icon :icon="$for.item.icon" icon-size="16"></oda-icon>
707
- <span>{{$for.item.label}}</span>
708
- <span ~if="badgeOf($for.item.id) > 0" class="nav-badge">{{badgeOf($for.item.id)}}</span>
709
- <span ~if="badgeOf($for.item.id) === 0 && countOf($for.item.id) > 0" class="nav-count">{{countOf($for.item.id)}}</span>
710
- </button>
711
-
712
- <div class="side-sep" ~if="accounts.length"></div>
713
- <div class="side-label" ~if="accounts.length">Ящики</div>
714
- <button type="button" class="nav-btn acc-pill" ~if="accounts.length > 1"
715
- ~class="{ active: !selectedAccount }"
716
- @tap="selectAccount('')">Все ящики</button>
717
- <button type="button" class="nav-btn acc-pill" ~for="accounts"
718
- ~class="{ active: selectedAccount === $for.item.address }"
719
- @tap="selectAccount($for.item.address)"
720
- :title="$for.item.address">
721
- <span>{{$for.item.address}}</span>
722
- </button>
723
-
724
- <div class="mail-side-spacer" style="flex: 1;"></div>
725
- <div class="side-sep" ~if="canConfigure"></div>
726
- <label ~if="canConfigure && accounts.length" style="display:flex;align-items:center;gap:6px;padding:4px 8px;font-size:12px;cursor:pointer;white-space:nowrap;flex-shrink:0;">
727
- <input type="checkbox" :checked="autoRefresh" @change="toggleAutoRefresh($event.target.checked)">
728
- <span>Автопроверка почты</span>
729
- </label>
730
- <button type="button" class="nav-btn" ~if="canConfigure" @tap="openSettings()">
731
- <oda-icon icon="icons:settings" icon-size="16"></oda-icon>
732
- <span>Настройка ящиков</span>
733
- </button>
734
- </aside>
735
-
736
- <section class="mail-list-pane" ~class="{ 'mobile-hidden': mode !== 'idle' }">
737
- <div class="list-toolbar">
738
- <input class="search-input" type="search" placeholder="Поиск писем…" :value="searchQuery" @input="onSearchInput($event)">
739
- <button type="button" class="icon-btn" ~class="{ active: unreadOnly }" @tap="toggleUnreadOnly()" title="Только непрочитанные">●</button>
740
- <button type="button" class="icon-btn" @tap="fetchRefresh()" :disabled="refreshing" title="Проверить почту с сервера">
741
- <oda-icon :icon="refreshing ? 'spinners:8-dots-rotate' : 'icons:refresh'" icon-size="15"></oda-icon>
742
- </button>
743
- </div>
744
-
745
- <div class="msg-scroll">
746
- <div ~if="loading && !messages.length" class="empty-pane">Загрузка писем…</div>
747
- <div ~if="!loading && !messages.length" class="empty-pane">
748
- <span>В папке «{{activeBoxLabel}}» писем нет</span>
749
- </div>
750
- <div ~for="messages" class="msg-row"
751
- ~class="{ selected: selected?.path === $for.item.path, unread: !$for.item.read }"
752
- @tap="selectMessage($for.item)">
753
- <div class="msg-top">
754
- <span ~if="!$for.item.read" class="unread-dot"></span>
755
- <span class="msg-peer">{{peerLabel($for.item)}}</span>
756
- <span class="msg-time">{{shortDate($for.item.date || $for.item.sortTime)}}</span>
757
- </div>
758
- <div class="msg-subj">
759
- <span style="flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">{{$for.item.subject || '(без темы)'}}</span>
760
- <oda-icon ~if="$for.item.attachmentsCount > 0" icon="editor:attach-file" icon-size="13"></oda-icon>
761
- <span ~if="$for.item.status === 'failed'" class="status-tag err">ошибка</span>
762
- <span ~if="$for.item.status === 'draft'" class="status-tag draft">черновик</span>
763
- </div>
764
- <div ~if="$for.item.snippet" class="msg-snip">{{$for.item.snippet}}</div>
765
- </div>
766
- </div>
767
- </section>
768
-
769
- <main class="mail-view-pane" ~class="{ 'mobile-hidden': mode === 'idle' }">
770
- <div ~if="mode === 'idle'" class="empty-pane">
771
- <oda-icon icon="enterprise:email" icon-size="40" style="opacity:0.35;"></oda-icon>
772
- <div style="font-size:14px;font-weight:600;">Выберите письмо для просмотра</div>
773
- <div ~if="!accounts.length && canConfigure" style="font-size:12.5px;">
774
- Почтовый ящик для этого узла ещё не настроен.
775
- <div style="margin-top:8px;">
776
- <button type="button" class="compose-btn" @tap="openSettings()">Подключить ящик</button>
777
- </div>
778
- </div>
779
- </div>
780
-
781
- <div ~if="mode === 'view' && selected" style="display:flex;flex-direction:column;flex:1;min-height:0;">
782
- <div class="view-actions">
783
- <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
784
- <oda-button ~if="selected.box === 'drafts'" icon="editor:mode-edit" info-invert @tap="editDraft(selected)">Продолжить черновик</oda-button>
785
- <oda-button ~if="selected.box !== 'drafts'" icon="icons:reply" @tap="reply(false)">Ответить</oda-button>
786
- <oda-button ~if="selected.box !== 'drafts' && (selected.cc || (selected.to || '').includes(','))" icon="icons:reply-all" @tap="reply(true)">Ответить всем</oda-button>
787
- <oda-button icon="icons:forward" @tap="forward()">Переслать</oda-button>
788
- <oda-button ~if="selected.box === 'inbox'" :icon="selected.read ? 'icons:markunread' : 'icons:drafts'" @tap="toggleRead(selected)">
789
- {{selected.read ? 'Непрочитано' : 'Прочитано'}}
790
- </oda-button>
791
- <div style="flex:1;"></div>
792
- <oda-button ~if="selected.box !== 'trash'" icon="icons:delete" @tap="moveToTrash(selected)">В корзину</oda-button>
793
- <oda-button ~if="selected.box === 'trash'" icon="icons:restore" @tap="restoreFromTrash(selected)">Восстановить</oda-button>
794
- <oda-button ~if="selected.box === 'trash'" icon="icons:delete-forever" error @tap="deleteForever(selected)">Удалить навсегда</oda-button>
795
- </div>
796
-
797
- <div class="view-head">
798
- <div class="view-subject">{{selected.subject || '(без темы)'}}</div>
799
- <div class="view-meta"><b>От:</b> {{selected.from || '—'}} · <b>Дата:</b> {{fullDate(selected.date)}}</div>
800
- <div class="view-meta"><b>Кому:</b> {{selected.to || '—'}} <span ~if="selected.cc">· <b>Копия:</b> {{selected.cc}}</span></div>
801
- <div ~if="selected.error" style="font-size:12.5px;color:#dc2626;font-weight:600;">Ошибка доставки: {{selected.error}}</div>
802
- </div>
803
-
804
- <div ~if="selected.attachments?.length" class="att-bar">
805
- <div ~for="selected.attachments" class="att-chip" @tap="openAttachment($for.item)">
806
- <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
807
- <span>{{$for.item.name || 'Вложение'}}</span>
808
- </div>
809
- </div>
810
-
811
- <iframe ~if="selected.html" class="view-iframe" sandbox="allow-popups allow-popups-to-escape-sandbox" :srcdoc="htmlDoc"></iframe>
812
- <div ~if="!selected.html" class="view-body">{{selected.body || ''}}</div>
813
- </div>
814
-
815
- <div ~if="mode === 'compose'" class="compose-wrap">
816
- <div style="display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap;">
817
- <oda-button class="mail-back-btn" icon="icons:arrow-back" @tap="mode = 'idle'">Письма</oda-button>
818
- <span style="font-size:15px;font-weight:700;">{{draft.uid ? 'Редактирование черновика' : 'Новое письмо'}}</span>
819
- </div>
820
-
821
- <div class="compose-field">
822
- <label>От:</label>
823
- <select @change="draft.from = $event.target.value">
824
- <option ~for="accounts" :value="$for.item.address" :selected="$for.item.address === draft.from">{{$for.item.address}}</option>
825
- </select>
826
- </div>
827
- <div class="compose-field">
828
- <label>Кому:</label>
829
- <input placeholder="recipient@example.com" :value="draft.to" @input="draft.to = $event.target.value">
830
- </div>
831
- <div class="compose-field">
832
- <label>Копия:</label>
833
- <input placeholder="cc@example.com (необязательно)" :value="draft.cc" @input="draft.cc = $event.target.value">
834
- </div>
835
- <div class="compose-field">
836
- <label>Тема:</label>
837
- <input placeholder="Тема письма" :value="draft.subject" @input="draft.subject = $event.target.value">
838
- </div>
839
-
840
- <div class="att-bar" style="padding:6px 0;border:none;background:transparent;" ~if="draft.attachments?.length">
841
- <div ~for="draft.attachments" class="att-chip">
842
- <oda-icon icon="editor:attach-file" icon-size="14"></oda-icon>
843
- <span>{{$for.item.name}}</span>
844
- <oda-icon icon="icons:close" icon-size="13" style="cursor:pointer;" @tap.stop="removeDraftAttachment($for.index)"></oda-icon>
845
- </div>
846
- </div>
847
-
848
- <textarea class="compose-body" placeholder="Текст письма…" :value="draft.body" @input="draft.body = $event.target.value"></textarea>
849
-
850
- <div class="compose-footer">
851
- <oda-button icon="icons:send" info-invert @tap="sendDraft()">Отправить</oda-button>
852
- <oda-button icon="icons:save" @tap="saveDraft()">Сохранить черновик</oda-button>
853
- <label class="icon-btn" style="cursor:pointer;">
854
- <oda-icon icon="editor:attach-file" icon-size="15"></oda-icon>
855
- <span>Прикрепить</span>
856
- <input type="file" multiple hidden @change="onAttachFiles($event)">
857
- </label>
858
- <div style="flex:1;"></div>
859
- <oda-button icon="icons:close" @tap="mode = selected ? 'view' : 'idle'">Отмена</oda-button>
860
- </div>
861
- </div>
862
- </main>
863
- `,
864
- $item: {
865
- $def: null,
866
- set(n, o) {
867
- if (o && this._onChanged)
868
- o.unlisten?.('changed', this._onChanged);
869
- if (n) {
870
- this._onChanged ??= () => this.debounce('mail-reload', () => this.reload(), 200);
871
- n.listen?.('changed', this._onChanged);
872
- this.initLoad();
873
- }
874
- }
875
- },
876
- folders: [
877
- { id: 'inbox', label: 'Входящие', icon: 'icons:inbox' },
878
- { id: 'drafts', label: 'Черновики', icon: 'editor:insert-drive-file' },
879
- { id: 'outbox', label: 'Исходящие', icon: 'iconoir:send-mail' },
880
- { id: 'trash', label: 'Корзина', icon: 'icons:delete' },
881
- ],
882
- activeBox: 'inbox',
883
- selectedAccount: '',
884
- searchQuery: '',
885
- unreadOnly: false,
886
- loading: false,
887
- refreshing: false,
888
- accounts: [],
889
- canConfigure: false,
890
- autoRefresh: true,
891
- messages: [],
892
- countsByBox: { inbox: 0, drafts: 0, outbox: 0, trash: 0 },
893
- unreadByBox: { inbox: 0, drafts: 0, outbox: 0, trash: 0 },
894
- selected: null,
895
- mode: 'idle',
896
- draft: EMPTY_DRAFT(),
897
- get activeBoxLabel() {
898
- return this.folders.find(f => f.id === this.activeBox)?.label || 'Входящие';
899
- },
900
- get htmlDoc() {
901
- return htmlDocument(this.selected?.html);
902
- },
903
- attached() {
904
- if (this.$item && this._loadedFor !== this.$item)
905
- this.initLoad();
906
- },
907
- detached() {
908
- this.$item?.unlisten?.('changed', this._onChanged);
909
- },
910
- async initLoad() {
911
- const cur = this.$item;
912
- if (!cur) return;
913
- this._loadedFor = cur;
914
- this.selected = null;
915
- this.mode = 'idle';
916
- await this.loadAccounts();
917
- await this.reload();
918
- },
919
- async loadAccounts() {
920
- if (!this.$item?.fetch) return;
921
- try {
922
- const res = await this.$item.fetch('mail_accounts');
923
- this.accounts = Array.isArray(res?.accounts) ? res.accounts : [];
924
- this.canConfigure = Boolean(res?.canConfigure);
925
- this.autoRefresh = res?.autoRefresh !== false;
926
- }
927
- catch {
928
- this.accounts = [];
929
- this.canConfigure = false;
930
- }
931
- },
932
- async reload() {
933
- if (!this.$item?.fetch) return;
934
- this.loading = true;
935
- try {
936
- const res = await this.$item.fetch('mail_list', {}, JSON.stringify({
937
- box: this.activeBox,
938
- address: this.selectedAccount,
939
- q: this.searchQuery,
940
- unreadOnly: this.unreadOnly,
941
- limit: 200,
942
- }));
943
- this.messages = Array.isArray(res?.messages) ? res.messages : [];
944
- if (res?.countsByBox) this.countsByBox = res.countsByBox;
945
- if (res?.unreadByBox) this.unreadByBox = res.unreadByBox;
946
- }
947
- catch (e) {
948
- this.messages = [];
949
- }
950
- finally {
951
- this.loading = false;
952
- }
953
- },
954
- badgeOf(boxId) {
955
- return boxId === 'inbox' ? (Number(this.unreadByBox?.[boxId]) || 0) : 0;
956
- },
957
- countOf(boxId) {
958
- return boxId === 'drafts' ? (Number(this.countsByBox?.[boxId]) || 0) : 0;
959
- },
960
- peerLabel(msg) {
961
- if (this.activeBox === 'outbox' || this.activeBox === 'drafts')
962
- return msg.to || '(без получателя)';
963
- return msg.from || '(неизвестный отправитель)';
964
- },
965
- shortDate(v) { return formatMailShortDate(v); },
966
- fullDate(v) { return formatMailFullDate(v); },
967
- selectBox(boxId) {
968
- this.activeBox = boxId;
969
- this.selected = null;
970
- if (this.mode === 'view') this.mode = 'idle';
971
- this.reload();
972
- },
973
- selectAccount(addr) {
974
- this.selectedAccount = addr || '';
975
- this.reload();
976
- },
977
- onSearchInput(e) {
978
- this.searchQuery = e.target.value || '';
979
- this.debounce('mail-search', () => this.reload(), 200);
980
- },
981
- toggleUnreadOnly() {
982
- this.unreadOnly = !this.unreadOnly;
983
- this.reload();
984
- },
985
- async fetchRefresh() {
986
- if (!this.$item?.fetch || this.refreshing) return;
987
- this.refreshing = true;
988
- try {
989
- await this.$item.fetch('mail_refresh');
990
- }
991
- catch (e) {
992
- ODA.showMessage?.(e?.message || String(e));
993
- }
994
- finally {
995
- this.refreshing = false;
996
- }
997
- await this.loadAccounts();
998
- await this.reload();
999
- },
1000
- async selectMessage(msg) {
1001
- if (!msg?.path || !this.$item?.fetch) return;
1002
- this.selected = msg;
1003
- this.mode = 'view';
1004
- try {
1005
- const full = await this.$item.fetch('mail_read', {}, JSON.stringify({ path: msg.path, uid: msg.uid, markRead: true }));
1006
- this.selected = full;
1007
- if (!msg.read && full.read) {
1008
- msg.read = true;
1009
- this.messages = [...this.messages];
1010
- if (this.unreadByBox.inbox > 0) {
1011
- this.unreadByBox = { ...this.unreadByBox, inbox: this.unreadByBox.inbox - 1 };
1012
- }
1013
- }
1014
- }
1015
- catch (e) {
1016
- ODA.showMessage?.(e?.message || String(e));
1017
- }
1018
- },
1019
- async toggleRead(msg) {
1020
- if (!msg?.path || !this.$item?.fetch) return;
1021
- try {
1022
- await this.$item.fetch('mail_state', {}, JSON.stringify({ path: msg.path, uid: msg.uid, read: !msg.read }));
1023
- await this.reload();
1024
- if (this.selected?.path === msg.path)
1025
- this.selected = { ...this.selected, read: !msg.read };
1026
- }
1027
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1028
- },
1029
- async moveToTrash(msg) {
1030
- if (!msg?.path || !this.$item?.fetch) return;
1031
- try {
1032
- await this.$item.fetch('mail_state', {}, JSON.stringify({ path: msg.path, uid: msg.uid, box: 'trash' }));
1033
- this.selected = null;
1034
- this.mode = 'idle';
1035
- await this.reload();
1036
- }
1037
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1038
- },
1039
- async restoreFromTrash(msg) {
1040
- if (!msg?.path || !this.$item?.fetch) return;
1041
- try {
1042
- await this.$item.fetch('mail_state', {}, JSON.stringify({ path: msg.path, uid: msg.uid, restore: true }));
1043
- this.selected = null;
1044
- this.mode = 'idle';
1045
- await this.reload();
1046
- }
1047
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1048
- },
1049
- async deleteForever(msg) {
1050
- if (!msg?.path || !this.$item?.fetch) return;
1051
- try {
1052
- await this.$item.fetch('mail_state', {}, JSON.stringify({ path: msg.path, uid: msg.uid, deletePermanent: true }));
1053
- this.selected = null;
1054
- this.mode = 'idle';
1055
- await this.reload();
1056
- }
1057
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1058
- },
1059
- async createEmail(init = {}) {
1060
- if (!this.accounts.length)
1061
- await this.loadAccounts();
1062
- if (!this.accounts.length) {
1063
- ODA.showMessage?.('Сначала настройте почтовый ящик');
1064
- return;
1065
- }
1066
- this.draft = {
1067
- ...EMPTY_DRAFT(),
1068
- from: this.selectedAccount || this.accounts[0]?.address || '',
1069
- ...init,
1070
- };
1071
- this.mode = 'compose';
1072
- },
1073
- editDraft(msg) {
1074
- this.createEmail({
1075
- uid: msg.uid || '',
1076
- origTime: msg.origTime || 0,
1077
- from: msg.address || msg.from || this.accounts[0]?.address || '',
1078
- to: msg.to || '',
1079
- cc: msg.cc || '',
1080
- subject: msg.subject === '(без темы)' ? '' : (msg.subject || ''),
1081
- body: msg.body || '',
1082
- attachments: Array.isArray(msg.attachments) ? [...msg.attachments] : [],
1083
- });
1084
- },
1085
- reply(replyAll = false) {
1086
- const src = this.selected;
1087
- if (!src) return;
1088
- const subject = /^re:/i.test(src.subject || '') ? src.subject : 'Re: ' + (src.subject || '');
1089
- const to = src.box === 'outbox' ? src.to : src.from;
1090
- const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1091
- this.createEmail({
1092
- to,
1093
- cc: replyAll ? (src.cc || '') : '',
1094
- subject,
1095
- body: quoteBody(src),
1096
- inReplyTo: src.messageId || '',
1097
- ...(from ? { from } : {}),
1098
- });
1099
- },
1100
- forward() {
1101
- const src = this.selected;
1102
- if (!src) return;
1103
- const subject = /^fwd?:/i.test(src.subject || '') ? src.subject : 'Fwd: ' + (src.subject || '');
1104
- const from = this.accounts.some(a => a.address === src.address) ? src.address : undefined;
1105
- this.createEmail({
1106
- to: '',
1107
- subject,
1108
- body: `\n\n---------- Пересылаемое сообщение ----------\nОт: ${src.from}\nКому: ${src.to}\nТема: ${src.subject}\n\n${src.body || htmlToText(src.html || '')}`,
1109
- attachments: Array.isArray(src.attachments) ? src.attachments.filter(a => a.path) : [],
1110
- ...(from ? { from } : {}),
1111
- });
1112
- },
1113
- async onAttachFiles(e) {
1114
- const files = [...(e.target?.files || [])];
1115
- e.target.value = '';
1116
- if (!files.length || !this.$item?.save_files) return;
1117
- try {
1118
- const fd = new FormData();
1119
- for (const f of files)
1120
- fd.append('file', f, f.name);
1121
- const saved = await this.$item.save_files(fd, { ignore_save_logs: true });
1122
- const arr = Array.isArray(saved) ? saved : (saved ? [saved] : []);
1123
- const nextAtts = [...(this.draft.attachments || [])];
1124
- for (let i = 0; i < arr.length; i++) {
1125
- const s = arr[i];
1126
- const p = s?.path || s?.logFullPath || '';
1127
- if (p)
1128
- nextAtts.push({ name: files[i]?.name || p.split('/').pop(), path: p });
1129
- }
1130
- this.draft = { ...this.draft, attachments: nextAtts };
1131
- }
1132
- catch (err) {
1133
- ODA.showMessage?.(err?.message || String(err));
1134
- }
1135
- },
1136
- removeDraftAttachment(idx) {
1137
- const next = [...(this.draft.attachments || [])];
1138
- next.splice(idx, 1);
1139
- this.draft = { ...this.draft, attachments: next };
1140
- },
1141
- async saveDraft() {
1142
- if (!this.$item?.fetch) return;
1143
- try {
1144
- const res = await this.$item.fetch('mail_draft_save', {}, JSON.stringify(this.draft));
1145
- this.draft = { ...this.draft, uid: res?.uid || this.draft.uid };
1146
- ODA.showMessage?.('Черновик сохранён');
1147
- await this.reload();
1148
- }
1149
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1150
- },
1151
- async sendDraft() {
1152
- if (!this.$item?.fetch) return;
1153
- try {
1154
- await this.$item.fetch('mail_send', {}, JSON.stringify({
1155
- ...this.draft,
1156
- draftUid: this.draft.uid || undefined,
1157
- }));
1158
- this.draft = EMPTY_DRAFT();
1159
- this.mode = 'idle';
1160
- this.activeBox = 'outbox';
1161
- await this.reload();
1162
- }
1163
- catch (e) { ODA.showMessage?.(e?.message || String(e)); }
1164
- },
1165
- async openAttachment(att) {
1166
- if (!att?.path) {
1167
- ODA.showMessage?.(`Вложение «${att?.name || 'файл'}»`);
1168
- return;
1169
- }
1170
- const item = await globalThis.WORK?.get_item?.(att.path).catch(() => null);
1171
- if (item && typeof window?.execute === 'function')
1172
- window.execute(item);
1173
- },
1174
- async openSettings() {
1175
- const res = await openEmailSettingsDialog(this.$item);
1176
- if (res) {
1177
- await this.loadAccounts();
1178
- await this.reload();
1179
- }
1180
- },
1181
- async toggleAutoRefresh(val) {
1182
- this.autoRefresh = Boolean(val);
1183
- try {
1184
- await this.$item?.save?.({ mailAutoRefresh: this.autoRefresh });
1185
- }
1186
- catch { /* ignore */ }
1187
- },
1188
- };