protected async Task SaveExtra(Extra extra) { var result = RegisteredFunction.Invoke <bool>("validateExtra", $"#extra_optional_{extra.Id}"); if (result) { // TODO: SAVE STUFFIE TO SERVER HERE var saveResult = await MegaService.Fetcher.Fetch("/api/product/UpdateExtra/", new { Product.Id, Extra = extra }); var saveBool = saveResult["Result"].ToObject <bool>(); var newExtra = saveResult["Extra"].ToObject <Extra>(); extra.Id = newExtra.Id; extra.Options.Clear(); newExtra.Options.ForEach(o => { extra.Options.Add(o); }); Toastr(saveBool); StateHasChanged(); } }
public override Task <string> GetStringAsync(Uri requestUri) { if (requestUri == null) { return(null); } string absoluteURI = string.Empty; if (requestUri.IsAbsoluteUri) { absoluteURI = requestUri.AbsoluteUri; } else { absoluteURI = BaseAddress + requestUri.PathAndQuery; } int id = TaskDispatcher.CreateTaskToDispatch(TaskDispatcher.CommonTask.StringToCSharp(), out Task <string> futurTask); RegisteredFunction.Invoke <string>("daddoon_jQuery_SendAsync", id, WebRequestMethods.Http.Get, absoluteURI, new RequestMetadata() { timeout = Timeout.TotalMilliseconds, headers = ParseHeaders(DefaultRequestHeaders) }, null); return(futurTask); }
protected override async Task OnInitAsync() { RegisteredFunction.Invoke <bool>("removeCss", "metronic"); MegaService.Util.InitComponents(); // MegaService.Util.InitAdminComponents(); Loaded = true; }
protected override async Task OnInitAsync() { RegisteredFunction.Invoke <bool>("removeCss", "outside"); var resultChart = await MegaService.Fetcher.Fetch("/api/Product/GetDashboardChart"); var resultPie = await MegaService.Fetcher.Fetch("/api/Product/GetDashboardPieOrder"); var catDis = resultPie["CategoryDistribution"].ToObject <ICollection <Category> >(); CategoryCount = resultPie["CountProduct"].ToObject <int>(); LatestOrders = resultPie["LastOrders"].ToObject <ICollection <OrderData> >(); EarningLastWeek = resultChart["EarningLastWeek"].ToObject <ICollection <double> >(); PercentageCash = resultChart["PercentageCash"].ToObject <double>(); PercentagePayPal = resultChart["PercentagePayPal"].ToObject <double>(); EarningThisMonth = resultChart["EarningThisMonth"].ToObject <double>(); EarningToday = resultChart["EarningToday"].ToObject <double>(); PreparePieChart(catDis); LoadChart(); var resultTops1 = await MegaService.Fetcher.Fetch("/api/Product/GetDashboardTopsProducts"); var resultTops2 = await MegaService.Fetcher.Fetch("/api/Product/GetDashboardTopsUsers"); TopUsers = resultTops2["TopUsers"].ToObject <ICollection <User> >(); TopProducts = resultTops1["TopProducts"].ToObject <ICollection <Product> >(); TopBrands = resultTops2["TopBrands"].ToObject <ICollection <Brand> >(); TopCategories = resultTops1["TopCategories"].ToObject <ICollection <Category> >(); }
protected void OnClickInternal(UIMouseEventArgs e) { if (!Enabled) { return; } var menuId = RegisteredFunction.Invoke <string>("BlazorContextMenu.MenuItem.GetMenuId", MenuItemElement); var menu = BlazorContextMenuHandler.GetMenu(menuId); var contextMenuTarget = menu.GetTarget(); var args = new MenuItemClickEventArgs(e, menuId, contextMenuTarget, MenuItemElement, this); if (Click != null) { Click(args); if (!args.IsCanceled) { BlazorContextMenuHandler.HideMenu(menuId); } } else if (ClickAsync != null) { ClickAsync(args).ContinueWith((t) => { if (!args.IsCanceled) { BlazorContextMenuHandler.HideMenu(menuId); } }); } }
/// <inheritdoc /> protected override async Task <HttpResponseMessage> SendAsync( HttpRequestMessage request, CancellationToken cancellationToken) { var tcs = new TaskCompletionSource <HttpResponseMessage>(); cancellationToken.Register(() => tcs.TrySetCanceled()); int id; lock (_idLock) { id = _nextRequestId++; _pendingRequests.Add(id, tcs); } RegisteredFunction.Invoke <object>( $"{typeof(BrowserHttpMessageHandler).FullName}.Send", id, request.Method.Method, request.RequestUri, request.Content == null ? null : await GetContentAsString(request.Content), SerializeHeadersAsJson(request)); return(await tcs.Task); }
private static Point GetOffsetPoint(HTMLElement element) { #if BLAZOR var rev = RegisteredFunction.Invoke <string>("getOffsetPoint", element.uid, Settings.IsFF).Split(','); return(new Point(Convert.ToInt32(rev[0]), Convert.ToInt32(rev[1]))); #else double top = 0; double left = 0; do { dynamic dym = element; if (Settings.IsFF) { var rec = element.getBoundingClientRect().As <ClientRect>(); top += rec.top; left += rec.left; //element = dym.offsetParent; element = element.parentElement; } else { top += dym.offsetTop; left += dym.offsetLeft; element = dym.offsetParent; } } while (element != null); return(new Point((int)left, (int)top)); #endif }
internal static void Init(BrowserRenderer br, string domElementSelector, Action onFinish) { if (br == null) { throw new NullReferenceException(); } br.AddComponent <BlazorXamarinExtensionScript>(domElementSelector); xamService = new BlazorXamarinDeviceService(); InternalHelper.SetTimeout(async() => { //Safety for detect if RuntimePlatform is a Mobile app or a Browser //First detect Browser context eligible for Xamarin, then returning the proper Xamarin RuntimePlatform try { if (RegisteredFunction.Invoke <bool>("BlazorXamarinRuntimeCheck")) { string resultRuntimePlatform = await xamService.GetRuntimePlatform(); RuntimePlatform = resultRuntimePlatform; } else { RuntimePlatform = Browser; } } catch (Exception ex) { RuntimePlatform = Browser; } onFinish?.Invoke(); }, 100); }
public void WatchLocation(Action <Location> watchCallback) { var requestId = Guid.NewGuid(); _watches.Add(requestId, watchCallback); RegisteredFunction.Invoke <object>("WatchLocation", requestId); }
public HTMLTableSectionElement createTHead() { return(new HTMLTableSectionElement() { uid = RegisteredFunction.Invoke <string>("createElement", "thead") }); }
public HTMLDocumentFragement createDocumentFragment() { return(new HTMLDocumentFragement() { uid = RegisteredFunction.Invoke <string>("createDocumentFragment") }); }
public void DispatchInit(object state) { if (IsEnabled) { RegisteredFunction.Invoke <object>(jsFunctionName, "init", state); } }
public Task Start() { TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>(); var callbackId = Guid.NewGuid().ToString(); Callbacks[callbackId] = new Action(() => tcs.SetResult(true)); var success = RegisteredFunction.Invoke <bool>(StartHubClientProxyMethod, _id, callbackId); if (!success) { Callbacks[callbackId] = null; throw new InvalidOperationException("Unable to register callback on the proxy"); } return(Task.WhenAny(tcs.Task, Task.Delay(5000).ContinueWith((t) => { if (!tcs.Task.IsCompleted) { return Task.FromException(new InvalidOperationException("Send timed out")); } else { return tcs.Task; } }))); }
public static void RemoveConnection(string connectionId) { if (_connections.ContainsKey(connectionId)) { _connections.Remove(connectionId); } RegisteredFunction.Invoke <object>(REMOVE_CONNECTION_METHOD, connectionId); }
protected override void OnAfterRender() { if (this._isFirstRender) { this._isFirstRender = false; RegisteredFunction.Invoke <bool>(ADD_RIPPLE_FUNCTION, this._MDCButton); } }
protected override async Task OnInitAsync() { RegisteredFunction.Invoke <bool>("initializeSignalR"); await LoadProduct(); RegisteredFunction.Invoke <bool>("tabs"); RegisteredFunction.Invoke <bool>("slick"); }
protected async Task DeleteBook() { RegisteredFunction.Invoke <bool>("hideDeleteDialog"); await Http.PostAsync("/Books/Delete/" + DeleteId, null); await LoadBooks(int.Parse(Page)); }
public HTMLDocumentElement() { uid = RegisteredFunction.Invoke <string>("document"); _body = new HTMLElement() { uid = RegisteredFunction.Invoke <string>("body") }; }
protected async Task DeleteBook() { RegisteredFunction.Invoke <bool>("hideDeleteDialog"); await BooksClient.DeleteBook(DeleteId); await LoadBooks(int.Parse(Page)); }
protected override void OnAfterRender() { if (this._isFirstRender) { this._isFirstRender = false; RegisteredFunction.Invoke <bool>(ATTACH_FUNCTION, this._MDCTopAppBar); } }
protected override void OnInit() { ReduxDevToolsInterop.IsEnabled = RegisteredFunction.Invoke <bool>("blazor-state.ReduxDevTools.create"); // We could send in the Store.GetSerializeState but it will be empty if (ReduxDevToolsInterop.IsEnabled) { ReduxDevToolsInterop.DispatchInit(""); } }
public async Task <Location> GetLocationAsync() { var tcs = new TaskCompletionSource <Location>(); var requestId = Guid.NewGuid(); _pendingRequests.Add(requestId, tcs); RegisteredFunction.Invoke <object>("GetLocation", requestId); return(await tcs.Task); }
static void Main(string[] args) { // Needed because the test server runs on a different port than the client app, // and we want to test sending/receiving cookies undering this config BrowserHttpMessageHandler.DefaultCredentials = FetchCredentialsOption.Include; // Signal to tests that we're ready RegisteredFunction.Invoke <object>("testReady"); }
protected override async Task OnInitAsync() { RegisteredFunction.Invoke <bool>("removeCss", "outside"); await LoadUsers(); // MegaService.Util.InitializeSignalR(); MegaService.Util.InitAdminComponents(); Loaded = true; }
public void SetItem <TItem>(string key, TItem item) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); } RegisteredFunction.Invoke <object>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key, JsonUtil.Serialize(item)); }
public TItem GetItem <TItem>(string key) { if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); } return(RegisteredFunction.Invoke <TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key)); }
protected override async Task OnInitAsync() { RegisteredFunction.Invoke <bool>("removeCss", "outside"); await LoadCategories(); await LoadAttributes(); RegisteredFunction.Invoke <bool>("enableCreateProductValidation", "outside"); MegaService.Util.InitializeSignalR(); MegaService.Util.InitAdminComponents(); }
private void LoadChart() { var categoryPieChartLabels = CategoryDistribution.Select(c => c.Name); var categoryPieChartData = CategoryDistribution.Select(c => c.ProductCount); var earningLastWeekLabels = GetRecentDates(); var earningLastWeekData = EarningLastWeek; RegisteredFunction.Invoke <bool>("initDashboard", categoryPieChartLabels, categoryPieChartData, earningLastWeekLabels, earningLastWeekData); }
public HTMLElement this[int index] // Indexer declaration { get { return(new HTMLElement() { uid = RegisteredFunction.Invoke <string>("element_childnode", owner.uid, index) }); } }
public void Dispatch <TRequest>(TRequest aRequest, object state) { if (IsEnabled) { Logger.LogDebug($"{GetType().Name}: {nameof(this.Dispatch)}"); Logger.LogDebug($"{GetType().Name}: aRequest.GetType().FullName:{aRequest.GetType().FullName}"); var reduxAction = new ReduxAction(aRequest); RegisteredFunction.Invoke <object>(jsFunctionName, reduxAction, state); } }