Type=Class Version=4.7 ModulesStructureVersion=1 B4J=true @EndOfDesignText@ 'Class module Sub Class_Globals Private ws As WebSocket 'ignore ' will hold our page information Public page As ABMPage ' page theme Private theme As ABMTheme ' to access the constants Private ABM As ABMaterial 'ignore ' name of the page, must be the same as the class name (case sensitive!) Public Name As String = "frmLogin" '<-------------------------------------------------------- IMPORTANT Private ABMPageId As String = "" ' your own variables Dim Origin As String = "http://localhost:51049" '<--- IMPORTANT for youtube videos. Set here your website address ' the download folder Public DownloadFolder As String = "/www/" & ABMShared.AppName & "/uploads/" Public DownloadMaxSize As String = 1000000*1024 Private myToastId As Int Private dbAction As Map Private ActiveID As Int private IsNew As Boolean Private Filter As String Private LastSort As String Private FilterCount As String Private OldValue As String Public MaxRows As Int End Sub 'Initializes the object. You can add parameters to this method if needed. Public Sub Initialize() ' build the local structure IMPORTANT! BuildPage End Sub Private Sub WebSocket_Connected (WebSocket1 As WebSocket) Log("Connected") ws = WebSocket1 ABMPageId = ABM.GetPageID(page, Name,ws) Dim session As HttpSession = ABM.GetSession(ws, ABMShared.SessionMaxInactiveIntervalSeconds) If session.IsNew Then session.Invalidate ABMShared.NavigateToPage(ws, "", "./") Return End If If ABMShared.NeedsAuthorization Then If session.GetAttribute2("IsAuthorized", "") = "" Then ABMShared.NavigateToPage(ws, ABMPageId, "../") Return End If End If ABM.UpdateFromCache(Me, ABMShared.CachedPages, ABMPageId, ws) If page.ComesFromPageCache Then ' when we have a page that is cached it doesn't matter if it comes or not from a new connection we serve the cached version. Log("Comes from cache") page.Refresh page.FinishedLoading Else If page.WebsocketReconnected Then Log("Websocket reconnected") ABMShared.NavigateToPage (ws, ABMPageId, "./" & page.PageHTMLName) Else ' when the client did not reconnected it doesn't matter if the session was new or not because this is the websockets first connection so no dynamic content in the browser ... we are going to serve the dynamic content... Log("Websocket first connection") page.Prepare ConnectPage End If End If Log(ABMPageId) End Sub Private Sub WebSocket_Disconnected() Log("Disconnected") Try ws.Session.RemoveAttribute("abmcallback") ws.Session.RemoveAttribute("abmdownloadfolder") ws.Session.RemoveAttribute("abmmaxsize") Catch Log(LastException.Message) End Try End Sub Sub Page_ParseEvent(Params As Map) Dim eventName As String = Params.Get("eventname") Dim eventParams() As String = Regex.Split(",",Params.Get("eventparams")) If eventName = "beforeunload" Then Log("preparing for url refresh") ABM.RemoveMeFromCache(ABMShared.CachedPages, ABMPageId) Return End If Dim caller As Object = page.GetEventHandler(Me, eventName) If caller = Me Then If SubExists(Me, eventName) Then Params.Remove("eventname") Params.Remove("eventparams") ' BEGIN NEW DRAGDROP If eventName = "page_dropped" Then page.ProcessDroppedEvent(Params) End If ' END NEW DRAGDROP Select Case Params.Size Case 0 CallSub(Me, eventName) Case 1 CallSub2(Me, eventName, Params.Get(eventParams(0))) Case 2 If Params.get(eventParams(0)) = "abmistable" Then Dim PassedTables As List = ABM.ProcessTablesFromTargetName(Params.get(eventParams(1))) CallSub2(Me, eventName, PassedTables) Else CallSub3(Me, eventName, Params.Get(eventParams(0)), Params.Get(eventParams(1))) End If Case Else ' cannot be called directly, to many param CallSub2(Me, eventName, Params) End Select End If Else CallSubDelayed2(caller, "ParseEvent", Params) 'ignore End If End Sub public Sub BuildTheme() ' start with the base theme defined in ABMShared theme.Initialize("PageTheme") theme.AddABMTheme(ABMShared.MyTheme) ' add additional themes specific for this page theme.Page.BackColor = ABM.COLOR_TRANSPARENT theme.Page.BackColorIntensity = ABM.INTENSITY_NORMAL theme.Page.ConnectedIndicatorColor = ABM.COLOR_GREEN theme.Page.ConnectedIndicatorColorIntensity = ABM.INTENSITY_NORMAL theme.Page.DisconnectedIndicatorColor = ABM.COLOR_RED theme.Page.DisconnectedIndicatorColorIntensity = ABM.INTENSITY_NORMAL theme.Page.PlaceHolderColor = ABM.COLOR_GREY theme.Page.PlaceHolderColorIntensity = ABM.INTENSITY_NORMAL theme.Page.searchmarkbackcolor = ABM.COLOR_YELLOW theme.Page.searchmarkbackcolorintensity = ABM.INTENSITY_NORMAL theme.Page.searchmarkforecolor = ABM.COLOR_BLACK theme.Page.searchmarkforecolorintensity = ABM.INTENSITY_NORMAL End Sub public Sub BuildPage() ' initialize the theme BuildTheme ' initialize this page using our theme page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme) page.ShowLoader=True page.ShowLoaderType=ABM.LOADER_TYPE_MANUAL page.SetLoaderHEARTBEAT(ABM.INTENSITY_NORMAL,ABM.INTENSITY_NORMAL,ABM.COLOR_WHITE,ABM.COLOR_RED,ABM.COLOR_GREY,ABM.COLOR_GREY,ABM.INTENSITY_NORMAL,ABM.INTENSITY_NORMAL) page.PageHTMLName = "frmLogin.html" page.PageTitle = "Ask TeenCoach" page.PageDescription = "" page.PageKeywords = "" page.PageSiteMapPriority = "0.50" page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_MONTHLY 'page.UseFontAwesome = False page.DisableBackButton = False page.UseGoogleAnalytics(ABMShared.TrackingID, Null) ' IMPORTANT Change this to your own TrackingID !!!!!!! page.GoogleMapsAPIExtras = ABMShared.GoogleMapsAPIExtras page.IsFixedFooter = False page.DisablePageReloadOnSwipeDown = True page.ShowConnectedIndicator = True page.PageLanguage = "en" page.AlwaysShowVerticalScrollBar = False MashPlugIns.NeedsAnimation(page) ' adding a navigation bar Dim sbtopimg As ABMImage sbtopimg.Initialize(page, "sbtopimg", "../images/logo.png?" & DateTime.Now, 1) sbtopimg.IsCircular = False sbtopimg.SetFixedSize(236, 49) page.NavigationBar.Initialize(page, "navBar", ABM.SIDEBAR_MANUAL_ALWAYSHIDE, "Ask {C:#000000}Teen{/C}{C:#993333}Coach{/C}", True, True, 330, 48, sbtopimg, ABM.COLLAPSE_ACCORDION, "nb") page.NavigationBar.SideBarSubItemsArrowUnicodeChar = "" page.NavigationBar.SideBarLogoHeight = 49 page.NavigationBar.TopBarDropDownConstrainWidth = True ' you must add at least ONE dummy item if you want to add items to the topbar in ConnectNaviagationBar page.NavigationBar.AddTopItem("DUMMY", "{NBSP}", "", "", False) ' you must add at least ONE dummy item if you want to add items to the sidebar ABMShared.AddSideBarItem(page,"DUMMY", "{NBSP}", "", "", "0", "0") page.ShowGridInfo = False ' create the page grid page.AddRows(1, True, "").AddCells12(1, "") page.AddRows(4, True, "").AddCells12(1, "") page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components ' add a error box template if the name is not entered page.AddModalSheetTemplate(ABMShared.BuildWrongInputModalSheet(page)) ' add a modal sheet template for a yes no msgbox page.AddModalSheetTemplate(ABMShared.BuildMsgBoxYesNo(page)) ' add a modal sheet template for a msgbox page.AddModalSheetTemplate(ABMShared.BuildMsgBox(page)) page.AddModalSheetTemplate(msLoginBuild) End Sub Private Sub msLoginBuild() As ABMModalSheet Dim msLogin As ABMModalSheet msLogin.Initialize(page, "msLogin", False, ABM.MODALSHEET_TYPE_NORMAL, "ms") msLogin.Size = ABM.MODALSHEET_SIZE_NORMAL msLogin.IsDismissible = False msLogin.IsTextSelectable = True msLogin.Content.AddRows(1,True,"").AddCells12(1, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 10, 0, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 0, 10, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 10, 10, ABM.VISIBILITY_ALL, "") msLogin.Content.AddRows(1,True,"").AddCellsOSMPV(1, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, ABM.VISIBILITY_ALL, "") msLogin.Header.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components msLogin.Content.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components msLogin.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components 'Add components to ModalSheet Dim lbllblCreateAccount As ABMLabel lbllblCreateAccount.Initialize(page, "lbllblCreateAccount", $"{C:#CC9966}{I}{B}Not a Member yet?{/B}{/I}{/C}"$, ABM.SIZE_PARAGRAPH, False, "centercontent") lbllblCreateAccount.Clickable = True lbllblCreateAccount.SetCursor(ABM.CURSOR_POINTING) lbllblCreateAccount.istextselectable = True lbllblCreateAccount.paddingleft = "" lbllblCreateAccount.paddingright = "" lbllblCreateAccount.paddingtop = "" lbllblCreateAccount.paddingbottom = "" lbllblCreateAccount.margintop = "" lbllblCreateAccount.marginbottom = "" lbllblCreateAccount.marginleft = "" lbllblCreateAccount.marginright = "" lbllblCreateAccount.supportemoji = False msLogin.Content.Cell(8,1).AddComponent(lbllblCreateAccount) msLogin.Content.Cell(8,1).UseTheme("centercontent") Dim txtemail As ABMInput txtemail.Initialize(page, "txtemail", ABM.INPUT_EMAIL, "Email Address", False, "") txtemail.Tag = "txtemail" msLogin.Content.Cell(4,1).AddComponent(txtemail) Dim txtpassword As ABMInput txtpassword.Initialize(page, "txtpassword", ABM.INPUT_PASSWORD, "Password", False, "") txtpassword.Tag = "txtpassword" msLogin.Content.Cell(5,1).AddComponent(txtpassword) Dim btnNext As ABMButton btnNext.InitializeRaised(page, "btnNext", "", "", "Next", "") btnNext.Tag = "btnNext" btnNext.UseFullCellWidth = True btnNext.Size = ABM.BUTTONSIZE_NORMAL btnNext.dropdownhidearrow = False btnNext.dropdownshowbelow = False btnNext.dropdownconstrainwidth = False msLogin.Content.Cell(7,1).AddComponent(btnNext) Dim lblheader As ABMLabel lblheader.Initialize(page, "lblheader", $"{B}To continue, let's verify it's you{/B}"$, ABM.SIZE_PARAGRAPH, False, "") lblheader.istextselectable = True lblheader.paddingleft = "" lblheader.paddingright = "" lblheader.paddingtop = "" lblheader.paddingbottom = "" lblheader.margintop = "" lblheader.marginbottom = "" lblheader.marginleft = "" lblheader.marginright = "" lblheader.supportemoji = False msLogin.Content.Cell(3,1).AddComponent(lblheader) Dim lbllblForgotPassword As ABMLabel lbllblForgotPassword.Initialize(page, "lbllblForgotPassword", $"{C:#CC9966}{I}Forgot Password?{/I}{/C}"$, ABM.SIZE_PARAGRAPH, False, "rightlabel") lbllblForgotPassword.Clickable = True lbllblForgotPassword.SetCursor(ABM.CURSOR_POINTING) lbllblForgotPassword.istextselectable = True lbllblForgotPassword.paddingleft = "" lbllblForgotPassword.paddingright = "" lbllblForgotPassword.paddingtop = "" lbllblForgotPassword.paddingbottom = "" lbllblForgotPassword.margintop = "" lbllblForgotPassword.marginbottom = "" lbllblForgotPassword.marginleft = "" lbllblForgotPassword.marginright = "" lbllblForgotPassword.supportemoji = False msLogin.Content.Cell(6,1).AddComponent(lbllblForgotPassword) Dim imglogo As ABMImage imglogo.Initialize(page, "imglogo", "../images/logo.png?"& DateTime.Now, 1) imglogo.Tag = "imglogo" imglogo.IsResponsive = False imglogo.IsCircular = False imglogo.IsClickable = False imglogo.IsMaterialBoxed = False msLogin.Content.Cell(2,1).AddComponent(imglogo) Return msLogin End Sub 'Get the contents of the modal sheet input components and save to a map Sub msLoginGetContents() As Map Dim pMap As Map pMap.Initialize Dim msLogin As ABMModalSheet msLogin = page.ModalSheet("msLogin") Dim txtemail As ABMInput = msLogin.Content.Component("txtemail") Dim txtpassword As ABMInput = msLogin.Content.Component("txtpassword") pMap.put("email", txtemail.Text) pMap.put("password", txtpassword.Text) Return pMap End Sub 'Get the contents of the modal sheet from GetContents and check validity Sub msLoginValidate(gMap As Map) As Boolean Dim msLogin As ABMModalSheet msLogin = page.ModalSheet("msLogin") Dim stxtemail As String stxtemail = gMap.get("email") If stxtemail = "null" Then stxtemail = "" If stxtemail.Length = 0 Then ABMShared.Warn(page,"Email Address cannot be blank. Please enter a value.") Dim txtemail As ABMInput = msLogin.Content.Component("txtemail") txtemail.SetFocus Return False End If Dim stxtpassword As String stxtpassword = gMap.get("password") If stxtpassword = "null" Then stxtpassword = "" If stxtpassword.Length = 0 Then ABMShared.Warn(page,"Password cannot be blank. Please enter a value.") Dim txtpassword As ABMInput = msLogin.Content.Component("txtpassword") txtpassword.SetFocus Return False End If Return True End Sub 'Set the contents of the modal page input components from map Sub msLoginSetContents(pMap As Map) Dim msLogin As ABMModalSheet msLogin = page.ModalSheet("msLogin") 'Get the page components to update 'Update computations 'Assign content to component values End Sub Private Sub msLoginSignIn() As Boolean 'define a map to hold the form contents Dim m as Map 'read the file contents to a map m = msLoginGetContents 'validate the form contents where required If msLoginValidate(m) = False Then Return False End If 'the form contents are ok, continue with the sign in process 'define the search criteria, fields must equal Dim w as Map Dim nk As String Dim nv As String w.Initialize For Each strKey As String In m.Keys nv = m.Get(strKey) nk = StrKey & "=" w.put(nk, nv) Next 'Get connection from current pool if MySQL/MSSQL Dim jSQL As SQL = ABMShared.SQLGet Dim UserMap As Map = ABMShared.SQLSelectRecordWhereMap(jSQL,"users", w) if UserMap.IsInitialized = False Then ABMShared.Warn(page,"The Sign In credentials you have provided are incorrect. Please check them and try to sign in again.") ws.Session.SetAttribute("IsAuthorized", "") Return False End If dim uactive As String = UserMap.get("useractive") ws.Session.SetAttribute("UserActive", uactive) If uactive = 0 Then ABMShared.Warn(page,"Your Profile is currently in-active, please contact the App Administrator.") Return False End If dim uemail As String = UserMap.get("email") ws.Session.SetAttribute("UserEmail", uemail) dim uname As String = UserMap.get("username") ws.Session.SetAttribute("authName", uname) dim uid As String = UserMap.get("id") ws.Session.SetAttribute("UserID", uid) dim utype As String = UserMap.get("groupid") ws.Session.SetAttribute("UserType", utype) ws.Session.SetAttribute("IsAuthorized", "true") ws.Session.SetAttribute("authType", "local") 'Build the permissions ABMShared.PermissionsL.Initialize ABMShared.Permissions.Initialize ABMShared.PermissionsL = ABMShared.SQLExecuteMaps(jSQL,"select * from GroupPermissions where groupid = ?", Array As String(utype)) For each permission As Map in ABMShared.PermissionsL dim spageName as string = permission.get("pagename") spageName = spageName.tolowercase ABMShared.Permissions.put(spageName,permission) Next 'Close the connection to the database ABMShared.SQLClose(jSQL) Return True End Sub Sub msLoginClear() Dim msLogin As ABMModalSheet msLogin = page.ModalSheet("msLogin") Dim txtemail As ABMInput = msLogin.Content.Component("txtemail") Dim txtpassword As ABMInput = msLogin.Content.Component("txtpassword") txtemail.Text = "" txtemail.Refresh txtpassword.Text = "" txtpassword.Refresh End Sub Sub msgyes_Clicked(Target As String) Dim msg As ABMModalSheet = page.ModalSheet("confirm") Dim msgyes As ABMButton = msg.Footer.Component("msgyes") dim strTag As String strTag = msgyes.Tag page.CloseModalSheet("confirm") End Sub Sub msgok_Clicked(Target As String) page.CloseModalSheet("msgbox") End Sub Sub msgno_Clicked(Target As String) page.CloseModalSheet("confirm") End Sub ' clicked on the navigation bar Sub Page_NavigationbarClicked(Action As String, Value As String) page.SaveNavigationBarPosition If Action = "LogOff" Then ABMShared.LogOff(page) Return End If Select Case Action.ToLowerCase End Select ABMShared.NavigateToPage(ws, ABMPageId, Value) End Sub Sub Page_FileUploaded(FileName As String, success As Boolean) myToastId = myToastId + 1 If success Then page.ShowToast("toast" & myToastId, "toastgreen", "File " & FileName & " uploaded!", 3000, False) Else page.ShowToast("toast" & myToastId, "toastred", "File " & FileName & " not uploaded!", 3000, False) End If Dim actualFile As String = File.combine(File.DirApp, DownloadFolder & FileName) page.ws.Flush ' IMPORTANT End Sub Sub Page_ToastDismissed(ToastId As String) End Sub Sub Page_ToastClicked(ToastId As String, Action As String) page.DismissToast(ToastId) End Sub Sub page_NavigationbarSearch(search As String) End Sub Public Sub ConnectPage() 'connect navigation bar ConnectNavigationBar 'add components for the page AdminAccess page.SetFontStack("arial,sans-serif") ' this page uses uploads, so needs some settings page.ws.session.SetAttribute("abmcallback", Me) page.ws.session.SetAttribute("abmdownloadfolder", DownloadFolder) page.ws.session.SetAttribute("abmmaxsize", DownloadMaxSize) page.ShowModalSheet("msLogin") page.Refresh ' IMPORTANT ' NEW, because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL page.FinishedLoading 'IMPORTANT page.RestoreNavigationBarPosition End Sub Sub Page_SignedOffSocialNetwork(Network As String, Extra As String) page.ws.Session.SetAttribute("UserID", "") page.ws.Session.SetAttribute("UserEmail", "") page.ws.Session.SetAttribute("authType", "") page.ws.Session.SetAttribute("authName", "") page.ws.Session.SetAttribute("IsAuthorized", "") ABMShared.NavigateToPage(ws,ABMPageId, "../") End Sub 'The label has been clicked Sub lbllblCreateAccount_Clicked(Target As String) ABMShared.NavigateToPage(ws, ABMPageId,"../frmCreateAccount/frmCreateAccount.html") End Sub 'An ABMButton has been clicked Sub btnNext_Clicked(Target As String) If msLoginSignIn = False Then Return ABMShared.NavigateToPage(ws, ABMPageId, "../frmMainMenu/frmMainMenu.html") End Sub 'The label has been clicked Sub lbllblForgotPassword_Clicked(Target As String) ABMShared.NavigateToPage(ws, ABMPageId,"../frmForgotPassword/frmForgotPassword.html") End Sub Sub AdminAccess() 'Get the usertype Dim UserType As String = ws.Session.GetAttribute2("UserType", "0") End Sub Sub ConnectNavigationBar() ' Clear the dummies we created in BuildNavigationBar page.NavigationBar.Clear 'connect the items in the navigation bar 'refresh the navigation bar page.NavigationBar.Refresh ' IMPORTANT End Sub Sub Page_MsgboxResult(returnName As String, result As String) End Sub Sub Page_InputboxResult(returnName As String, result As String) End Sub Sub Page_DebugConsole(message As String) Log("---> " & message) End Sub Sub Page_FirebaseAuthError(extra As String) End Sub Sub Page_FirebaseAuthStateChanged(IsLoggedIn As Boolean) End Sub Sub Page_FirebaseStorageError(jobID As String, extra As String) End Sub Sub Page_FirebaseStorageResult(jobID As String, extra As String) End Sub Sub Page_ModalSheetDismissed(ModalSheetName As String) End Sub Sub Page_NextContent(TriggerComponent As String) End Sub Sub page_CellClicked(Target As String, RowCell As String) 'Log(Target) End Sub Sub page_RowClicked(Target As String, Row As String) 'Log(Target) End Sub Sub Page_NativeResponse(jsonMessage As String) End Sub Sub Page_Dropped(Params As Map) If Params.Get("before") = "" Then Log("'" & Params.Get("component") & "' moved from " & Params.Get("source") & " to " & Params.Get("target")) Else Log("'" & Params.Get("component") & "' moved from " & Params.Get("source") & " to " & Params.Get("target") & " before component " & Params.Get("before")) End If End Sub