Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b367ee539 | ||
|
|
9134b8945d | ||
|
|
19b1751e78 | ||
|
|
a20956cde2 | ||
|
|
659171bf0a | ||
|
|
f5b3accc13 | ||
|
|
22e9096f7c | ||
|
|
6aee17fad2 | ||
|
|
b594889239 |
@@ -75,17 +75,16 @@ public partial class LoginWindow : Window
|
|||||||
msgHandler = (_, args) =>
|
msgHandler = (_, args) =>
|
||||||
{
|
{
|
||||||
Browser.CoreWebView2.WebMessageReceived -= msgHandler;
|
Browser.CoreWebView2.WebMessageReceived -= msgHandler;
|
||||||
tcs.TrySetResult(args.WebMessageAsString);
|
tcs.TrySetResult(args.WebMessageAsJson);
|
||||||
};
|
};
|
||||||
Browser.CoreWebView2.WebMessageReceived += msgHandler;
|
Browser.CoreWebView2.WebMessageReceived += msgHandler;
|
||||||
|
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const h={headers:{accept:'application/json'}};
|
const h={headers:{accept:'application/json'}};
|
||||||
const b=await(await fetch('/api/bootstrap',h)).json();
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
const bkeys=Object.keys(b||{}).join(',');
|
const rawB=JSON.stringify(b).slice(0,600);
|
||||||
const akeys=Object.keys(b?.account||{}).join(',');
|
|
||||||
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
||b?.default_organization?.uuid||null;
|
||b?.default_organization?.uuid||b?.account?.uuid||null;
|
||||||
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
let orgSrc='bootstrap';
|
let orgSrc='bootstrap';
|
||||||
if(!id){
|
if(!id){
|
||||||
@@ -95,12 +94,13 @@ public partial class LoginWindow : Window
|
|||||||
if(!id){
|
if(!id){
|
||||||
let pu=null;
|
let pu=null;
|
||||||
try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
|
try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
|
||||||
window.chrome.webview.postMessage(JSON.stringify({email:e,orgId:null,usage:(pu&&!pu.error?pu:null),debug:'no-org|bkeys:'+bkeys+'|akeys:'+akeys}));
|
window.chrome.webview.postMessage({email:e,orgId:null,usage:(pu&&!pu.error?pu:null),debug:'no-org|raw:'+rawB});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
||||||
window.chrome.webview.postMessage(JSON.stringify({email:e,orgId:id,usage:u,debug:'orgSrc:'+orgSrc+'|bkeys:'+bkeys+'|akeys:'+akeys}));
|
const rawU=JSON.stringify(u).slice(0,300);
|
||||||
}catch(ex){window.chrome.webview.postMessage(JSON.stringify({error:String(ex)}));}})()";
|
window.chrome.webview.postMessage({email:e,orgId:id,usage:u,debug:'src:'+orgSrc+'|ukeys:'+Object.keys(u||{}).join(',')+'|raw:'+rawB});
|
||||||
|
}catch(ex){window.chrome.webview.postMessage({error:String(ex)});}})()";
|
||||||
|
|
||||||
await Browser.CoreWebView2.ExecuteScriptAsync(script);
|
await Browser.CoreWebView2.ExecuteScriptAsync(script);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,16 @@
|
|||||||
|
|
||||||
<!-- Cards scroll area -->
|
<!-- Cards scroll area -->
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<StackPanel x:Name="CardsPanel" Margin="0,4,0,4"/>
|
<StackPanel Margin="0,4,0,4">
|
||||||
|
<Border x:Name="DebugBanner" Visibility="Collapsed"
|
||||||
|
Background="{DynamicResource CardBrush}"
|
||||||
|
BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1"
|
||||||
|
CornerRadius="6" Margin="12,4,12,4" Padding="12,8">
|
||||||
|
<TextBlock x:Name="DebugBannerText" FontSize="10" FontFamily="Consolas"
|
||||||
|
Foreground="{DynamicResource SecondaryBrush}" TextWrapping="Wrap"/>
|
||||||
|
</Border>
|
||||||
|
<StackPanel x:Name="CardsPanel"/>
|
||||||
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
|
|||||||
@@ -287,12 +287,15 @@ public partial class PopupWindow : Window
|
|||||||
var dbg = AppSettings.Default.DebugInfo;
|
var dbg = AppSettings.Default.DebugInfo;
|
||||||
if (!string.IsNullOrEmpty(dbg))
|
if (!string.IsNullOrEmpty(dbg))
|
||||||
{
|
{
|
||||||
DebugText.Text = dbg;
|
DebugText.Text = dbg;
|
||||||
DebugText.Visibility = Visibility.Visible;
|
DebugText.Visibility = Visibility.Visible;
|
||||||
|
DebugBannerText.Text = dbg;
|
||||||
|
DebugBanner.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DebugText.Visibility = Visibility.Collapsed;
|
DebugText.Visibility = Visibility.Collapsed;
|
||||||
|
DebugBanner.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
## What's new in beta.26
|
## What's new in beta.28
|
||||||
|
|
||||||
- Fixed: script results now use window.chrome.webview.postMessage instead of async IIFE return value — older WebView2 runtimes don't await Promises from ExecuteScriptAsync, so data was never received
|
- Debug banner now appears on the main panel after sign-in showing raw bootstrap data — paste this here so we can fix org ID parsing
|
||||||
- Debug text in Settings will now always show what happened during sign-in
|
- Fix: limits no longer wiped when a refresh cycle returns no data (placeholders stay until real data arrives)
|
||||||
|
- Try account.uuid as org ID fallback when no org found in bootstrap
|
||||||
|
|||||||
@@ -131,12 +131,8 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
|
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
Limits = limits;
|
if (limits.Count > 0) { Limits = limits; Overage = overage; Prepaid = prepaid; }
|
||||||
Overage = overage;
|
|
||||||
Prepaid = prepaid;
|
|
||||||
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
if (!string.IsNullOrEmpty(email)) UserEmail = email;
|
||||||
// Trust that cookies / cached auth mean the user IS signed in,
|
|
||||||
// even if the live fetch failed this cycle.
|
|
||||||
IsSignedIn = true;
|
IsSignedIn = true;
|
||||||
ErrorMessage = null;
|
ErrorMessage = null;
|
||||||
LastUpdated = DateTime.Now;
|
LastUpdated = DateTime.Now;
|
||||||
@@ -203,11 +199,11 @@ public class UsageViewModel : INotifyPropertyChanged
|
|||||||
if(!id){
|
if(!id){
|
||||||
let pu=null;
|
let pu=null;
|
||||||
try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
|
try{pu=await(await fetch('/api/usage',h)).json();}catch(e3){}
|
||||||
window.chrome.webview.postMessage(JSON.stringify({email:em,orgId:null,usage:(pu&&!pu.error?pu:null)}));
|
window.chrome.webview.postMessage({email:em,orgId:null,usage:(pu&&!pu.error?pu:null)});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
||||||
window.chrome.webview.postMessage(JSON.stringify({email:em,orgId:id,usage:u}));
|
window.chrome.webview.postMessage({email:em,orgId:id,usage:u});
|
||||||
}catch(ex){window.chrome.webview.postMessage(null);}})();";
|
}catch(ex){window.chrome.webview.postMessage(null);}})();";
|
||||||
|
|
||||||
var resultJson = await Application.Current.Dispatcher.InvokeAsync(async () =>
|
var resultJson = await Application.Current.Dispatcher.InvokeAsync(async () =>
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ internal sealed class WebViewFetchWindow : Window
|
|||||||
msgHandler = (_, args) =>
|
msgHandler = (_, args) =>
|
||||||
{
|
{
|
||||||
_wv.CoreWebView2.WebMessageReceived -= msgHandler;
|
_wv.CoreWebView2.WebMessageReceived -= msgHandler;
|
||||||
tcs.TrySetResult(args.WebMessageAsString);
|
tcs.TrySetResult(args.WebMessageAsJson);
|
||||||
};
|
};
|
||||||
_wv.CoreWebView2.WebMessageReceived += msgHandler;
|
_wv.CoreWebView2.WebMessageReceived += msgHandler;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user