From ccf08a3077398b8053f047cc8c011a6eaf346268 Mon Sep 17 00:00:00 2001 From: trungduong Date: Wed, 19 Nov 2025 07:57:43 +0700 Subject: [PATCH] v0.0.3 twa sys --- TWA-App/wwwroot/js/libs/js-AElementFixed.js | 16 +++---- .../DBModels/{ => SotrageModel}/Files.cs | 2 +- .../DBModels/{ => SotrageModel}/Folder.cs | 2 +- .../Folders_has_StorageArea.cs | 2 +- .../{ => SotrageModel}/LocalServer.cs | 2 +- .../{ => SotrageModel}/MicrosoftAccount.cs | 2 +- .../{ => SotrageModel}/RefreshToken.cs | 2 +- .../{ => SotrageModel}/RefreshToken_Log.cs | 2 +- .../{ => SotrageModel}/ServerAuthorization.cs | 6 +-- .../ServerAuthorization_has_Token.cs | 2 +- .../{ => SotrageModel}/StorageArea.cs | 2 +- .../StorageArea_has_StorageServer.cs | 2 +- .../{ => SotrageModel}/StorageServer.cs | 2 +- .../StorageServer_has_LocalServer.cs | 2 +- .../StorageServer_has_MicrosoftAccount.cs | 2 +- .../StorageServers_ValidationDomain.cs | 2 +- .../{ => SotrageModel}/SyncFile_Log.cs | 2 +- .../DBModels/{ => SotrageModel}/Token.cs | 2 +- .../{ => SotrageModel}/TypeStorageServer.cs | 2 +- .../{ => SotrageModel}/ValidationDomain.cs | 4 +- TWASys-App/Models/StorageModel.cs | 44 ++++++++++++++++++- TWASys-App/Models/TypeStorageServerModel.cs | 1 + TWASys-App/Models/ValidationDomainModel.cs | 1 + TWASys-App/TWASys-App.csproj | 4 ++ 24 files changed, 75 insertions(+), 35 deletions(-) rename TWASys-App/DBModels/{ => SotrageModel}/Files.cs (95%) rename TWASys-App/DBModels/{ => SotrageModel}/Folder.cs (96%) rename TWASys-App/DBModels/{ => SotrageModel}/Folders_has_StorageArea.cs (89%) rename TWASys-App/DBModels/{ => SotrageModel}/LocalServer.cs (96%) rename TWASys-App/DBModels/{ => SotrageModel}/MicrosoftAccount.cs (96%) rename TWASys-App/DBModels/{ => SotrageModel}/RefreshToken.cs (92%) rename TWASys-App/DBModels/{ => SotrageModel}/RefreshToken_Log.cs (93%) rename TWASys-App/DBModels/{ => SotrageModel}/ServerAuthorization.cs (76%) rename TWASys-App/DBModels/{ => SotrageModel}/ServerAuthorization_has_Token.cs (91%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageArea.cs (93%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageArea_has_StorageServer.cs (93%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageServer.cs (94%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageServer_has_LocalServer.cs (92%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageServer_has_MicrosoftAccount.cs (92%) rename TWASys-App/DBModels/{ => SotrageModel}/StorageServers_ValidationDomain.cs (93%) rename TWASys-App/DBModels/{ => SotrageModel}/SyncFile_Log.cs (95%) rename TWASys-App/DBModels/{ => SotrageModel}/Token.cs (90%) rename TWASys-App/DBModels/{ => SotrageModel}/TypeStorageServer.cs (91%) rename TWASys-App/DBModels/{ => SotrageModel}/ValidationDomain.cs (86%) diff --git a/TWA-App/wwwroot/js/libs/js-AElementFixed.js b/TWA-App/wwwroot/js/libs/js-AElementFixed.js index a59e24b..9376146 100644 --- a/TWA-App/wwwroot/js/libs/js-AElementFixed.js +++ b/TWA-App/wwwroot/js/libs/js-AElementFixed.js @@ -28,10 +28,10 @@ export default class AElementFixed extends window.AObject { this._snapLoopId = null; // rAF: monitor chạm đáy CHA khi đang snap this._needIntroPose = true;// hiệu ứng intro khi snap this._snapWidth = null; // lock width (px) khi portal - this._isInit = false; + this._bind(); + this._initObservers(); this._onResize(); - } update(opts = {}) { @@ -59,17 +59,10 @@ export default class AElementFixed extends window.AObject { _onResize() { const desktop = window.innerWidth >= this.o.breakpoint; - if (desktop) { - if (!this._isInit) { - this._initObservers(); - this._isInit = true; - } - } else { - this._isInit = false; + if (!desktop) { this._stopInViewLoop(); this._stopSnapMonitor(); this._unsnapAbsolute(); - this._teardownObservers(); } } @@ -109,6 +102,7 @@ export default class AElementFixed extends window.AObject { const vpBottom = e.rootBounds ? e.rootBounds.bottom : document.documentElement.clientHeight; const EPS = 0.75; if (e.isIntersecting) { + console.log(e.target.style.bottom); if (e.target.style.bottom === '0px') { this._startInViewLoop(); @@ -264,7 +258,7 @@ export default class AElementFixed extends window.AObject { this.el.style.left = ''; this.el.style.top = ''; this.el.style.bottom = ''; - this.el.style.width = ''; + this._restoreToHostBeforeProbe(); } } diff --git a/TWASys-App/DBModels/Files.cs b/TWASys-App/DBModels/SotrageModel/Files.cs similarity index 95% rename from TWASys-App/DBModels/Files.cs rename to TWASys-App/DBModels/SotrageModel/Files.cs index 40cda59..f3b96fc 100644 --- a/TWASys-App/DBModels/Files.cs +++ b/TWASys-App/DBModels/SotrageModel/Files.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class Files { diff --git a/TWASys-App/DBModels/Folder.cs b/TWASys-App/DBModels/SotrageModel/Folder.cs similarity index 96% rename from TWASys-App/DBModels/Folder.cs rename to TWASys-App/DBModels/SotrageModel/Folder.cs index 0e3d411..50e5e46 100644 --- a/TWASys-App/DBModels/Folder.cs +++ b/TWASys-App/DBModels/SotrageModel/Folder.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class Folder { diff --git a/TWASys-App/DBModels/Folders_has_StorageArea.cs b/TWASys-App/DBModels/SotrageModel/Folders_has_StorageArea.cs similarity index 89% rename from TWASys-App/DBModels/Folders_has_StorageArea.cs rename to TWASys-App/DBModels/SotrageModel/Folders_has_StorageArea.cs index ee4e10d..a7bf53e 100644 --- a/TWASys-App/DBModels/Folders_has_StorageArea.cs +++ b/TWASys-App/DBModels/SotrageModel/Folders_has_StorageArea.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class Folders_has_StorageArea { diff --git a/TWASys-App/DBModels/LocalServer.cs b/TWASys-App/DBModels/SotrageModel/LocalServer.cs similarity index 96% rename from TWASys-App/DBModels/LocalServer.cs rename to TWASys-App/DBModels/SotrageModel/LocalServer.cs index a32f4e2..3464a3c 100644 --- a/TWASys-App/DBModels/LocalServer.cs +++ b/TWASys-App/DBModels/SotrageModel/LocalServer.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class LocalServer { diff --git a/TWASys-App/DBModels/MicrosoftAccount.cs b/TWASys-App/DBModels/SotrageModel/MicrosoftAccount.cs similarity index 96% rename from TWASys-App/DBModels/MicrosoftAccount.cs rename to TWASys-App/DBModels/SotrageModel/MicrosoftAccount.cs index e702143..19e3523 100644 --- a/TWASys-App/DBModels/MicrosoftAccount.cs +++ b/TWASys-App/DBModels/SotrageModel/MicrosoftAccount.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class MicrosoftAccount { diff --git a/TWASys-App/DBModels/RefreshToken.cs b/TWASys-App/DBModels/SotrageModel/RefreshToken.cs similarity index 92% rename from TWASys-App/DBModels/RefreshToken.cs rename to TWASys-App/DBModels/SotrageModel/RefreshToken.cs index 5d77b61..67516c7 100644 --- a/TWASys-App/DBModels/RefreshToken.cs +++ b/TWASys-App/DBModels/SotrageModel/RefreshToken.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class RefreshToken { diff --git a/TWASys-App/DBModels/RefreshToken_Log.cs b/TWASys-App/DBModels/SotrageModel/RefreshToken_Log.cs similarity index 93% rename from TWASys-App/DBModels/RefreshToken_Log.cs rename to TWASys-App/DBModels/SotrageModel/RefreshToken_Log.cs index 892a5d7..7db6cb1 100644 --- a/TWASys-App/DBModels/RefreshToken_Log.cs +++ b/TWASys-App/DBModels/SotrageModel/RefreshToken_Log.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class RefreshToken_Log { diff --git a/TWASys-App/DBModels/ServerAuthorization.cs b/TWASys-App/DBModels/SotrageModel/ServerAuthorization.cs similarity index 76% rename from TWASys-App/DBModels/ServerAuthorization.cs rename to TWASys-App/DBModels/SotrageModel/ServerAuthorization.cs index c4ca129..87bad4b 100644 --- a/TWASys-App/DBModels/ServerAuthorization.cs +++ b/TWASys-App/DBModels/SotrageModel/ServerAuthorization.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class ServerAuthorization { @@ -12,11 +12,11 @@ namespace TWASys_App.DBModels [ForeignKey("IdStorageServer")] public long IdStorageServer { get; set; } public DateTime CreateDate { get; set; } - public int Count { get; set; } + public int Count { get; set; } public int Status { get; set; } [NotMapped()] - public ICollection Tokens { get; set; } = new List(); + public ICollection Tokens { get; set; } = new List(); [NotMapped()] public ICollection RefreshTokens { get; set; } = new List(); diff --git a/TWASys-App/DBModels/ServerAuthorization_has_Token.cs b/TWASys-App/DBModels/SotrageModel/ServerAuthorization_has_Token.cs similarity index 91% rename from TWASys-App/DBModels/ServerAuthorization_has_Token.cs rename to TWASys-App/DBModels/SotrageModel/ServerAuthorization_has_Token.cs index 8db2985..68d6832 100644 --- a/TWASys-App/DBModels/ServerAuthorization_has_Token.cs +++ b/TWASys-App/DBModels/SotrageModel/ServerAuthorization_has_Token.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class ServerAuthorization_has_Token { diff --git a/TWASys-App/DBModels/StorageArea.cs b/TWASys-App/DBModels/SotrageModel/StorageArea.cs similarity index 93% rename from TWASys-App/DBModels/StorageArea.cs rename to TWASys-App/DBModels/SotrageModel/StorageArea.cs index 07d8c16..9835665 100644 --- a/TWASys-App/DBModels/StorageArea.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageArea.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageArea { diff --git a/TWASys-App/DBModels/StorageArea_has_StorageServer.cs b/TWASys-App/DBModels/SotrageModel/StorageArea_has_StorageServer.cs similarity index 93% rename from TWASys-App/DBModels/StorageArea_has_StorageServer.cs rename to TWASys-App/DBModels/SotrageModel/StorageArea_has_StorageServer.cs index 9d0f083..9802687 100644 --- a/TWASys-App/DBModels/StorageArea_has_StorageServer.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageArea_has_StorageServer.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageArea_has_StorageServer { diff --git a/TWASys-App/DBModels/StorageServer.cs b/TWASys-App/DBModels/SotrageModel/StorageServer.cs similarity index 94% rename from TWASys-App/DBModels/StorageServer.cs rename to TWASys-App/DBModels/SotrageModel/StorageServer.cs index 30a47da..1dc634d 100644 --- a/TWASys-App/DBModels/StorageServer.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageServer.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageServer { diff --git a/TWASys-App/DBModels/StorageServer_has_LocalServer.cs b/TWASys-App/DBModels/SotrageModel/StorageServer_has_LocalServer.cs similarity index 92% rename from TWASys-App/DBModels/StorageServer_has_LocalServer.cs rename to TWASys-App/DBModels/SotrageModel/StorageServer_has_LocalServer.cs index 175cf77..314a16e 100644 --- a/TWASys-App/DBModels/StorageServer_has_LocalServer.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageServer_has_LocalServer.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageServer_has_LocalServer { diff --git a/TWASys-App/DBModels/StorageServer_has_MicrosoftAccount.cs b/TWASys-App/DBModels/SotrageModel/StorageServer_has_MicrosoftAccount.cs similarity index 92% rename from TWASys-App/DBModels/StorageServer_has_MicrosoftAccount.cs rename to TWASys-App/DBModels/SotrageModel/StorageServer_has_MicrosoftAccount.cs index c17cee8..f2427ac 100644 --- a/TWASys-App/DBModels/StorageServer_has_MicrosoftAccount.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageServer_has_MicrosoftAccount.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageServer_has_MicrosoftAccount { diff --git a/TWASys-App/DBModels/StorageServers_ValidationDomain.cs b/TWASys-App/DBModels/SotrageModel/StorageServers_ValidationDomain.cs similarity index 93% rename from TWASys-App/DBModels/StorageServers_ValidationDomain.cs rename to TWASys-App/DBModels/SotrageModel/StorageServers_ValidationDomain.cs index 8c7810f..59c598b 100644 --- a/TWASys-App/DBModels/StorageServers_ValidationDomain.cs +++ b/TWASys-App/DBModels/SotrageModel/StorageServers_ValidationDomain.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class StorageServers_ValidationDomain { diff --git a/TWASys-App/DBModels/SyncFile_Log.cs b/TWASys-App/DBModels/SotrageModel/SyncFile_Log.cs similarity index 95% rename from TWASys-App/DBModels/SyncFile_Log.cs rename to TWASys-App/DBModels/SotrageModel/SyncFile_Log.cs index 74ab31d..dec0379 100644 --- a/TWASys-App/DBModels/SyncFile_Log.cs +++ b/TWASys-App/DBModels/SotrageModel/SyncFile_Log.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc.Filters; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class SyncFile_Log { diff --git a/TWASys-App/DBModels/Token.cs b/TWASys-App/DBModels/SotrageModel/Token.cs similarity index 90% rename from TWASys-App/DBModels/Token.cs rename to TWASys-App/DBModels/SotrageModel/Token.cs index 7f1ec51..ed29712 100644 --- a/TWASys-App/DBModels/Token.cs +++ b/TWASys-App/DBModels/SotrageModel/Token.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class Token { diff --git a/TWASys-App/DBModels/TypeStorageServer.cs b/TWASys-App/DBModels/SotrageModel/TypeStorageServer.cs similarity index 91% rename from TWASys-App/DBModels/TypeStorageServer.cs rename to TWASys-App/DBModels/SotrageModel/TypeStorageServer.cs index 73e26d9..0755223 100644 --- a/TWASys-App/DBModels/TypeStorageServer.cs +++ b/TWASys-App/DBModels/SotrageModel/TypeStorageServer.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class TypeStorageServer { diff --git a/TWASys-App/DBModels/ValidationDomain.cs b/TWASys-App/DBModels/SotrageModel/ValidationDomain.cs similarity index 86% rename from TWASys-App/DBModels/ValidationDomain.cs rename to TWASys-App/DBModels/SotrageModel/ValidationDomain.cs index 42f072e..d8473c4 100644 --- a/TWASys-App/DBModels/ValidationDomain.cs +++ b/TWASys-App/DBModels/SotrageModel/ValidationDomain.cs @@ -1,7 +1,7 @@ - using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace TWASys_App.DBModels +namespace TWASys_App.DBModels.SotrageModel { public class ValidationDomain { diff --git a/TWASys-App/Models/StorageModel.cs b/TWASys-App/Models/StorageModel.cs index 11a8af5..7c0e9c9 100644 --- a/TWASys-App/Models/StorageModel.cs +++ b/TWASys-App/Models/StorageModel.cs @@ -6,10 +6,12 @@ using Microsoft.AspNetCore.Razor.Language.Intermediate; using Microsoft.VisualBasic; using MySqlConnector; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System.Data.Common; using System.Xml.Linq; using TWASys_App.Dapper.AExtentions; using TWASys_App.DBModels; +using TWASys_App.DBModels.SotrageModel; namespace TWASys_App.Models { @@ -24,7 +26,7 @@ namespace TWASys_App.Models public ICollection ValidationDomains { set; get; } = new List(); - public int Size { set; get; }; + public int Size { set; get; } public string IpPublic { set; get; } = ""; public string IpPrivatev4 { set; get; } = ""; @@ -208,6 +210,37 @@ namespace TWASys_App.Models throw new NotImplementedException(); } + private void ProccessToken(Dictionary dict, IList tokens, bool isToken =true) + { + foreach (dynamic token in tokens) + { + if (dict.ContainsKey(token.idServerAuthorization)) + { + ServerAuthorization tm; + if (dict.TryGetValue(token.idServerAuthorization, out tm)) + { + if (isToken) + { + tm.Tokens.Add(new Token { IdToken = token.idToken, AccessToken = token.accessToken, CreateDate = token.createDate, ExpireDate = token.expireDate }); + } + else + { + tm.RefreshTokens.Add(new RefreshToken { }); + } + } + } + else + { + var tmp = new ServerAuthorization + { + IdServerAuthorization = token.idServerAuthorization + }; + tmp.Tokens.Add(new Token { IdToken = token.idToken, AccessToken = token.accessToken }); + dict.TryAdd(token.idServerAuthorization, tmp); + } + } + } + public async Task UpdateStorageSize() { var fMess = new MessageHeader(); @@ -228,7 +261,9 @@ namespace TWASys_App.Models SELECT sa.idServerAuthorization, st.idToken, - t.accessToken + t.accessToken, + t.createDate, + t.expireDate FROM sa_need sa JOIN maxc m ON m.idServerAuthorization = sa.idServerAuthorization JOIN ServerAuthorization_has_Token st @@ -254,8 +289,13 @@ namespace TWASys_App.Models await con.OpenAsync(); using var trans = await con.BeginTransactionAsync(); using var multi = await con.QueryMultipleAsync(sql, new { size = Size, id = IdStorageServer }, trans); + IList tokens = (await multi.ReadAsync()).AsList(); IList rTokens = (await multi.ReadAsync()).AsList(); + Dictionary dict = new Dictionary(); + ProccessToken(dict, tokens); + ProccessToken(dict, rTokens, false); + using (var writer = new StreamWriter(Path.GetFullPath("Json/dataServer.json"), false)) { await writer.WriteAsync(JsonConvert.SerializeObject(new diff --git a/TWASys-App/Models/TypeStorageServerModel.cs b/TWASys-App/Models/TypeStorageServerModel.cs index 0ab5356..f83d66f 100644 --- a/TWASys-App/Models/TypeStorageServerModel.cs +++ b/TWASys-App/Models/TypeStorageServerModel.cs @@ -6,6 +6,7 @@ using MySqlConnector; using Newtonsoft.Json; using System.ComponentModel.DataAnnotations; using System.Data.Common; +using TWASys_App.DBModels.SotrageModel; namespace TWASys_App.Models { diff --git a/TWASys-App/Models/ValidationDomainModel.cs b/TWASys-App/Models/ValidationDomainModel.cs index b85e2d6..28501c2 100644 --- a/TWASys-App/Models/ValidationDomainModel.cs +++ b/TWASys-App/Models/ValidationDomainModel.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using MySqlConnector; using Newtonsoft.Json; using System.Data.Common; +using TWASys_App.DBModels.SotrageModel; namespace TWASys_App.Models { diff --git a/TWASys-App/TWASys-App.csproj b/TWASys-App/TWASys-App.csproj index a32a68d..9eb5b31 100644 --- a/TWASys-App/TWASys-App.csproj +++ b/TWASys-App/TWASys-App.csproj @@ -53,4 +53,8 @@ + + + +