diff --git a/Build Automation.xojo_code b/Build Automation.xojo_code new file mode 100644 index 0000000..2d2333e --- /dev/null +++ b/Build Automation.xojo_code @@ -0,0 +1,171 @@ +#tag BuildAutomation + Begin BuildStepList Linux + Begin BuildProjectStep Build + End + Begin IDEScriptBuildStep DockerImage , AppliesTo = 2, Architecture = 1, Target = 0 + '************************************************************* + 'Xojo Web App 2 Docker - How to use with your Xojo-built .app? + '************************************************************* + '1. copy the folder 'scripts' to your project folder. + '2. Edit the file 'Dockerfile' in your favourite Text Editor. + ' 1. Look for the last line: CMD /app/CRCCalculatorWeb + ' Make sure the App Name is the same as in your Xojo + ' project in Build Settings -> Linux + ' 2. Look for the line: EXPOSE 80 + ' Make sure the App Name is the same as in your Xojo + ' project in Build Settings -> Shared: Build (Port) + '3. Create a PostBuild Copy File Step 'CopyDockerfile' + ' Copy the file 'resources/Dockerfile' to 'App Parent Folder' + '4. create a PostBuild Script, place it after the + ' build step and copy-and-paste this one. + '5. Add/Modify the Constant App.constDockerTag to fit your + ' Company/App + '6. Read the Comments in the PostBuild Script, + ' modify according to your needs. + '************************************************** + + '************************************************** + 'Setup Xojo Web App 2 Docker - Post Build Script + '************************************************** + '1. Read the comments in this PostBuild Script + '2. Edit the values according to your needs + '************************************************** + '3. If it's working for you: Do you like it? Does it help you? Has it saved you time and money? + ' You're welcome - it's free... + ' If you want to say thanks I appreciate a message or a small donation. + ' Contact: xojo@jo-tools.ch + ' PayPal: https://paypal.me/jotools + '************************************************** + + + '************************************************** + 'Requires Docker Installation + '************************************************** + 'Download, install and run Docker.app: + 'https://docs.docker.com/docker-for-mac/install/ + '************************************************** + + 'Configuration + '------------- + 'Docker Tag: will be used from App.constDockerTag + 'Docker Push (to Docker Hub): + Var bDockerPushEnabled As Boolean = False + Select Case PropertyValue("App.StageCode") + Case "0" 'Development + bDockerPushEnabled = False + Case "1" 'Alpha + bDockerPushEnabled = False + Case "2" 'Beta + bDockerPushEnabled = False + Case "3" 'Final + bDockerPushEnabled = True + End Select + + + '******************************************* + 'Xojo Web App 2 Docker - Let's go... + '******************************************* + 'you shouldn't need to modify anything below + '(but feel free to do so :-) + '******************************************* + If (Not TargetMacOS) Then + Print "The Post Build Script 'DockerImage' can only be run on macOS. You need to modify the Shell Commands if you're building on Linux or Windows." + Return + End If + + + 'Check Build Target + Select Case CurrentBuildTarget + Case 17 + 'Linux (Intel, 64Bit) + Else + Print "The only supported Build Target for the Post Build Script 'DockerImage' is: Linux, Intel 64Bit" + Return + End Select + + 'Check Build + If DebugBuild Then + Print "The Post Build Script 'DockerImage' should not be run for Debug Run's." + Return + End If + + 'Xojo Project Settings + Var sPROJECT_PATH As String = Trim(DoShellCommand("echo $PROJECT_PATH", 0)) + If Right(sPROJECT_PATH, 1) = "/" Then + 'no trailing / + sPROJECT_PATH = Mid(sPROJECT_PATH, 1, Len(sPROJECT_PATH)-1) + End If + Var sBUILD_LOCATION As String = ReplaceAll(CurrentBuildLocation, "\", "") 'don't escape Path + Var sBUILD_APPNAME As String = CurrentBuildAppName + + If (sPROJECT_PATH = "") Then + Print "Xojo Web App 2 Docker requires to get the Environment Variable $PROJECT_PATH from the Xojo IDE." + EndOfLine + EndOfLine + "Unfortunately, it's empty.... try again after re-launching the Xojo IDE and/or rebooting your machine." + Return + End If + + 'App Version -> used for Docker Image Tag + Var sAPP_VERSION As String = PropertyValue("App.MajorVersion") + "." + PropertyValue("App.MinorVersion") + "." + PropertyValue("App.BugVersion") + Select Case PropertyValue("App.StageCode") + Case "0" + sAPP_VERSION = sAPP_VERSION + "-dev" + Case "1" + sAPP_VERSION = sAPP_VERSION + "-alpha" + Case "2" + sAPP_VERSION = sAPP_VERSION + "-beta" + End Select + + 'DockerTag + Var sDOCKER_TAG As String = ConstantValue("App.constDockerTag") + If (sDOCKER_TAG = "") Then + Print "Xojo Web App 2 Docker requires the Constant: App.constDockerTag." + Return + End If + sDOCKER_TAG = sDOCKER_TAG + ":" + sAPP_VERSION + + 'Add DockerFile + Call DoShellCommand("cp """ + sPROJECT_PATH + "/scripts/Dockerfile"" """ + sBUILD_LOCATION + "/Dockerfile""", 0) + + + 'The Contents of Array will later be passed to + 'the ShellScript 'xojo2docker.sh', which does all the processing + ' + 'The order is important, so don't change anything here without + 'changing the ShellScript, too. + Var sShellArguments() As String + + 'Parameters required to create the Docker Image + sShellArguments.Add(sPROJECT_PATH) + sShellArguments.Add(sBUILD_LOCATION) + sShellArguments.Add(sBUILD_APPNAME) + sShellArguments.Add(sDOCKER_TAG) + sShellArguments.Add(If(bDockerPushEnabled, "yes", "no")) + + 'Make sure the ShellScript is executable: + Call DoShellCommand("chmod 755 """ + sPROJECT_PATH + "/scripts/xojo2docker.sh""", 0) + + If (Not DebugBuild) Then + 'Automate Terminal: + 'Pass ShellArguments to Script and execute it in Terminal.app + Call DoShellCommand("osascript -e 'tell application ""Terminal"" to activate'", 0) + Call DoShellCommand("osascript -e 'tell application ""Terminal"" to do script ""\""" + sPROJECT_PATH + "/scripts/xojo2docker.sh\"" \""" + Join(sShellArguments, "\"" \""") + "\""""'", 0) + Return 'see progress and errors in Terminal.app + End If + + End + End + Begin BuildStepList Mac OS X + Begin BuildProjectStep Build + End + Begin SignProjectStep Sign + DeveloperID= + End + End + Begin BuildStepList Windows + Begin BuildProjectStep Build + End + End + Begin BuildStepList Xojo Cloud + Begin BuildProjectStep Build + End + End +#tag EndBuildAutomation diff --git a/cubesql-webadmin.xojo_project b/cubesql-webadmin.xojo_project new file mode 100644 index 0000000..03d702c --- /dev/null +++ b/cubesql-webadmin.xojo_project @@ -0,0 +1,87 @@ +Type=Web2 +RBProjectVersion=2024.01 +MinIDEVersion=20200200 +OrigIDEVersion=20240100 +Folder=resources;resources;&h0000000035B107FF;&h0000000000000000;false +Folder=styles;styles;&h00000000139DBFFF;&h0000000000000000;false +Folder=webapp;webapp;&h0000000018D38FFF;&h0000000000000000;false +Folder=main;webapp/main;&h000000001D9447FF;&h0000000018D38FFF;false +WebView=LoginPage;webapp/main/LoginPage.xojo_code;&h000000005492FFFF;&h000000001D9447FF;false +WebView=CubeSQLAdminPage;webapp/main/CubeSQLAdminPage.xojo_code;&h000000004DEBB7FF;&h000000001D9447FF;false +Folder=dialogs;webapp/dialogs;&h0000000054A427FF;&h0000000018D38FFF;false +WebView=dlgRegisterServer;webapp/dialogs/dlgRegisterServer.xojo_code;&h000000000EEC17FF;&h0000000054A427FF;false +WebView=dlgDatabaseCreate;webapp/dialogs/dlgDatabaseCreate.xojo_code;&h0000000045C397FF;&h0000000054A427FF;false +WebView=dlgUserCreate;webapp/dialogs/dlgUserCreate.xojo_code;&h0000000064C14FFF;&h0000000054A427FF;false +WebView=dlgUserGroups;webapp/dialogs/dlgUserGroups.xojo_code;&h00000000347EFFFF;&h0000000054A427FF;false +WebView=dlgPrivilegeGrant;webapp/dialogs/dlgPrivilegeGrant.xojo_code;&h0000000022F4BFFF;&h0000000054A427FF;false +WebView=dlgCommonName;webapp/dialogs/dlgCommonName.xojo_code;&h0000000053B56FFF;&h0000000054A427FF;false +Folder=containers;webapp/containers;&h000000005859EFFF;&h0000000018D38FFF;false +Class=App;webapp/App.xojo_code;&h0000000055A03FFF;&h0000000018D38FFF;false +WebSession=Session;webapp/Session.xojo_code;&h0000000046C87FFF;&h0000000018D38FFF;false +Module=modCubeSQLAdmin;webapp/modCubeSQLAdmin.xojo_code;&h00000000097C9FFF;&h0000000018D38FFF;false +Class=cntBase;webapp/containers/cntBase.xojo_code;&h0000000041D557FF;&h000000005859EFFF;false +WebContainer=cntStatus;webapp/containers/cntStatus.xojo_code;&h000000000A45BFFF;&h000000005859EFFF;false +WebContainer=cntCommands;webapp/containers/cntCommands.xojo_code;&h000000002752C7FF;&h000000005859EFFF;false +WebContainer=cntRegistration;webapp/containers/cntRegistration.xojo_code;&h000000002FA707FF;&h000000005859EFFF;false +WebContainer=cntRegistrationAction;webapp/containers/cntRegistrationAction.xojo_code;&h000000000788EFFF;&h000000005859EFFF;false +WebContainer=cntDatabases;webapp/containers/cntDatabases.xojo_code;&h0000000040B4DFFF;&h000000005859EFFF;false +WebContainer=cntGroups;webapp/containers/cntGroups.xojo_code;&h0000000034036FFF;&h000000005859EFFF;false +WebContainer=cntUsers;webapp/containers/cntUsers.xojo_code;&h00000000700FF7FF;&h000000005859EFFF;false +WebContainer=cntPrivileges;webapp/containers/cntPrivileges.xojo_code;&h0000000018AA4FFF;&h000000005859EFFF;false +WebContainer=cntConsole;webapp/containers/cntConsole.xojo_code;&h000000004BD2DFFF;&h000000005859EFFF;false +WebContainer=cntClients;webapp/containers/cntClients.xojo_code;&h000000002140EFFF;&h000000005859EFFF;false +WebContainer=cntLog;webapp/containers/cntLog.xojo_code;&h000000002B1057FF;&h000000005859EFFF;false +MultiImage=icon_128;resources/icon_128.xojo_image;&h000000007294E7FF;&h0000000035B107FF;false +BuildSteps=Build Automation;Build Automation.xojo_code;&h000000001394FFFF;&h0000000000000000;false +ColorAsset=colTextKey;styles/colTextKey.xojo_color;&h000000005870AFFF;&h00000000139DBFFF;false +Module=modWebStyles;styles/modWebStyles.xojo_code;&h0000000002BE7FFF;&h00000000139DBFFF;false +DefaultWindow=LoginPage +MajorVersion=0 +MinorVersion=0 +SubVersion=1 +NonRelease=0 +Release=0 +InfoVersion=cubeSQL Web Admin +LongVersion=jo-tools.ch +ShortVersion=0.0.1 +WinCompanyName=example.com +WinInternalName=cubesqlwebadmin +WinProductName=cubeSQL Web Admin +WinFileDescription=cubeSQL Web Admin +AutoIncrementVersionInformation=False +BuildFlags=&h180 +BuildLanguage=&h0 +DebugLanguage=&h0 +Region= +WindowsName=cubeSQLWebAdmin.exe +MacCarbonMachName=cubeSQLWebAdmin +LinuxX86Name=cubeSQLWebAdmin +MacCreator= +MDI=0 +MDICaption= +DefaultEncoding=&h0 +AppIcon=cubesql-webadmin.xojo_resources;&h0 +OSXBundleID=ch.jo-tools.cubesqlwebadmin +DebuggerCommandLine=--CubeSQLHostname=localhost --CubeSQLPort=4440 --CubeSQLUsername=admin --CubeSQLPassword=admin +UseGDIPlus=False +UseBuildsFolder=True +HiDPI=True +DarkMode=True +CopyRedistNextToWindowsEXE=False +IncludePDB=False +WinUIFramework=False +IsWebProject=True +WebDebugPort=8080 +WebLivePort=80 +WebSecurePort=443 +WebProtocol=1 +WebHTMLHeader= +WebHostingIdentifier= +WebHostingAppName=cubeSQLWebAdmin +WebHostingDomain= +LinuxBuildArchitecture=1 +MacBuildArchitecture=4 +OptimizationLevel=6 +WindowsVersions={1f676c76-80e1-4239-95bb-83d0f6d0da78}|{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a} +WindowsRunAs=0 +MacOSMinimumVersion= diff --git a/cubesql-webadmin.xojo_resources b/cubesql-webadmin.xojo_resources new file mode 100644 index 0000000..ba0197a Binary files /dev/null and b/cubesql-webadmin.xojo_resources differ diff --git a/resources/icon_128.png b/resources/icon_128.png new file mode 100644 index 0000000..a3dfbf0 Binary files /dev/null and b/resources/icon_128.png differ diff --git a/resources/icon_128.xojo_image b/resources/icon_128.xojo_image new file mode 100644 index 0000000..13727c1 --- /dev/null +++ b/resources/icon_128.xojo_image @@ -0,0 +1,43 @@ +#tag MultiImage +Image icon_128 + #tag ImageRepresentation + SaveInfo = APHRcwIABwDAAwAAYm9va8ADAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApAIAAAQAAAADAwAAAAQAAAUAAAABAQAAVXNlcnMAAAAFAAAAAQEAAGp1ZXJnAAAACQAAAAEBAABEb2N1bWVudHMAAAAGAAAAAQEAAEdpdEh1YgAACAAAAAEBAABqby10b29scxQAAAABAQAAY3ViZXNxbC13ZWJhZG1pbi1kZXYJAAAAAQEAAHJlc291cmNlcwAAAAwAAAABAQAAaWNvbl8xMjgucG5nIAAAAAEGAAAQAAAAIAAAADAAAABEAAAAVAAAAGQAAACAAAAAlAAAAAgAAAAEAwAAnVMAAAAAAAAIAAAABAMAABCQBQAAAAAACAAAAAQDAABBkAUAAAAAAAgAAAAEAwAAUr8jAAAAAAAIAAAABAMAAJVf7wIAAAAACAAAAAQDAABaYd8FAAAAAAgAAAAEAwAAZ2LfBQAAAAAIAAAABAMAAGxi3wUAAAAAIAAAAAEGAADQAAAA4AAAAPAAAAAAAQAAEAEAACABAAAwAQAAQAEAAAgAAAAABAAAQcDiKhgAAAAYAAAAAQIAAAEAAAAAAAAAHwIAAAAAAAAfAgAAAAAAAAgAAAAEAwAABgAAAAAAAAAEAAAAAwMAAPUBAAAIAAAAAQkAAGZpbGU6Ly8vCwAAAAEBAABDYWRtaXVtIFNTRAAIAAAABAMAAABwxNjRAQAACAAAAAAEAABBxdYDwYAAACQAAAABAQAAOEFDQjE5RDItRjMxMi00MDExLTg2NzItMDM1NkE1NzM2NUEzGAAAAAECAACBAAAAAQAAAO8TAAABAAAA7xMAAAEAAAABAAAAAQEAAC8AAAAAAAAAAQUAADMAAAABAgAAZG5pYgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAcG5nPz8/PwAAAAAAAAAAAOQAAAD+////AQAAAAAAAAASAAAABBAAAKgAAAAAAAAABRAAAFABAAAAAAAAEBAAAIgBAAAAAAAAQBAAAHgBAAAAAAAAAiAAAFQCAAAAAAAABSAAAMQBAAAAAAAAECAAANQBAAAAAAAAESAAAAgCAAAAAAAAEiAAAOgBAAAAAAAAEyAAAPgBAAAAAAAAICAAADQCAAAAAAAAMCAAAGACAAAAAAAAAcAAAKgBAAAAAAAAEcAAACAAAAAAAAAAEsAAALgBAAAAAAAAENAAAAQAAAAAAAAAF/AAAJQAAAAAAAAAIvAAAGgCAAAAAAAAAAA= + FullPath = /Users/juerg/Documents/GitHub/jo-tools/cubesql-webadmin-dev/resources/icon_128.png + PartialPath = resources\icon_128.png + #tag ImageSpecification + Comment = + Device = 31 + HSize = 128.00 + Orientation = Any + Platform = 15 + PPI = 72 + VSize = 128.00 + #tag EndImageSpecification + #tag EndImageRepresentation + #tag ImageRepresentation + SaveInfo = APHRcwIABwDAAwAAYm9va8ADAAAAAAQQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAApAIAAAQAAAADAwAAAAQAAAUAAAABAQAAVXNlcnMAAAAFAAAAAQEAAGp1ZXJnAAAACQAAAAEBAABEb2N1bWVudHMAAAAGAAAAAQEAAEdpdEh1YgAACAAAAAEBAABqby10b29scxQAAAABAQAAY3ViZXNxbC13ZWJhZG1pbi1kZXYJAAAAAQEAAHJlc291cmNlcwAAAAwAAAABAQAAaWNvbl8yNTYucG5nIAAAAAEGAAAQAAAAIAAAADAAAABEAAAAVAAAAGQAAACAAAAAlAAAAAgAAAAEAwAAnVMAAAAAAAAIAAAABAMAABCQBQAAAAAACAAAAAQDAABBkAUAAAAAAAgAAAAEAwAAUr8jAAAAAAAIAAAABAMAAJVf7wIAAAAACAAAAAQDAABaYd8FAAAAAAgAAAAEAwAAZ2LfBQAAAAAIAAAABAMAAGti3wUAAAAAIAAAAAEGAADQAAAA4AAAAPAAAAAAAQAAEAEAACABAAAwAQAAQAEAAAgAAAAABAAAQcDiKhgAAAAYAAAAAQIAAAEAAAAAAAAAHwIAAAAAAAAfAgAAAAAAAAgAAAAEAwAABgAAAAAAAAAEAAAAAwMAAPUBAAAIAAAAAQkAAGZpbGU6Ly8vCwAAAAEBAABDYWRtaXVtIFNTRAAIAAAABAMAAABwxNjRAQAACAAAAAAEAABBxdYDwYAAACQAAAABAQAAOEFDQjE5RDItRjMxMi00MDExLTg2NzItMDM1NkE1NzM2NUEzGAAAAAECAACBAAAAAQAAAO8TAAABAAAA7xMAAAEAAAABAAAAAQEAAC8AAAAAAAAAAQUAADMAAAABAgAAZG5pYgAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAcG5nPz8/PwAAAAAAAAAAAOQAAAD+////AQAAAAAAAAASAAAABBAAAKgAAAAAAAAABRAAAFABAAAAAAAAEBAAAIgBAAAAAAAAQBAAAHgBAAAAAAAAAiAAAFQCAAAAAAAABSAAAMQBAAAAAAAAECAAANQBAAAAAAAAESAAAAgCAAAAAAAAEiAAAOgBAAAAAAAAEyAAAPgBAAAAAAAAICAAADQCAAAAAAAAMCAAAGACAAAAAAAAAcAAAKgBAAAAAAAAEcAAACAAAAAAAAAAEsAAALgBAAAAAAAAENAAAAQAAAAAAAAAF/AAAJQAAAAAAAAAIvAAAGgCAAAAAAAAAAA= + FullPath = /Users/juerg/Documents/GitHub/jo-tools/cubesql-webadmin-dev/resources/icon_256.png + PartialPath = resources\icon_256.png + #tag ImageSpecification + Comment = + Device = 31 + HSize = 128.00 + Orientation = Any + Platform = 15 + PPI = 144 + VSize = 128.00 + #tag EndImageSpecification + #tag EndImageRepresentation + #tag ImageRepresentation + #tag ImageSpecification + Comment = + Device = 31 + HSize = -1.00 + Orientation = Any + Platform = 15 + PPI = 216 + VSize = -1.00 + #tag EndImageSpecification + #tag EndImageRepresentation +End Image +#tag EndMultiImage diff --git a/resources/icon_256.png b/resources/icon_256.png new file mode 100644 index 0000000..8fe947b Binary files /dev/null and b/resources/icon_256.png differ diff --git a/scripts/Dockerfile b/scripts/Dockerfile new file mode 100644 index 0000000..b508564 --- /dev/null +++ b/scripts/Dockerfile @@ -0,0 +1,21 @@ +#BASE IMAGE +FROM ubuntu:22.04 + +#ENVIRONMENT +ENV CUBESQL_HOSTNAME=host.docker.internal +ENV CUBESQL_PORT=4430 +ENV CUBESQL_ENCRYPTION=AES256 +ENV CUBESQL_USERNAME=admin +ENV CUBESQL_PASSWORD= + +#INSTALL REQUIRED LIBRARIES +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update && apt-get install -y libunwind8 libglib2.0 libsoup2.4-1 + +#ADD APPLICATION TO DOCKER IMAGE +ADD / /app/ + +#EXPOSE PORT AND RUN APPLICATION +EXPOSE 80 +WORKDIR /app +CMD /app/cubeSQLWebAdmin \ No newline at end of file diff --git a/scripts/xojo2docker.sh b/scripts/xojo2docker.sh new file mode 100755 index 0000000..33076e0 --- /dev/null +++ b/scripts/xojo2docker.sh @@ -0,0 +1,138 @@ +#!/bin/sh +# + +# ************************************************************** +# How to use Xojo Web App 2 Docker's 'xojo2docker.sh'? +# ************************************************************** +# It's all being set up in the Xojo Post Build Script. +# You should not need to modify this Shell Script (unless you're +# going to extend it for more advanced applications of yours). +# +# And that's why you'll find all the infos and hints you need +# in the comments of the Xojo Post Build Script. +# ************************************************************** + + + +# get input +echo "Xojo2Docker: reading input variables..." +PROJECT_PATH=$1 +BUILD_LOCATION=$2 +BUILD_APPNAME=$3 +DOCKER_TAG=$4 +DOCKER_PUSH_ENABLED=$5 + +DOCKER_FILE="${BUILD_LOCATION}/Dockerfile" +DOCKER_IMAGE_FINAL="${BUILD_LOCATION}/${BUILD_APPNAME}.dockerimage.tgz" + + +# check input +echo "" +echo "Xojo2Docker: checking input variables..." +if [ -z "$PROJECT_PATH" ]; then + echo "Xojo2Docker ERROR: \$PROJECT_PATH is empty." + exit 8 +fi +if [ ! -d "${PROJECT_PATH}" ]; then + echo "Xojo2Docker ERROR: \${PROJECT_PATH} = ${PROJECT_PATH} directory doesn't exist." + exit 8 +fi +if [ -z "$BUILD_LOCATION" ]; then + echo "Xojo2Docker ERROR: \$BUILD_LOCATION is empty." + exit 8 +fi +if [ -z "$DOCKER_TAG" ]; then + echo "Xojo2Docker ERROR: \$DOCKER_TAG is empty." + exit 8 +fi +if [ -z "$DOCKER_PUSH_ENABLED" ]; then + echo "Xojo2Docker ERROR: \$DOCKER_PUSH_ENABLED is empty." + exit 8 +fi + +# set up a couple of things +echo "" +echo "Xojo2Docker: setting up a couple of things..." + +docker version > /dev/null +if [ $? -ne 0 ]; then + echo "Xojo2Docker ERROR: 'docker version' failed. Is Docker installed?" + exit 9 +fi + +if [ ! -f "$DOCKER_FILE" ]; then + echo "Xojo2Docker ERROR: Dockerfile doesn't exist: \$DOCKER_FILE" + exit 8 +fi + + +# change to our working directory +echo "" +echo "Xojo2Docker: change to our working directory" +if [ ! -d "${BUILD_LOCATION}" ]; then + echo "Xojo2Docker ERROR: \${BUILD_LOCATION} = ${BUILD_LOCATION} doesn't exist." + exit 8 +fi +cd "${BUILD_LOCATION}" + +echo "" +echo "Xojo2Docker: looking for the built .app" +if [ ! -f "./${BUILD_APPNAME}" ]; then + echo "Xojo2Docker ERROR: \${BUILD_APPNAME} = ${BUILD_APPNAME} doesn't exist." + exit 8 +fi + + +# clear out any old data +echo "" +echo "Xojo2Docker: clear out old data" +rm -rf "${DOCKER_IMAGE_FINAL}" + +sync + +# build docker image +echo "" +echo "Xojo2Docker: Build '$DOCKER_TAG'" + +docker image inspect $DOCKER_TAG > /dev/null 2>&1 +if [ $? -eq 0 ]; then + echo "Xojo2Docker ERROR: Image '$DOCKER_TAG' already exists" + echo "Xojo2Docker won't overwrite your Image. Remove it first yourself or change the Build's Version." + #docker image rm $DOCKER_TAG > /dev/null 2>&1 + exit 10 +fi + +docker build -t $DOCKER_TAG . +if [ $? -ne 0 ]; then + echo "Xojo2Docker ERROR: 'docker build -t $DOCKER_TAG .' failed." + exit 10 +fi + +echo "" +echo "Xojo2Docker: Save Docker Image '$DOCKER_TAG'" + +docker save $DOCKER_TAG | gzip > "${DOCKER_IMAGE_FINAL}" +if [ $? -ne 0 ]; then + echo "Xojo2Docker ERROR: Saving the Image for '$DOCKER_TAG' failed." + exit 10 +fi + +sync +sleep 1 +sync + +if [ "${DOCKER_PUSH_ENABLED}" = "yes" ]; then + echo "" + echo "Xojo2Docker: Push Docker Image '$DOCKER_TAG'" + docker push $DOCKER_TAG + if [ $? -ne 0 ]; then + echo "Xojo2Docker ERROR: 'docker push $DOCKER_TAG' failed." + exit 10 + fi +fi + + + +echo "" +echo "Xojo2Docker: It's all done." +exit 0 \ No newline at end of file diff --git a/styles/colTextKey.xojo_color b/styles/colTextKey.xojo_color new file mode 100644 index 0000000..66ce71c --- /dev/null +++ b/styles/colTextKey.xojo_color @@ -0,0 +1,9 @@ +#tag ColorGroup + CodeName=colTextKey + #tag Color + Type=1 + Platform=3 + Light=5E5E5E00 + Dark=C0C0C000 + #tag EndColor +#tag EndColorGroup diff --git a/styles/modWebStyles.xojo_code b/styles/modWebStyles.xojo_code new file mode 100644 index 0000000..a6aeeda --- /dev/null +++ b/styles/modWebStyles.xojo_code @@ -0,0 +1,98 @@ +#tag Module +Protected Module modWebStyles + #tag Method, Flags = &h0 + Sub ShowWithActionDanger(Extends dialog As WebMessageDialog) + dialog.Show + + Timer.CallLater(1, AddressOf ShowWithActionDangerTimerAction, dialog) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowWithActionDangerTimerAction(dialog As Variant) + If (Not (dialog IsA WebMessageDialog)) Then Return + + Var javaScript() As String + javaScript.Add("(function() {") + javaScript.Add(" let button = document.getElementById('" + WebMessageDialog(dialog).ControlID + "_action');") + javaScript.Add(" button.classList.remove('btn-primary');") + javaScript.Add(" button.classList.add('btn-danger');") + javaScript.Add("})();") + + WebMessageDialog(dialog).ExecuteJavaScript(String.FromArray(javaScript, "")) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Function StyleListboxKeyColumn() As WebStyle + Var style As New WebStyle + style.ForegroundColor = colTextKey + style.Value("text-align") = "right" + Return style + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Function StyleListboxTextAlignCenter() As WebStyle + Var style As New WebStyle + style.Value("text-align") = "center" + return style + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Function StyleListboxTextAlignCenterGreen() As WebStyle + Var style As New WebStyle + style.ForegroundColor = Color.Green + style.Value("text-align") = "center" + Return style + End Function + #tag EndMethod + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule diff --git a/webapp/App.xojo_code b/webapp/App.xojo_code new file mode 100644 index 0000000..2569566 --- /dev/null +++ b/webapp/App.xojo_code @@ -0,0 +1,29 @@ +#tag Class +Protected Class App +Inherits WebApplication + #tag Event + Sub Opening(args() As String) + // Store Launch Arguments for later + modCubeSQLAdmin.StoreLaunchArguments(args) + + End Sub + #tag EndEvent + + #tag Event + Function UnhandledException(error As RuntimeException) As Boolean + #Pragma unused error + + Break + + End Function + #tag EndEvent + + + #tag Constant, Name = constDockerTag, Type = String, Dynamic = False, Default = \"jotools/cubesql-webadmin", Scope = Private + #tag EndConstant + + + #tag ViewBehavior + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/webapp/Session.xojo_code b/webapp/Session.xojo_code new file mode 100644 index 0000000..4d35f62 --- /dev/null +++ b/webapp/Session.xojo_code @@ -0,0 +1,269 @@ +#tag Class +Protected Class Session +Inherits WebSession +#tag Session + interruptmessage=The connection to cubeSQL Admin has been interrupted.\r\nPlease wait a moment while attempting to reconnect. + disconnectmessage=You have been disconnected from cubeSQL Admin. + confirmmessage= + AllowTabOrderWrap=True + ColorMode=0 + SendEventsInBatches=False +#tag EndSession + #tag Method, Flags = &h0 + Function Login(loginDB As CubeSQLServer) As Boolean + If (loginDB = Nil) Then Return False + If (loginDB.IsConnected = False) Then Return False + + DB = loginDB + + Try + DB.ExecuteSQL("SET CLIENT TYPE TO 'cubeSQL Web Admin " + App.Version + "'") + + Catch err As DatabaseException + Return False + + Finally + Var cubeSqlAdminPage As New CubeSQLAdminPage + cubeSqlAdminPage.Show() + + Return True + + End Try + + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Logout() + If (DB <> Nil) Then + DB.Close + End If + + DB = Nil + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h0 + DB As CubeSQLServer + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Hashtag" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Identifier" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="LanguageCode" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="LanguageRightToLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="RemoteAddress" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScaleFactor" + Visible=false + Group="Behavior" + InitialValue="" + Type="Double" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="UserTimeout" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="URL" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="_baseurl" + Visible=false + Group="Behavior" + InitialValue="" + Type="string" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="DisconnectMessage" + Visible=true + Group="Behavior" + InitialValue="You have been disconnected from this application." + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="InterruptionMessage" + Visible=true + Group="Behavior" + InitialValue="We are having trouble communicating with the server. Please wait a moment while we attempt to reconnect." + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="_LastMessageTime" + Visible=false + Group="Behavior" + InitialValue="" + Type="Double" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="AllowTabOrderWrap" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ConfirmDisconnectMessage" + Visible=true + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Platform" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="IsDarkMode" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ClientHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ClientWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ColorMode" + Visible=false + Group="Behavior" + InitialValue="" + Type="WebSession.ColorModes" + EditorType="Enum" + #tag EnumValues + "0 - Auto" + "1 - Light" + "2 - Dark" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="UserPrefersDarkMode" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="SendEventsInBatches" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/webapp/containers/cntBase.xojo_code b/webapp/containers/cntBase.xojo_code new file mode 100644 index 0000000..6561207 --- /dev/null +++ b/webapp/containers/cntBase.xojo_code @@ -0,0 +1,268 @@ +#tag Class +Protected Class cntBase +Inherits WebContainer + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + Self.LockLeft = True + Self.LockRight = True + Self.LockTop = True + self.LockBottom = True + End Sub + #tag EndMethod + + + #tag Property, Flags = &h0 + Title As String + #tag EndProperty + + + #tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="300" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="300" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag EndViewBehavior +End Class +#tag EndClass diff --git a/webapp/containers/cntClients.xojo_code b/webapp/containers/cntClients.xojo_code new file mode 100644 index 0000000..16b2c70 --- /dev/null +++ b/webapp/containers/cntClients.xojo_code @@ -0,0 +1,426 @@ +#tag WebContainerControl +Begin cntBase cntClients + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 7 + ColumnWidths = "5%,15%,15%,15%,15%,18%,17%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 422 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Clients" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnRefresh + AllowAutoDisable= False + Cancel = False + Caption = "Refresh" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.RefreshButtons() + Self.ShowInfos() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Clients" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnRefresh.Enabled = True + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW CONNECTIONS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow(rs.Column("id").StringValue) + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 1) = rs.Column("address").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 2) = rs.Column("username").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 3) = rs.Column("connection_date").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 4) = rs.Column("last_activity").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 5) = rs.Column("database").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 6) = rs.Column("client_type").StringValue + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.HeaderAt(0) = "ID" + Me.HeaderAt(1) = "Address" + Me.HeaderAt(2) = "Username" + Me.HeaderAt(3) = "Connection Date" + Me.HeaderAt(4) = "Last Activity" + Me.HeaderAt(5) = "Database" + Me.HeaderAt(6) = "Client Type" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Descending + + For i As Integer = 1 To 6 + Me.ColumnSortTypeAt(i) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + next + + Me.RemoveAllRows + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRefresh + #tag Event + Sub Pressed() + Self.ShowInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntCommands.xojo_code b/webapp/containers/cntCommands.xojo_code new file mode 100644 index 0000000..30e5bc1 --- /dev/null +++ b/webapp/containers/cntCommands.xojo_code @@ -0,0 +1,375 @@ +#tag WebContainerControl +Begin cntBase cntCommands + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 3 + ColumnWidths = "60%, 20%, 20%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 500 + HighlightSortedColumn= False + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Commands" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Commands" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW COMMANDS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow(rs.Column("command").StringValue) + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 1) = rs.Column("context").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 2) = rs.Column("privilege").StringValue + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.HeaderAt(0) = "Command" + Me.HeaderAt(1) = "Context" + Me.HeaderAt(2) = "Privilege" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Ascending + + Me.ColumnSortTypeAt(1) = WebListBox.SortTypes.Unsortable + Me.ColumnSortDirectionAt(1) = WebListbox.SortDirections.None + + Me.ColumnSortTypeAt(2) = WebListBox.SortTypes.Unsortable + Me.ColumnSortDirectionAt(2) = WebListbox.SortDirections.None + + Me.RemoveAllRows + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntConsole.xojo_code b/webapp/containers/cntConsole.xojo_code new file mode 100644 index 0000000..f004d20 --- /dev/null +++ b/webapp/containers/cntConsole.xojo_code @@ -0,0 +1,648 @@ +#tag WebContainerControl +Begin cntBase cntConsole + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 1 + ColumnWidths = "" + ControlID = "" + Enabled = True + HasHeader = False + Height = 319 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No SQL SELECT executed yet" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnExecute + AllowAutoDisable= False + Cancel = False + Caption = "Execute" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 4 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebLabel labDatabase + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 2 + TabStop = True + Text = "Database:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 442 + Underline = False + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstDatabase + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 128 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 400 + _mPanelIndex = -1 + End + Begin WebTextArea edtCommand + AllowReturnKey = True + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + Height = 100 + Hint = "SQL Command" + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = False + LockVertical = False + MaximumCharactersAllowed= 0 + ReadOnly = False + Scope = 2 + TabIndex = 1 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 334 + Visible = True + Width = 710 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Closed() + Try + Session.DB.ExecuteSQL("CLEAR CURRENT DATABASE") + + Catch err As DatabaseException + + End Try + + End Sub + #tag EndEvent + + #tag Event + Sub Opening() + self.Clear() + Self.RefreshButtons() + + ebOpened = True + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub ActionExecute() + Var isquery As Boolean = False + Var rs As RowSet + + Try + + Var sql As String = edtCommand.Text.Trim + Var fword As String = sql.NthField(" ", 1).Trim.Lowercase + + + If (fword = "select") Or (fword = "show") Then + isquery = True + ElseIf (fword = "engine") Then + If sql.Contains(" select ", ComparisonOptions.CaseInsensitive) Then isquery = True + ElseIf (fword = "pragma") Then + If (sql.IndexOf("=") = 0) Then isquery = True + End If + + If isquery Then + rs = Session.DB.SelectSQL(sql) + lstInfos.NoRowsMessage = "No Records from SELECT SQL" + Else + Session.DB.ExecuteSQL(sql) + lstInfos.NoRowsMessage = "EXECUTE SQL successful" + End If + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = If(isquery, "SELECT SQL", "EXECUTE SQL") + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not execute " + dialog.Title + " command." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + rs = Nil + If isquery Then + lstInfos.NoRowsMessage = "SELECT SQL Error" + Else + lstInfos.NoRowsMessage = "EXECUTE SQL Error" + End If + + Finally + Me.ShowInfos(rs) + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Clear() + lstInfos.RemoveAllRows + lstInfos.HasHeader = False + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Console" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnExecute.Enabled = (edtCommand.Text.Trim <> "") + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos(rs As RowSet) + Me.Clear + + Try + If (rs = Nil) Then Return + + lstInfos.HasHeader = True + + lstInfos.ColumnCount = rs.ColumnCount + For i As Integer = rs.ColumnCount - 1 DownTo 0 + lstInfos.HeaderAt(i) = rs.ColumnAt(i).Name + lstInfos.ColumnSortTypeAt(i) = WebListBox.SortTypes.Sortable + lstInfos.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + Next + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow("") + + For i As Integer = rs.ColumnCount - 1 DownTo 0 + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, i) = rs.ColumnAt(i).StringValue + Next + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private ebOpened As Boolean + #tag EndProperty + + +#tag EndWindowCode + +#tag Events btnExecute + #tag Event + Sub Pressed() + Self.ActionExecute() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstDatabase + #tag Event + Sub Opening() + Me.RemoveAllRows + Me.AddRow "- NONE -" + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW DATABASES") + + If (rs <> Nil) Then + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + Me.AddRow(rs.Column("databasename").StringValue) + Me.RowTagAt(Me.LastAddedRowIndex) = rs.Column("databasename").StringValue + rs.MoveToNextRow + Wend + End If + + rs.Close + End If + + Catch DatabaseException + + Finally + Me.SelectedRowIndex = 0 + + End Try + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebOpened) Then Return + + Try + If (Me.SelectedRowIndex < 1) Then + Session.DB.ExecuteSQL("CLEAR CURRENT DATABASE") + Else + Session.DB.ExecuteSQL("USE DATABASE '" + Me.SelectedRowText + "'") + End If + + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Change database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not change database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Self.Clear() + + End Try + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtCommand + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntDatabases.xojo_code b/webapp/containers/cntDatabases.xojo_code new file mode 100644 index 0000000..127af69 --- /dev/null +++ b/webapp/containers/cntDatabases.xojo_code @@ -0,0 +1,953 @@ +#tag WebContainerControl +Begin cntBase cntDatabases + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 5 + ColumnWidths = "10%,50%,10%,20%,10%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 422 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Databases" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 1 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnDrop + AllowAutoDisable= False + Cancel = False + Caption = "Drop" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 4 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnStop + AllowAutoDisable= False + Cancel = False + Caption = "Stop" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 5 + Left = 522 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 4 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCreate + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnStart + AllowAutoDisable= False + Cancel = False + Caption = "Start" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 3 + Left = 414 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgDatabaseCreate dlgCreate + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebButton btnRename + AllowAutoDisable= False + Cancel = False + Caption = "Rename" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 2 + Left = 306 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgCommonName dlgRename + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 60 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 7 + TabStop = True + Tooltip = "" + Top = 60 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebMessageDialog dlgDrop + ControlID = "" + Enabled = True + Explanation = "" + Index = -2147483648 + Indicator = 0 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Message = "" + Scope = 2 + Title = "" + Tooltip = "" + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub ActionCreate() + dlgCreate.Show() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionCreateButtonPressed(Name As String, Key As String, Encoding As String) As Boolean + If (Name = "") Then Return False + + Try + + Var sqlCreateDb As String = "CREATE DATABASE " + "'" + Name + "'" + If (Key <> "") Then sqlCreateDb = sqlCreateDb + " WITH KEY " + "'" + Key + "'" + If (Encoding <> "UTF-8") Then sqlCreateDb = sqlCreateDb + " WITH ENCODING " + Encoding + + Session.DB.ExecuteSQL(sqlCreateDb) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Create Database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not create database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDrop() + Var dbRowTag As Dictionary = Me.GetSelectedDbRowTag() + If (dbRowTag = Nil) Or (dbRowTag.Lookup("databasename", "") = "") Then Return + + + dlgDrop.Title = "Drop Database" + dlgDrop.Indicator = Indicators.Danger + dlgDrop.ActionButton.Caption = "Drop" + dlgDrop.CancelButton.Visible = True + dlgDrop.Message = "Are you sure you want to drop database '" + dbRowTag.Lookup("databasename", "") + "'?" + dlgDrop.Explanation = "This action cannot be undone." + + esActionDatabasename = dbRowTag.Lookup("databasename", "") + + dlgDrop.ShowWithActionDanger() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDropButtonPressed(obj As WebMessageDialog, button As WebMessageDialogButton) + Var sDropDatabasename As String = esActionDatabasename + esActionDatabasename = "" + + If (button <> obj.ActionButton) Then Return + If (sDropDatabasename = "") Then Return + + Try + Session.DB.ExecuteSQL("DROP DATABASE '" + sDropDatabasename + "' IF EXISTS") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Drop Database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not drop database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionRename() + Var dbRowTag As Dictionary = Me.GetSelectedDbRowTag() + If (dbRowTag = Nil) Or (dbRowTag.Lookup("databasename", "") = "") Then Return + + Var databasename As String = dbRowTag.Lookup("databasename", "") + esActionDatabasename = databasename + + dlgRename.Show("Rename Database", "Name", "Rename", Indicators.Primary, databasename) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionRenameButtonPressed(Name As String) As Boolean + If (esActionDatabasename = "") Then Return False + If (Name = "") Then Return False + If (esActionDatabasename = Name) Then Return False + + Try + + Session.DB.ExecuteSQL("RENAME DATABASE '" + esActionDatabasename + "' TO " + "'" + Name + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Rename Database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not rename database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionStart() + Var dbRowTag As Dictionary = Me.GetSelectedDbRowTag() + If (dbRowTag = Nil) Then Return + + Try + Session.DB.ExecuteSQL("START DATABASE '" + dbRowTag.Lookup("databasename", "") + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Start database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not start database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionStop() + Var dbRowTag As Dictionary = Me.GetSelectedDbRowTag() + If (dbRowTag = Nil) Then Return + + Try + Session.DB.ExecuteSQL("STOP DATABASE '" + dbRowTag.Lookup("databasename", "") + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Stop database" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not stop database." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Databases" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetSelectedDbRowTag() As Dictionary + If (lstInfos.SelectedRowIndex < 0) Then Return Nil + + If (lstInfos.RowTagAt(lstInfos.SelectedRowIndex) IsA Dictionary) Then + Var dbRowTag As Dictionary = lstInfos.RowTagAt(lstInfos.SelectedRowIndex) + Return dbRowTag + End If + + Return Nil + + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var bRename, bStart, bStop, bDrop As Boolean + + If (lstInfos.SelectedRowIndex >= 0) Then + If (lstInfos.RowTagAt(lstInfos.SelectedRowIndex) IsA Dictionary) Then + Var dbRowTag As Dictionary = lstInfos.RowTagAt(lstInfos.SelectedRowIndex) + + bRename = True + bStart = dbRowTag.Lookup("stopped", False) = True + bStop = (Not bStart) + bDrop = True + + End If + End If + + If (btnRename.Enabled <> bRename) Then btnRename.Enabled = bRename + If (btnStart.Enabled <> bStart) Then btnStart.Enabled = bStart + If (btnStop.Enabled <> bStop) Then btnStop.Enabled = bStop + If (btnDrop.Enabled <> bDrop) Then btnDrop.Enabled = bDrop + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshInfos(selectDatabasename As String = "") + If (selectDatabasename = "") Then + Var dbRowTag As Dictionary = Me.GetSelectedDbRowTag() + If (dbRowTag <> Nil) Then + selectDatabasename = dbRowTag.Lookup("databasename", "") + End If + End If + + Me.ShowInfos() + + If (selectDatabasename = "") Then + Me.RefreshButtons() + Return + End If + + For i As Integer = lstInfos.LastRowIndex DownTo 0 + If (lstInfos.CellTextAt(i, 1) <> selectDatabasename) Then Continue + + lstInfos.SelectedRowIndex = i + Exit 'Loop + Next + + Me.RefreshButtons() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW DATABASES WITH DETAILS") + If (rs = Nil) Then Return + + Var styleCenter As WebStyle = StyleListboxTextAlignCenter() + Var styleCenterGreen As WebStyle = StyleListboxTextAlignCenterGreen() + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow("") + + Var icon As WebPicture + If rs.Column("stopped").BooleanValue Then + icon = WebPicture.BootstrapIcon("stop-circle-fill", Color.Orange) + Else + If rs.Column("available").BooleanValue Then + icon = WebPicture.BootstrapIcon("check-circle-fill", Color.Green) + Else + icon = WebPicture.BootstrapIcon("exclamation-circle-fill", Color.Red) + End If + End If + + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 0) = New WebListboxImageRenderer(icon.URL, True) + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 1) = rs.Column("databasename").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 2) = New WebListBoxStyleRenderer(styleCenter, If(rs.Column("locked").IntegerValue > 0, "yes", "no")) + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 3) = rs.Column("lockowner").StringValue + If rs.Column("encrypted").BooleanValue Then + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 4) = New WebListBoxStyleRenderer(styleCenterGreen, "yes") + Else + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 4) = New WebListBoxStyleRenderer(styleCenter, "no") + End If + + Var dbRowTag As New Dictionary + dbRowTag.Value("stopped") = rs.Column("stopped").BooleanValue + dbRowTag.Value("available") = rs.Column("available").BooleanValue + dbRowTag.Value("databasename") = rs.Column("databasename").StringValue + + lstInfos.RowTagAt(lstInfos.LastAddedRowIndex) = dbRowTag + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private esActionDatabasename As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.ExecuteJavaScript("$('#" + Me.ControlID + "').addClass('listboxDbHeaderAlignment')") + + Me.HeaderAt(0) = "Status" + Me.HeaderAt(1) = "Name" + Me.HeaderAt(2) = "Locked" + Me.HeaderAt(3) = "Lock Owner" + Me.HeaderAt(4) = "Encrypted" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Unsortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.None + + Me.ColumnSortTypeAt(1) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(1) = WebListbox.SortDirections.Ascending + + Me.ColumnSortTypeAt(2) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(2) = WebListbox.SortDirections.None + Me.ColumnSortTypeAt(3) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(3) = WebListbox.SortDirections.None + Me.ColumnSortTypeAt(4) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(4) = WebListbox.SortDirections.None + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(rows() As Integer) + #Pragma unused rows + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnDrop + #tag Event + Sub Pressed() + Self.ActionDrop() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnStop + #tag Event + Sub Pressed() + Self.ActionStop() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCreate + #tag Event + Sub Pressed() + Self.ActionCreate() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnStart + #tag Event + Sub Pressed() + Self.ActionStart() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgCreate + #tag Event + Function DatabaseCreateAction(Name As String, Key As String, Encoding As String) As Boolean + Return Self.ActionCreateButtonPressed(Name, Key, Encoding) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events btnRename + #tag Event + Sub Pressed() + Self.ActionRename() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgRename + #tag Event + Function NameAction(Name As String) As Boolean + Return Self.ActionRenameButtonPressed(Name) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events dlgDrop + #tag Event + Sub ButtonPressed(button As WebMessageDialogButton) + Self.ActionDropButtonPressed(Me, button) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntGroups.xojo_code b/webapp/containers/cntGroups.xojo_code new file mode 100644 index 0000000..ae8c3a9 --- /dev/null +++ b/webapp/containers/cntGroups.xojo_code @@ -0,0 +1,857 @@ +#tag WebContainerControl +Begin cntBase cntGroups + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 3 + ColumnWidths = "30%, 10%, 60%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 422 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Groups" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 1 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnDrop + AllowAutoDisable= False + Cancel = False + Caption = "Drop" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 4 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnRename + AllowAutoDisable= False + Cancel = False + Caption = "Rename" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 2 + Left = 522 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCreate + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgCommonName dlgCreate + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin dlgCommonName dlgRename + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 6 + TabStop = True + Tooltip = "" + Top = 40 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebThread thrDetails + DebugIdentifier = "" + Index = -2147483648 + LockedInPosition= False + Priority = 5 + Scope = 2 + StackSize = 0 + ThreadID = 0 + ThreadState = 0 + End + Begin WebMessageDialog dlgDrop + ControlID = "" + Enabled = True + Explanation = "" + Index = -2147483648 + Indicator = 0 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Message = "" + Scope = 2 + Title = "" + Tooltip = "" + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub ActionCreate() + dlgCreate.Show("Create Group", "Name", "Create") + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionCreateButtonPressed(Name As String) As Boolean + If (Name = "") Then Return False + + Try + + Session.DB.ExecuteSQL("CREATE GROUP " + "'" + Name + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Create Group" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not create group." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDrop() + Var groupname As String = Me.GetSelectedGroupname() + If (groupname = "") Then Return + + dlgDrop.Title = "Drop Group" + dlgDrop.Indicator = Indicators.Danger + dlgDrop.ActionButton.Caption = "Drop" + dlgDrop.CancelButton.Visible = True + dlgDrop.Message = "Are you sure you want to drop group '" + groupname + "'?" + dlgDrop.Explanation = "This action cannot be undone." + + esActionGroupname = groupname + + dlgDrop.ShowWithActionDanger() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDropButtonPressed(obj As WebMessageDialog, button As WebMessageDialogButton) + Var sDropGroupname As String = esActionGroupname + esActionGroupname = "" + + If (button <> obj.ActionButton) Then Return + If (sDropGroupname = "") Then Return + + Try + Session.DB.ExecuteSQL("DROP GROUP '" + sDropGroupname) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Drop Group" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not drop group." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionRename() + Var groupname As String = Me.GetSelectedGroupname() + If (groupname = "") Then Return + + esActionGroupname = groupname + + dlgRename.Show("Rename Group", "Name", "Rename", Indicators.Primary, groupname) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionRenameButtonPressed(Name As String) As Boolean + If (esActionGroupname = "") Then Return False + If (Name = "") Then Return False + If (esActionGroupname = Name) Then Return False + + Try + + Session.DB.ExecuteSQL("RENAME GROUP '" + esActionGroupname + "' TO " + "'" + Name + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Rename Group" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not rename group." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Close() + Try + thrDetails.Stop + Catch err As RuntimeException + + End Try + + Super.Close() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Groups" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetSelectedGroupname() As String + If (lstInfos.SelectedRowIndex < 0) Then Return "" + return lstInfos.CellTextAt(lstInfos.SelectedRowIndex, 0) + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var bRename, bDrop As Boolean + + Var groupname As String = Me.GetSelectedGroupname() + If (groupname <> "admin") And (groupname <> "") Then + bRename = True + bDrop = True + End If + + If (btnRename.Enabled <> bRename) Then btnRename.Enabled = bRename + If (btnDrop.Enabled <> bDrop) Then btnDrop.Enabled = bDrop + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshInfos(selectGroupname As String = "") + If (selectGroupname = "") Then + selectGroupname = me.GetSelectedGroupname() + End If + + Me.ShowInfos() + + If (selectGroupname = "") Then + Me.RefreshButtons() + Return + End If + + For i As Integer = lstInfos.LastRowIndex DownTo 0 + If (lstInfos.CellTextAt(i, 0) <> selectGroupname) Then Continue + + lstInfos.SelectedRowIndex = i + Exit 'Loop + Next + + Me.RefreshButtons() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowDetails() + Var styleCenter As WebStyle = StyleListboxTextAlignCenter() + + Var iLast As Integer = lstInfos.LastRowIndex + For i As Integer = 0 To iLast + Var groupname As String = lstInfos.CellTextAt(i, 0) + If (groupname = "") Then Continue + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW USERS IN GROUP '" + groupname + "'") + + Var iCount As Integer = 0 + Var sUsers() As String + + If (rs <> Nil) Then + iCount = rs.RowCount + + If (iCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + sUsers.Add(rs.Column("username").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + End If + + lstInfos.CellTextAt(i, 1) = New WebListBoxStyleRenderer(styleCenter, iCount.ToString) + lstInfos.CellTextAt(i, 2) = String.FromArray(sUsers, ", ") + + Catch DatabaseException + + End Try + + Next + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Try + thrDetails.Stop + Catch err As RuntimeException + + End Try + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow(rs.Column("groupname").StringValue) + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + Finally + + Try + thrDetails.Start + Catch err As RuntimeException + + End Try + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private esActionGroupname As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.ExecuteJavaScript("$('#" + Me.ControlID + "').addClass('listboxGroupsHeaderAlignment')") + + Me.HeaderAt(0) = "Groupname" + Me.HeaderAt(1) = "#" + Me.HeaderAt(2) = "Users" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Ascending + + For i As Integer = 1 To 2 + Me.ColumnSortTypeAt(i) = WebListBox.SortTypes.Unsortable + Me.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + Next + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(rows() As Integer) + #Pragma unused rows + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnDrop + #tag Event + Sub Pressed() + Self.ActionDrop() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRename + #tag Event + Sub Pressed() + Self.ActionRename() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCreate + #tag Event + Sub Pressed() + Self.ActionCreate() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgCreate + #tag Event + Function NameAction(Name As String) As Boolean + Return Self.ActionCreateButtonPressed(Name) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events dlgRename + #tag Event + Function NameAction(Name As String) As Boolean + Return Self.ActionRenameButtonPressed(Name) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events thrDetails + #tag Event + Sub Run() + Try + Self.ShowDetails() + Catch err As RuntimeException + End Try + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgDrop + #tag Event + Sub ButtonPressed(button As WebMessageDialogButton) + Self.ActionDropButtonPressed(Me, button) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntLog.xojo_code b/webapp/containers/cntLog.xojo_code new file mode 100644 index 0000000..07f24a0 --- /dev/null +++ b/webapp/containers/cntLog.xojo_code @@ -0,0 +1,497 @@ +#tag WebContainerControl +Begin cntBase cntLog + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 6 + ColumnWidths = "15%,10%,25%,15%,18%,17%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 422 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Log entries" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnRefresh + AllowAutoDisable= False + Cancel = False + Caption = "Refresh" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebLabel labLogNumberOfEntries + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 1 + TabStop = True + Text = "Number of Log entries:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 442 + Underline = False + Visible = True + Width = 197 + _mPanelIndex = -1 + End + Begin WebTextField edtLogNumberOfEntries + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 3 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + Left = 225 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + MaximumCharactersAllowed= 0 + ReadOnly = False + Scope = 2 + TabIndex = 2 + TabStop = True + Text = "50" + TextAlignment = 3 + Tooltip = "" + Top = 442 + Visible = True + Width = 120 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.RefreshButtons() + Self.ShowInfos() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Log" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnRefresh.Enabled = (edtLogNumberOfEntries.Text.ToInteger > 0) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + Var numLogEntries As Integer = edtLogNumberOfEntries.Text.ToInteger + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW LAST " + numLogEntries.ToString + " ROWS FROM Log ORDER DESC") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow(rs.Column("datetime").StringValue) + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 1) = rs.Column("operation").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 2) = rs.Column("description").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 3) = rs.Column("address").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 4) = rs.Column("username").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 5) = rs.Column("database").StringValue + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.HeaderAt(0) = "DateTime" + Me.HeaderAt(1) = "Operation" + Me.HeaderAt(2) = "Description" + Me.HeaderAt(3) = "Address" + Me.HeaderAt(4) = "Username" + Me.HeaderAt(5) = "Database" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Descending + + For i As Integer = 1 To 5 + Me.ColumnSortTypeAt(i) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + next + + Me.RemoveAllRows + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRefresh + #tag Event + Sub Pressed() + Self.ShowInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtLogNumberOfEntries + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntPrivileges.xojo_code b/webapp/containers/cntPrivileges.xojo_code new file mode 100644 index 0000000..10e4a9a --- /dev/null +++ b/webapp/containers/cntPrivileges.xojo_code @@ -0,0 +1,1041 @@ +#tag WebContainerControl +Begin cntBase cntPrivileges + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 4 + ColumnWidths = "30%, 15%, 25%, 30%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 292 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Privileges" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 1 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnRevoke + AllowAutoDisable= False + Cancel = False + Caption = "Revoke" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 4 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnGrant + AllowAutoDisable= False + Cancel = False + Caption = "Grant" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgPrivilegeGrant dlgGrant + ControlCount = 0 + ControlID = "" + Enabled = True + esPreSelectGroup= "" + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebRectangle rctFilter + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 125 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 300 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labFilter + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFilter" + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + Parent = "rctFilter" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Filter" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 320 + Underline = False + Visible = True + Width = 60 + _mPanelIndex = -1 + End + Begin WebLabel labFilterGroup + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFilter" + Italic = False + Left = 151 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFilter" + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "Group(s):" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 320 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebLabel labFilterDatabase + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFilter" + Italic = False + Left = 151 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFilter" + Scope = 2 + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Text = "Database(s):" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 366 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstFilterGroup + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFilter" + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 299 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Parent = "rctFilter" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 320 + Visible = True + Width = 400 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstFilterDatabase + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFilter" + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 299 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + PanelIndex = 0 + Parent = "rctFilter" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 4 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 366 + Visible = True + Width = 400 + _mPanelIndex = -1 + End + End + Begin WebMessageDialog dlgRevoke + ControlID = "" + Enabled = True + Explanation = "" + Index = -2147483648 + Indicator = 0 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Message = "" + Scope = 2 + Title = "" + Tooltip = "" + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.Load() + + Self.ShowInfos() + Self.RefreshButtons() + + ebOpened = True + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub ActionGrant() + dlgGrant.Show(lstFilterGroup.SelectedRowText) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionGrantButtonPressed(Group As String, Privilege As String, Database As String, Table As String) As Boolean + If (Group = "") Or (Group = "*") Or (Group = "admin") Then Return False + If (Privilege = "") Or (Privilege = "*") Then Return False + If (Database = "") Then Return False + If (Table = "") Then Return False + + Try + + Var sql As String = "GRANT '" + Privilege + "' TO GROUP '" + Group + "'" + If (Database <> "*") And (Table <> "*") Then sql = sql + " FOR TABLE '" + Table + "' IN DATABASE '" + Database + "'" + If (Database <> "*") And (Table = "*") Then sql = sql + " FOR DATABASE '" + Database + "'" + + Session.DB.ExecuteSQL(sql) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Grant Privilege" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not grant privilege." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Var selectRowTag As New Dictionary + selectRowTag.Value("groupname") = Group + selectRowTag.Value("privilege") = Privilege + selectRowTag.Value("databasename") = Database + selectRowTag.Value("tablename") = Table + + Self.RefreshInfos(selectRowTag) + Return True + + + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionRevoke() + Var privilege As Dictionary = Me.GetSelectedPrivilege() + If (privilege = Nil) Then Return + + Var privGroup As String = privilege.Lookup("groupname", "") + Var privName As String = privilege.Lookup("privilege", "") + Var privDB As String = privilege.Lookup("databasename", "") + Var privTable As String = privilege.Lookup("tablename", "") + + Var privilegeCaption As String = privName + " privilege" + If (privDB = "*" And privTable = "*") Then privilegeCaption = privilegeCaption + " on the entire server" + If (privDB <> "*" And privTable = "*") Then privilegeCaption = privilegeCaption + " on database " + privDB + If (privDB <> "*" And privTable <> "*") Then privilegeCaption = privilegeCaption + " on database " + privDB + " on table " + privTable + If (privDB = "*" And privTable <> "*") Then privilegeCaption = privilegeCaption + " on table " + privTable + + + dlgRevoke.Title = "Revoke Privilege" + dlgRevoke.Indicator = Indicators.Danger + dlgRevoke.ActionButton.Caption = "Revoke" + dlgRevoke.CancelButton.Visible = True + dlgRevoke.Message = "Are you sure you want to revoke the " + privilegeCaption + " for group " + privGroup + "?" + dlgRevoke.Explanation = "This action cannot be undone." + + edictActionPrivilege = privilege + + dlgRevoke.ShowWithActionDanger() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionRevokeButtonPressed(obj As WebMessageDialog, button As WebMessageDialogButton) + Var dictRevokePrivilege As Dictionary = edictActionPrivilege + edictActionPrivilege = Nil + + If (button <> obj.ActionButton) Then Return + If (dictRevokePrivilege = Nil) Then Return + + Try + Var privGroup As String = dictRevokePrivilege.Lookup("groupname", "") + Var privName As String = dictRevokePrivilege.Lookup("privilege", "") + Var privDB As String = dictRevokePrivilege.Lookup("databasename", "") + Var privTable As String = dictRevokePrivilege.Lookup("tablename", "") + + Var sql As String = "REVOKE " + privName + " FROM GROUP '" + privGroup + "'" + If (privDB <> "*" And privTable = "*") Then sql = sql + " FOR DATABASE '" + privDB + "'" + If (privDB <> "*" And privTable <> "*") Then sql = sql + " FOR TABLE '" + privTable + "' IN DATABASE '" + privDB + "'" + + Session.DB.ExecuteSQL(sql) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Drop Privilege" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not drop privilege." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Privileges" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetSelectedPrivilege() As Dictionary + If (lstInfos.SelectedRowIndex >= 0) And (lstInfos.RowTagAt(lstInfos.SelectedRowIndex) IsA Dictionary) Then + Return lstInfos.RowTagAt(lstInfos.SelectedRowIndex) + End If + + Return Nil + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Load() + Me.LoadGroups() + me.LoadDatabases() + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadDatabases() + lstFilterDatabase.RemoveAllRows + lstFilterDatabase.AddRow("(ALL)", "*") + lstFilterDatabase.AddRow("-", "*") + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW DATABASES") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstFilterDatabase.AddRow(rs.Column("databasename").StringValue, rs.Column("databasename").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Catch DatabaseException + + Finally + If (lstFilterDatabase.RowCount > 0) Then lstFilterDatabase.SelectedRowIndex = 0 + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadGroups() + lstFilterGroup.RemoveAllRows + lstFilterGroup.AddRow("(ALL)", "*") + lstFilterGroup.AddRow("-", "*") + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + + If (rs.Column("groupname").StringValue <> "admin") Then + lstFilterGroup.AddRow(rs.Column("groupname").StringValue, rs.Column("groupname").StringValue) + End If + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Catch DatabaseException + + Finally + If (lstFilterGroup.RowCount > 0) Then lstFilterGroup.SelectedRowIndex = 0 + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var bRevoke As Boolean + + Var selectedPrivilege As Dictionary = me.GetSelectedPrivilege() + + If (selectedPrivilege <> Nil) And (selectedPrivilege.Lookup("groupname", "*") <> "admin") Then + bRevoke = True + End If + + If (btnRevoke.Enabled <> bRevoke) Then btnRevoke.Enabled = bRevoke + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshInfos(selectRowTag As Dictionary = nil) + If (selectRowTag = Nil) And (lstInfos.SelectedRowIndex >= 0) Then + selectRowTag = Me.GetSelectedPrivilege() + End If + + Me.ShowInfos() + + If (selectRowTag = Nil) Then + Me.RefreshButtons() + Return + End If + + For i As Integer = lstInfos.LastRowIndex DownTo 0 + Var rowTag As Dictionary + If (lstInfos.RowTagAt(i) IsA Dictionary) Then + rowTag = lstInfos.RowTagAt(i) + End If + If (rowTag = Nil) Then Continue + + + If (rowTag.Lookup("groupname", "").StringValue = selectRowTag.Lookup("groupname", "-").StringValue) And _ + (rowTag.Lookup("privilege", "").StringValue = selectRowTag.Lookup("privilege", "-").StringValue) And _ + (rowTag.Lookup("databasename", "").StringValue = selectRowTag.Lookup("databasename", "-").StringValue) And _ + (rowTag.Lookup("tablename", "").StringValue = selectRowTag.Lookup("tablename", "-").StringValue) Then + + lstInfos.SelectedRowIndex = i + Exit 'Loop + End If + Next + + Me.RefreshButtons() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Var filterGroupname As String = lstFilterGroup.RowTagAt(lstFilterGroup.SelectedRowIndex) + Var filterDatabasename As String = lstFilterDatabase.RowTagAt(lstFilterDatabase.SelectedRowIndex) + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW ALL PRIVILEGES") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + Var dictRowTag As New Dictionary + dictRowTag.Value("groupname") = rs.Column("groupname").StringValue + dictRowTag.Value("privilege") = rs.Column("privilege").StringValue + dictRowTag.Value("databasename") = rs.Column("databasename").StringValue + dictRowTag.Value("tablename") = rs.Column("tablename").StringValue + + 'Filter + If (filterGroupname <> "") And (filterGroupname <> "*") Then + If (dictRowTag.Lookup("groupname", "").StringValue <> filterGroupname) Then + rs.MoveToNextRow + Continue + End If + End If + + If (filterDatabasename <> "") And (filterDatabasename <> "*") Then + If (dictRowTag.Lookup("databasename", "").StringValue <> "*") And _ + (dictRowTag.Lookup("databasename", "").StringValue <> filterDatabasename) Then + rs.MoveToNextRow + Continue + End If + End If + + lstInfos.AddRow("") + lstInfos.RowTagAt(lstInfos.LastAddedRowIndex) = dictRowTag + + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 0) = dictRowTag.Lookup("groupname", "").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 1) = dictRowTag.Lookup("privilege", "").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 2) = dictRowTag.Lookup("databasename", "").StringValue + lstInfos.CellTextAt(lstInfos.LastAddedRowIndex, 3) = dictRowTag.Lookup("tablename", "").StringValue + + rs.MoveToNextRow + Wend + End If + + rs.Close + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private ebOpened As Boolean + #tag EndProperty + + #tag Property, Flags = &h21 + Private edictActionPrivilege As Dictionary + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.HeaderAt(0) = "Groupname" + Me.HeaderAt(1) = "Privilege" + Me.HeaderAt(2) = "Databasename" + Me.HeaderAt(3) = "Tablename" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Ascending + + For i As Integer = 1 To 3 + Me.ColumnSortTypeAt(i) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + Next + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(rows() As Integer) + #Pragma unused rows + + If (Not ebOpened) Then Return + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRevoke + #tag Event + Sub Pressed() + Self.ActionRevoke() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnGrant + #tag Event + Sub Pressed() + Self.ActionGrant() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgGrant + #tag Event + Function PrivilegeGrantAction(Group As String, Privilege As String, Database As String, Table As String) As Boolean + Return Self.ActionGrantButtonPressed(Group, Privilege, Database, Table) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events lstFilterGroup + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebOpened) Then Return + + Self.RefreshInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstFilterDatabase + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebOpened) Then Return + + Self.RefreshInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgRevoke + #tag Event + Sub ButtonPressed(button As WebMessageDialogButton) + Self.ActionRevokeButtonPressed(Me, button) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntRegistration.xojo_code b/webapp/containers/cntRegistration.xojo_code new file mode 100644 index 0000000..95d940b --- /dev/null +++ b/webapp/containers/cntRegistration.xojo_code @@ -0,0 +1,426 @@ +#tag WebContainerControl +Begin cntBase cntRegistration + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 2 + ColumnWidths = "50%,50%" + ControlID = "" + Enabled = True + HasHeader = False + Height = 422 + HighlightSortedColumn= False + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Registration Information" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin cntRegistrationAction cntServerRegistration + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 78 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + ScrollDirection = 0 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 422 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Registration" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + lstInfos.AddRow "Server Name" + lstInfos.AddRow "" + lstInfos.AddRow "Registered to" + lstInfos.AddRow "Registration type" + lstInfos.AddRow "Upgrade plan expiration date" + lstInfos.AddRow "Max allowed connections" + + Var styleKeyColumn As WebStyle = StyleListboxKeyColumn + For i As Integer = 0 To lstInfos.LastRowIndex + lstInfos.CellTextAt(i, 0) = New WebListBoxStyleRenderer(styleKeyColumn, lstInfos.CellTextAt(i, 0)) + Next + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW PREFERENCES") + If (rs = Nil) Then Return + + Var infos As New Dictionary + For Each row As DatabaseRow In rs + infos.Value(row.ColumnAt(0).StringValue) = row.ColumnAt(1).StringValue + Next + + rs.Close + + + rs = Session.DB.SelectSQL("SHOW INFO") + If (rs <> Nil) Then + + For Each row As DatabaseRow In rs + infos.Value(row.ColumnAt(0).StringValue) = row.ColumnAt(1).StringValue + Next + + rs.Close + End If + + + lstInfos.CellTextAt(0, 1) = infos.Lookup("SERVER_NAME", "cubeSQL").StringValue + + Var keyName As String = infos.Lookup("KEY_NAME", "").StringValue + If (keyName = "") Or (keyName = "0") Then keyName = "N/A" + lstInfos.CellTextAt(2, 1) = keyName + + lstInfos.CellTextAt(3, 1) = infos.Lookup("KEY_STATUS", "N/A").StringValue + + If (infos.Lookup("KEY_EXPIRATION", "") <> "") Then + lstInfos.CellTextAt(4, 0) = New WebListBoxStyleRenderer(styleKeyColumn, "Key expiration") + lstInfos.CellTextAt(4, 1) = infos.Lookup("server_license", "").StringValue + Else + lstInfos.CellTextAt(4, 0) = New WebListBoxStyleRenderer(styleKeyColumn, "Upgrade plan expiration date") + lstInfos.CellTextAt(4, 1) = infos.Lookup("KEY_EXPIRATION_PLAN", "").StringValue + End If + + lstInfos.CellTextAt(5, 1) = infos.Lookup("max_allowed_connections", "").StringValue + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + +#tag EndWindowCode + +#tag Events cntServerRegistration + #tag Event + Sub NeedsRefresh() + Self.ShowInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntRegistrationAction.xojo_code b/webapp/containers/cntRegistrationAction.xojo_code new file mode 100644 index 0000000..151bf3d --- /dev/null +++ b/webapp/containers/cntRegistrationAction.xojo_code @@ -0,0 +1,494 @@ +#tag WebContainerControl +Begin WebContainer cntRegistrationAction + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 78 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebButton btnGetServerKey + AllowAutoDisable= False + Cancel = False + Caption = "Get a Server Key" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 266 + _mPanelIndex = -1 + End + Begin WebButton btnRegisterServer + AllowAutoDisable= False + Cancel = False + Caption = "Register Server" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 464 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 266 + _mPanelIndex = -1 + End + Begin dlgRegisterServer dlgRegistration + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 272 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebMessageDialog dlgGetServerKey + ControlID = "" + Enabled = True + Explanation = "" + Index = -2147483648 + Indicator = 0 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Message = "" + Scope = 2 + Title = "" + Tooltip = "" + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Method, Flags = &h21 + Private Sub GetServerKeyAction(obj As WebMessageDialog, button As WebMessageDialogButton) + If (button = obj.ActionButton) Then + Self.GoToURL(constUrl_DeveloperKey, True) + End If + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function RegistrationAction(Name As String, Key As String) As Boolean + If (Name = "") Or (Key = "") Then Return False + + Try + If Name.Contains("'", ComparisonOptions.CaseInsensitive) Then + Session.DB.ExecuteSQL("SET BASE64 REGISTRATION TO '" + EncodeBase64(Name) + "' WITH KEY '" + Key + "'") + Else + Session.DB.ExecuteSQL("SET REGISTRATION TO '" + Name + "' WITH KEY '" + Key + "'") + End If + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Registration" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not register cubeSQL." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + NeedsRefresh + Return False + + End Try + + Var dialog As New WebMessageDialog + dialog.Title = "Registration" + dialog.Indicator = Indicators.Success + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Thanks for registering cubeSQL Server!" + dialog.Explanation = "" + dialog.Show + NeedsRefresh + + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowGetServerKeyDialog() + dlgGetServerKey.Title = "Server Key" + dlgGetServerKey.Indicator = Indicators.Default + dlgGetServerKey.ActionButton.Caption = "Get a Key" + dlgGetServerKey.CancelButton.Visible = True + dlgGetServerKey.Message = "Get a Server Key from SQlabs." + dlgGetServerKey.Explanation = "Open this URL in a new Browser Window: " + constUrl_DeveloperKey + + dlgGetServerKey.Show() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowRegistrationDialog() + Var Name, Key As String + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW PREFERENCES") + If (rs <> Nil) Then + Var infos As New Dictionary + For Each row As DatabaseRow In rs + infos.Value(row.ColumnAt(0).StringValue) = row.ColumnAt(1).StringValue + Next + + rs.Close + + Name = infos.Lookup("KEY_NAME", "").StringValue + Key = infos.Lookup("KEY_VALUE", "").StringValue + End If + + + Catch DatabaseException + + Finally + dlgRegistration.Show(Name, Key) + + End Try + + + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event NeedsRefresh() + #tag EndHook + + +#tag EndWindowCode + +#tag Events btnGetServerKey + #tag Event + Sub Pressed() + self.ShowGetServerKeyDialog() + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRegisterServer + #tag Event + Sub Pressed() + self.ShowRegistrationDialog() + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgRegistration + #tag Event + Function RegistrationAction(Name As String, Key As String) As Boolean + Return Self.RegistrationAction(Name, Key) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events dlgGetServerKey + #tag Event + Sub ButtonPressed(button As WebMessageDialogButton) + Self.GetServerKeyAction(Me, button) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntStatus.xojo_code b/webapp/containers/cntStatus.xojo_code new file mode 100644 index 0000000..6c4e1c7 --- /dev/null +++ b/webapp/containers/cntStatus.xojo_code @@ -0,0 +1,480 @@ +#tag WebContainerControl +Begin cntBase cntStatus + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 2 + ColumnWidths = "50%,50%" + ControlID = "" + Enabled = True + HasHeader = False + Height = 500 + HighlightSortedColumn= False + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Status Information" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 0 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebTimer timRefresh + ControlID = "" + Enabled = True + Index = -2147483648 + Location = 1 + LockedInPosition= True + Period = 5000 + RunMode = 2 + Scope = 2 + _mPanelIndex = -1 + End + Begin cntRegistrationAction cntServerRegistration + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 78 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + ScrollDirection = 0 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 422 + Visible = False + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + #tag Event + Sub Shown() + ebShown = True + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h0 + Sub Close() + timRefresh.RunMode = WebTimer.RunModes.Off + timRefresh.Enabled = False + + Super.Close() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Status" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW DETAILED STATISTICS") + If (rs = Nil) Then Return + + Var infos As New Dictionary + For Each row As DatabaseRow In rs + infos.Value(row.ColumnAt(0).StringValue) = row.ColumnAt(1).StringValue + Next + + rs.Close + + + lstInfos.CellTextAt(0, 1) = infos.Lookup("server_release", "") + " (" + infos.Lookup("server_mode", "") + ")" + lstInfos.CellTextAt(1, 1) = infos.Lookup("engine_version", "").StringValue + lstInfos.CellTextAt(2, 1) = infos.Lookup("server_license", "").StringValue + + lstInfos.CellTextAt(4, 1) = infos.Lookup("ip_address", "").StringValue + lstInfos.CellTextAt(5, 1) = infos.Lookup("server_port", "").StringValue + lstInfos.CellTextAt(6, 1) = infos.Lookup("os_version", "").StringValue + + lstInfos.CellTextAt(8, 1) = "Current: " + infos.Lookup("current_connections", "") + " | Total: " + infos.Lookup("total_connections", "") + " | Max: " + infos.Lookup("max_connections", "") + lstInfos.CellTextAt(9, 1) = "Sent: " + infos.Lookup("bytes_sent", "") + " | Received: " + infos.Lookup("bytes_received", "") + lstInfos.CellTextAt(10, 1) = "Query: " + infos.Lookup("query_count", "") + " | Exec: " + infos.Lookup("exec_count", "") + " | Custom Commands: " + infos.Lookup("commands_count", "") + lstInfos.CellTextAt(11, 1) = "Current: " + infos.Lookup("memory_usage", "") + " | Max: " + infos.Lookup("max_memory_usage", "") + lstInfos.CellTextAt(12, 1) = infos.Lookup("server_startup_datetime", "").StringValue + + If ebShown Then + ' Don't change Height before shown... + Var serverLicenseIsNotRegistered As Boolean = infos.Lookup("server_license", "").StringValue.Contains("NOT REGISTERED", ComparisonOptions.CaseInsensitive) + Var isNotRegistered As Boolean = infos.Lookup("registered", "").StringValue.Contains("NOT REGISTERED", ComparisonOptions.CaseInsensitive) + + If serverLicenseIsNotRegistered Or isNotRegistered Then + If (cntServerRegistration.Visible <> True) Then cntServerRegistration.Visible = True + If (lstInfos.Height <> Self.Height - cntServerRegistration.Height) Then lstInfos.Height = Self.Height - cntServerRegistration.Height + Else + If (cntServerRegistration.Visible <> False) Then cntServerRegistration.Visible = False + If (lstInfos.Height <> Self.Height) Then lstInfos.Height = Self.Height + End If + End If + + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private ebShown As Boolean + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.RemoveAllRows + + Me.AddRow "Version" + Me.AddRow "Engine version" + Me.AddRow "License" + Me.AddRow "" + Me.AddRow "Address" + Me.AddRow "Port" + Me.AddRow "Host OS" + Me.AddRow "" + Me.AddRow "Connections" + Me.AddRow "Bytes" + Me.AddRow "Counters" + Me.AddRow "Memory Usage" + Me.AddRow "Up since" + + Var styleKeyColumn As WebStyle = StyleListboxKeyColumn + + For i As Integer = 0 To Me.LastRowIndex + Me.CellTextAt(i, 0) = New WebListBoxStyleRenderer(styleKeyColumn, Me.CellTextAt(i, 0)) + Next + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events timRefresh + #tag Event + Sub Run() + self.ShowInfos() + End Sub + #tag EndEvent +#tag EndEvents +#tag Events cntServerRegistration + #tag Event + Sub NeedsRefresh() + Self.ShowInfos() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/containers/cntUsers.xojo_code b/webapp/containers/cntUsers.xojo_code new file mode 100644 index 0000000..1e3d4c7 --- /dev/null +++ b/webapp/containers/cntUsers.xojo_code @@ -0,0 +1,1065 @@ +#tag WebContainerControl +Begin cntBase cntUsers + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 500 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + ScrollDirection = 0 + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebListBox lstInfos + ColumnCount = 3 + ColumnWidths = "30%, 10%, 60%" + ControlID = "" + Enabled = True + HasHeader = True + Height = 422 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Users" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 1 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 0 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebButton btnDrop + AllowAutoDisable= False + Cancel = False + Caption = "Drop" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 4 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 4 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnRename + AllowAutoDisable= False + Cancel = False + Caption = "Rename" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 2 + Left = 522 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCreate + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgUserCreate dlgCreate + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin dlgCommonName dlgRename + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 6 + TabStop = True + Tooltip = "" + Top = 40 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebThread thrDetails + DebugIdentifier = "" + Index = -2147483648 + LockedInPosition= True + Priority = 5 + Scope = 2 + StackSize = 0 + ThreadID = 0 + ThreadState = 0 + End + Begin WebButton btnPassword + AllowAutoDisable= False + Cancel = False + Caption = "Set Password" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 5 + Left = 374 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin dlgUserCreate dlgPassword + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 40 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 7 + TabStop = True + Tooltip = "" + Top = 40 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebButton btnGroups + AllowAutoDisable= False + Cancel = False + Caption = "Groups" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 6 + Left = 266 + LockBottom = True + LockedInPosition= False + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 8 + TabStop = True + Tooltip = "" + Top = 442 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin dlgUserGroups dlgGroups + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 40 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 9 + TabStop = True + Tooltip = "" + Top = 40 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + End + Begin WebMessageDialog dlgDrop + ControlID = "" + Enabled = True + Explanation = "" + Index = -2147483648 + Indicator = 0 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Message = "" + Scope = 2 + Title = "" + Tooltip = "" + _mPanelIndex = -1 + End +End +#tag EndWebContainerControl + +#tag WindowCode + #tag Event + Sub Opening() + Self.ShowInfos() + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub ActionCreate() + dlgCreate.Show() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionCreateButtonPressed(Name As String, Password As String) As Boolean + If (Name = "") Then Return False + + Try + + Session.DB.ExecuteSQL("CREATE USER " + "'" + Name + "' WITH PASSWORD '" + Password + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Create User" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not create user." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDrop() + Var username As String = Me.GetSelectedUsername() + If (username = "") Then Return + + dlgDrop.Title = "Drop User" + dlgDrop.Indicator = Indicators.Danger + dlgDrop.ActionButton.Caption = "Drop" + dlgDrop.CancelButton.Visible = True + dlgDrop.Message = "Are you sure you want to drop user '" + username + "'?" + dlgDrop.Explanation = "This action cannot be undone." + + esActionUsername = username + + dlgDrop.ShowWithActionDanger() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionDropButtonPressed(obj As WebMessageDialog, button As WebMessageDialogButton) + Var sDropUsername As String = esActionUsername + esActionUsername = "" + + If (button <> obj.ActionButton) Then Return + If (sDropUsername = "") Then Return + + Try + Session.DB.ExecuteSQL("DROP USER '" + sDropUsername) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Drop User" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not drop user." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + + Finally + Me.RefreshInfos() + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionGroups() + Var username As String = Me.GetSelectedUsername() + If (username = "") Then Return + + esActionUsername = username + + dlgGroups.Show(username) + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionGroupsButtonPressed() + Var sUsername As String = esActionUsername + esActionUsername = "" + + Self.RefreshInfos(sUsername) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionPassword() + Var username As String = Me.GetSelectedUsername() + If (username = "") Then Return + + dlgPassword.ShowSetPassword(username) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionPasswordButtonPressed(Name As String, Password As String) As Boolean + If (Name = "") Then Return False + + Try + + Session.DB.ExecuteSQL("SET PASSWORD '" + Password + "' FOR USER " + "'" + Name) + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Set User Password" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not set user password." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ActionRename() + Var username As String = Me.GetSelectedUsername() + If (username = "") Then Return + + esActionUsername = username + + dlgRename.Show("Rename User", "Name", "Rename", Indicators.Primary, username) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function ActionRenameButtonPressed(Name As String) As Boolean + If (esActionUsername = "") Then Return False + If (Name = "") Then Return False + If (esActionUsername = Name) Then Return False + + Try + + Session.DB.ExecuteSQL("RENAME USER '" + esActionUsername + "' TO " + "'" + Name + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Rename User" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not rename user." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return False + + End Try + + 'Success - no dialog + Self.RefreshInfos(Name) + Return True + + End Function + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Close() + Try + thrDetails.Stop + Catch err As RuntimeException + + End Try + + Super.Close() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Constructor() + Super.Constructor + + me.Title = "Users" + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetSelectedUsername() As String + If (lstInfos.SelectedRowIndex < 0) Then Return "" + return lstInfos.CellTextAt(lstInfos.SelectedRowIndex, 0) + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var bGroups, bPassword, bRename, bDrop As Boolean + + Var username As String = Me.GetSelectedUsername() + If (username <> "admin") And (username <> "") Then + bGroups = True + bPassword = True + bRename = (username <> Session.DB.UserName) + bDrop = (username <> Session.DB.UserName) + End If + + If (btnGroups.Enabled <> bGroups) Then btnGroups.Enabled = bGroups + If (btnPassword.Enabled <> bPassword) Then btnPassword.Enabled = bPassword + If (btnRename.Enabled <> bRename) Then btnRename.Enabled = bRename + If (btnDrop.Enabled <> bDrop) Then btnDrop.Enabled = bDrop + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshInfos(selectUsername As String = "") + If (selectUsername = "") Then + selectUsername = Me.GetSelectedUsername() + End If + + Me.ShowInfos() + + If (selectUsername = "") Then + Me.RefreshButtons() + Return + End If + + For i As Integer = lstInfos.LastRowIndex DownTo 0 + If (lstInfos.CellTextAt(i, 0) <> selectUsername) Then Continue + + lstInfos.SelectedRowIndex = i + Exit 'Loop + Next + + Me.RefreshButtons() + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowDetails() + Var styleCenter As WebStyle = StyleListboxTextAlignCenter() + + Var iLast As Integer = lstInfos.LastRowIndex + For i As Integer = 0 To iLast + Var username As String = lstInfos.CellTextAt(i, 0) + If (username = "") Then Continue + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS FOR USER '" + username + "'") + + Var iCount As Integer = 0 + Var sUsers() As String + + If (rs <> Nil) Then + iCount = rs.RowCount + + If (iCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + sUsers.Add(rs.Column("groupname").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + End If + + lstInfos.CellTextAt(i, 1) = New WebListBoxStyleRenderer(styleCenter, iCount.ToString) + lstInfos.CellTextAt(i, 2) = String.FromArray(sUsers, ", ") + + Catch DatabaseException + + End Try + + Next + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowInfos() + lstInfos.RemoveAllRows + + Try + thrDetails.Stop + Catch err As RuntimeException + + End Try + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW USERS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstInfos.AddRow(rs.Column("username").StringValue) + + rs.MoveToNextRow + Wend + End If + + + rs.Close + + + Catch DatabaseException + + Finally + + Try + thrDetails.Start + Catch err As RuntimeException + + End Try + + End Try + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private esActionUsername As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstInfos + #tag Event + Sub Opening() + Me.ExecuteJavaScript("$('#" + Me.ControlID + "').addClass('listboxUsersHeaderAlignment')") + + Me.HeaderAt(0) = "Username" + Me.HeaderAt(1) = "#" + Me.HeaderAt(2) = "Groups" + + Me.ColumnSortTypeAt(0) = WebListBox.SortTypes.Sortable + Me.ColumnSortDirectionAt(0) = WebListbox.SortDirections.Ascending + + For i As Integer = 1 To 2 + Me.ColumnSortTypeAt(i) = WebListBox.SortTypes.Unsortable + Me.ColumnSortDirectionAt(i) = WebListbox.SortDirections.None + Next + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(rows() As Integer) + #Pragma unused rows + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnDrop + #tag Event + Sub Pressed() + Self.ActionDrop() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRename + #tag Event + Sub Pressed() + Self.ActionRename() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCreate + #tag Event + Sub Pressed() + Self.ActionCreate() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgCreate + #tag Event + Function UserCreateAction(Name As String, Password As String) As Boolean + Return Self.ActionCreateButtonPressed(Name, Password) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events dlgRename + #tag Event + Function NameAction(Name As String) As Boolean + Return Self.ActionRenameButtonPressed(Name) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events thrDetails + #tag Event + Sub Run() + Try + Self.ShowDetails() + Catch err As RuntimeException + End Try + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnPassword + #tag Event + Sub Pressed() + Self.ActionPassword() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgPassword + #tag Event + Function UserCreateAction(Name As String, Password As String) As Boolean + Return Self.ActionPasswordButtonPressed(Name, Password) + + End Function + #tag EndEvent +#tag EndEvents +#tag Events btnGroups + #tag Event + Sub Pressed() + Self.ActionGroups() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgGroups + #tag Event + Sub NeedsRefresh() + self.ActionGroupsButtonPressed() + End Sub + #tag EndEvent +#tag EndEvents +#tag Events dlgDrop + #tag Event + Sub ButtonPressed(button As WebMessageDialogButton) + Self.ActionDropButtonPressed(Me, button) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=true + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="ScrollDirection" + Visible=true + Group="Behavior" + InitialValue="ScrollDirections.None" + Type="WebContainer.ScrollDirections" + EditorType="Enum" + #tag EnumValues + "0 - None" + "1 - Horizontal" + "2 - Vertical" + "3 - Both" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="View" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="View" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=false + Group="" + InitialValue="250" + Type="Integer" + EditorType="" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgCommonName.xojo_code b/webapp/dialogs/dlgCommonName.xojo_code new file mode 100644 index 0000000..010b143 --- /dev/null +++ b/webapp/dialogs/dlgCommonName.xojo_code @@ -0,0 +1,512 @@ +#tag WebPage +Begin WebDialog dlgCommonName + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 230 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "Title" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 560 + _mPanelIndex = -1 + End + Begin WebRectangle rctFormContent + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 80 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = True + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 560 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labName + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Name:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 86 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebTextField edtName + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 86 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + End + Begin WebButton btnName + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 480 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 172 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCancel + AllowAutoDisable= False + Cancel = True + Caption = "Cancel" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 172 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + edtName.SetFocus() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnName.Enabled = (edtName.Text.Trim <> "") and (esNameInitialValue <> edtName.Text.Trim) + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show(DialogTitle As String, LabelCaption As String, ButtonCaption As String, ButtonIndicator As Indicators = Indicators.Primary, NameInitialValue As String = "") + labTitle.Text = DialogTitle + labName.Text = LabelCaption + ":" + btnName.Caption = ButtonCaption + btnName.Indicator = ButtonIndicator + edtName.Text = NameInitialValue + esNameInitialValue = NameInitialValue + + Me.RefreshButtons() + Super.Show() + + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event NameAction(Name As String) As Boolean + #tag EndHook + + + #tag Property, Flags = &h21 + Private esNameInitialValue As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events edtName + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnName + #tag Event + Sub Pressed() + If NameAction(edtName.Text.Trim) Then + Self.Close() + End If + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCancel + #tag Event + Sub Pressed() + Self.Close() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgDatabaseCreate.xojo_code b/webapp/dialogs/dlgDatabaseCreate.xojo_code new file mode 100644 index 0000000..0185489 --- /dev/null +++ b/webapp/dialogs/dlgDatabaseCreate.xojo_code @@ -0,0 +1,673 @@ +#tag WebPage +Begin WebDialog dlgDatabaseCreate + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "Create Database" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 560 + _mPanelIndex = -1 + End + Begin WebRectangle rctFormContent + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 171 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 560 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labKey + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Text = "Encryption Key:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 132 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebLabel labName + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Name:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 86 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebTextField edtKey + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 132 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + Begin WebTextField edtName + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 86 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + Begin WebLabel labEncoding + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 4 + TabPanelIndex = 0 + TabStop = True + Text = "Encoding:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 178 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstEncoding + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Parent = "rctFormContent" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 5 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 178 + Visible = True + Width = 150 + _mPanelIndex = -1 + End + End + Begin WebButton btnCreate + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 480 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 256 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCancel + AllowAutoDisable= False + Cancel = True + Caption = "Cancel" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 256 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + edtName.SetFocus() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnCreate.Enabled = (edtName.Text.Trim <> "") And (Not edtKey.Text.Contains("'")) + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show() + edtName.Text = "" + edtKey.Text = "" + lstEncoding.SelectedRowIndex = 0 + + Super.Show() + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event DatabaseCreateAction(Name As String, Key As String, Encoding As String) As Boolean + #tag EndHook + + +#tag EndWindowCode + +#tag Events edtKey + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtName + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstEncoding + #tag Event + Sub Opening() + Me.RemoveAllRows + + Me.AddRow "UTF-8" + Me.AddRow "UTF-16" + Me.AddRow "UTF-16le" + Me.AddRow "UTF-16be" + + Me.SelectedRowIndex = 0 + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCreate + #tag Event + Sub Pressed() + If DatabaseCreateAction(edtName.Text.Trim, edtKey.Text.Trim, lstEncoding.SelectedRowText.Trim) Then + Self.Close() + End If + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCancel + #tag Event + Sub Pressed() + Self.Close() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgPrivilegeGrant.xojo_code b/webapp/dialogs/dlgPrivilegeGrant.xojo_code new file mode 100644 index 0000000..7c5f1e5 --- /dev/null +++ b/webapp/dialogs/dlgPrivilegeGrant.xojo_code @@ -0,0 +1,931 @@ +#tag WebPage +Begin WebDialog dlgPrivilegeGrant + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 372 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "Grant Privilege" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 560 + _mPanelIndex = -1 + End + Begin WebRectangle rctFormContent + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 222 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 580 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labPrivilege + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Text = "Privilege:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 132 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebLabel labGroup + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Group:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 86 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebLabel labDatabase + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 4 + TabPanelIndex = 0 + TabStop = True + Text = "Database:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 178 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstGroup + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Parent = "rctFormContent" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 86 + Visible = True + Width = 392 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstPrivilege + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + PanelIndex = 0 + Parent = "rctFormContent" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 132 + Visible = True + Width = 392 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstDatabase + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + PanelIndex = 0 + Parent = "rctFormContent" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 5 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 178 + Visible = True + Width = 392 + _mPanelIndex = -1 + End + Begin WebLabel labTable + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 6 + TabPanelIndex = 0 + TabStop = True + Text = "Table:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 224 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstTable + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + PanelIndex = 0 + Parent = "rctFormContent" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 7 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 224 + Visible = True + Width = 392 + _mPanelIndex = -1 + End + End + Begin WebButton btnGrant + AllowAutoDisable= False + Cancel = False + Caption = "Grant" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 480 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 314 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCancel + AllowAutoDisable= False + Cancel = True + Caption = "Cancel" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 314 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + ebShown = true + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub Load() + Me.LoadGroup() + Me.LoadPrivileges() + Me.LoadDatabases() + Me.LoadTables() + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadDatabases() + lstDatabase.RemoveAllRows + lstDatabase.AddRow("(ALL)", "*") + lstDatabase.AddRow("-", "*") + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW DATABASES") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstDatabase.AddRow(rs.Column("databasename").StringValue, rs.Column("databasename").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Catch DatabaseException + + Finally + If (lstDatabase.RowCount > 0) Then lstDatabase.SelectedRowIndex = 0 + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadGroup() + lstGroup.RemoveAllRows + + Var iPreSelectGroup As Integer = -1 + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + + If (rs.Column("groupname").StringValue <> "admin") Then + lstGroup.AddRow(rs.Column("groupname").StringValue, rs.Column("groupname").StringValue) + If (esPreSelectGroup <> "") And (esPreSelectGroup = rs.Column("groupname").StringValue) Then + iPreSelectGroup = lstGroup.LastAddedRowIndex + End If + End If + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Catch DatabaseException + + Finally + If (iPreSelectGroup >= 0) And (lstGroup.LastRowIndex >= iPreSelectGroup) Then + lstGroup.SelectedRowIndex = iPreSelectGroup + Else + If (lstGroup.RowCount > 0) Then lstGroup.SelectedRowIndex = 0 + End If + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadPrivileges() + lstPrivilege.RemoveAllRows + + Var privileges() As String + + Try + + Var rs As RowSet = Session.DB.SelectSQL("SHOW PRIVILEGES TABLE") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + Var priv As String = rs.Column("name").StringValue + If (priv <> "") And (privileges.IndexOf(priv) < 0) Then + privileges.Add(priv) + End If + + rs.MoveToNextRow + Wend + End If + + rs.Close + + + Catch DatabaseException + + Finally + + privileges.Sort() + + For Each sAddPrivilege As String In privileges + lstPrivilege.AddRow(sAddPrivilege, sAddPrivilege) + Next + + If (lstPrivilege.RowCount > 0) Then lstPrivilege.SelectedRowIndex = 0 + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadTables() + lstTable.RemoveAllRows + lstTable.AddRow("(ALL)", "*") + + Var databaseName As String = lstDatabase.RowTagAt(lstDatabase.SelectedRowIndex).StringValue + If (databaseName = "") Or (databaseName = "*") Then + If (lstTable.RowCount > 0) Then lstTable.SelectedRowIndex = 0 + Return + End If + + lstTable.AddRow("-", "*") + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW TABLES FOR DATABASE '" + databaseName + "'") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstTable.AddRow(rs.Column("tablename").StringValue, rs.Column("tablename").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Catch DatabaseException + + Finally + If (lstTable.RowCount > 0) Then lstTable.SelectedRowIndex = 0 + + End Try + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var Group As String = lstGroup.RowTagAt(lstGroup.SelectedRowIndex).StringValue + Var Privilege As String = lstPrivilege.RowTagAt(lstPrivilege.SelectedRowIndex).StringValue + + btnGrant.Enabled = (Group <> "admin") And (Group <> "*") And (Group <> "") _ + And (Privilege <> "*") And (Privilege <> "") + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show(PreSelectGroup As String) + esPreSelectGroup = PreSelectGroup + + Me.Load() + Me.RefreshButtons() + + Super.Show() + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event PrivilegeGrantAction(Group As String, Privilege As String, Database As String, Table As String) As Boolean + #tag EndHook + + + #tag Property, Flags = &h21 + Private ebShown As Boolean + #tag EndProperty + + #tag Property, Flags = &h0 + esPreSelectGroup As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstGroup + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebShown) Then Return + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstPrivilege + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebShown) Then Return + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstDatabase + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebShown) Then Return + + Self.LoadTables() + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstTable + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + If (Not ebShown) Then Return + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnGrant + #tag Event + Sub Pressed() + If PrivilegeGrantAction( _ + lstGroup.RowTagAt(lstGroup.SelectedRowIndex).StringValue, _ + lstPrivilege.RowTagAt(lstPrivilege.SelectedRowIndex).StringValue, _ + lstDatabase.RowTagAt(lstDatabase.SelectedRowIndex).StringValue, _ + lstTable.RowTagAt(lstTable.SelectedRowIndex).StringValue _ + ) Then + Self.Close() + End If + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCancel + #tag Event + Sub Pressed() + Self.Close() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="esPreSelectGroup" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgRegisterServer.xojo_code b/webapp/dialogs/dlgRegisterServer.xojo_code new file mode 100644 index 0000000..7f009d5 --- /dev/null +++ b/webapp/dialogs/dlgRegisterServer.xojo_code @@ -0,0 +1,601 @@ +#tag WebPage +Begin WebDialog dlgRegisterServer + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 272 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "cubeSQL Server Registration" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 560 + _mPanelIndex = -1 + End + Begin WebRectangle rctFormContent + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 120 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 560 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labKey + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Text = "Key:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 132 + Underline = False + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebLabel labName + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Name:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 86 + Underline = False + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebTextField edtKey + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 148 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 132 + Visible = True + Width = 412 + _mPanelIndex = -1 + End + Begin WebTextField edtName + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 148 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 86 + Visible = True + Width = 412 + _mPanelIndex = -1 + End + End + Begin WebButton btnRegister + AllowAutoDisable= False + Cancel = False + Caption = "Register" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 480 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 214 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCancel + AllowAutoDisable= False + Cancel = True + Caption = "Cancel" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 214 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + edtName.SetFocus() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var isInitialValues As Boolean = (edtName.Text.Trim = esInitialName) And (edtKey.Text.Trim = esInitialKey) + Var isEmpty As Boolean = (edtName.Text.Trim = "") Or (edtKey.Text.Trim = "") + + btnRegister.Enabled = (Not isInitialValues) And (Not isEmpty) + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show() + me.Show("", "") + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show(Name As String, Key As String) + edtName.Text = Name.Trim + edtKey.Text = Key.Trim + + esInitialName = edtName.Text + esInitialKey = edtKey.Text + + Super.Show() + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event RegistrationAction(Name As String, Key As String) As Boolean + #tag EndHook + + + #tag Property, Flags = &h21 + Private esInitialKey As String + #tag EndProperty + + #tag Property, Flags = &h21 + Private esInitialName As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events edtKey + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtName + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRegister + #tag Event + Sub Pressed() + If RegistrationAction(edtName.Text.Trim, edtKey.Text.Trim) Then + Self.Close() + End If + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCancel + #tag Event + Sub Pressed() + Self.Close() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgUserCreate.xojo_code b/webapp/dialogs/dlgUserCreate.xojo_code new file mode 100644 index 0000000..1be6bb0 --- /dev/null +++ b/webapp/dialogs/dlgUserCreate.xojo_code @@ -0,0 +1,686 @@ +#tag WebPage +Begin WebDialog dlgUserCreate + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 314 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 600 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "Create User" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 560 + _mPanelIndex = -1 + End + Begin WebRectangle rctFormContent + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 171 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 560 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labPassword + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Text = "Password:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 132 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebLabel labName + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Text = "Name:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 86 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebTextField edtPassword + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 1 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 132 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + Begin WebTextField edtName + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 86 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + Begin WebLabel labPasswordRepeat + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rctFormContent" + Scope = 2 + TabIndex = 4 + TabPanelIndex = 0 + TabStop = True + Text = "Repeat:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 178 + Underline = False + Visible = True + Width = 140 + _mPanelIndex = -1 + End + Begin WebTextField edtPasswordRepeat + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 1 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rctFormContent" + Left = 188 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rctFormContent" + ReadOnly = False + Scope = 2 + TabIndex = 5 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 178 + Visible = True + Width = 372 + _mPanelIndex = -1 + End + End + Begin WebButton btnCreate + AllowAutoDisable= False + Cancel = False + Caption = "Create" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 480 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 256 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnCancel + AllowAutoDisable= False + Cancel = True + Caption = "Cancel" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 256 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + If edtName.Enabled Then + edtName.SetFocus() + Return + End If + + If edtPassword.Enabled Then + edtPassword.SetFocus() + End If + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + btnCreate.Enabled = (edtName.Text.Trim <> "") _ + And (edtPassword.Text.Trim <> "") _ + And (edtPassword.Text.Trim.Compare(edtPasswordRepeat.Text.Trim, ComparisonOptions.Binary) = 0) _ + And (Not edtName.Text.Contains("'")) _ + And (Not edtPassword.Text.Contains("'")) + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show() + edtName.Text = "" + edtPassword.Text = "" + edtPasswordRepeat.Text = "" + + Super.Show() + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub ShowSetPassword(Name As String) + edtName.Text = Name + edtPassword.Text = "" + edtPasswordRepeat.Text = "" + + labTitle.Text = "Set User Password" + edtName.Enabled = False + + Super.Show() + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event UserCreateAction(Name As String, Password As String) As Boolean + #tag EndHook + + +#tag EndWindowCode + +#tag Events edtPassword + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtName + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events edtPasswordRepeat + #tag Event + Sub TextChanged() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCreate + #tag Event + Sub Pressed() + If UserCreateAction(edtName.Text.Trim, edtPassword.Text.Trim) Then + Self.Close() + End If + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnCancel + #tag Event + Sub Pressed() + Self.Close() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/dialogs/dlgUserGroups.xojo_code b/webapp/dialogs/dlgUserGroups.xojo_code new file mode 100644 index 0000000..98fd282 --- /dev/null +++ b/webapp/dialogs/dlgUserGroups.xojo_code @@ -0,0 +1,688 @@ +#tag WebPage +Begin WebDialog dlgUserGroups + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = True + Height = 346 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = False + LockRight = False + LockTop = False + LockVertical = False + TabIndex = 0 + Top = 0 + Visible = True + Width = 750 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebLabel labTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 24.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + Italic = False + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Scope = 2 + TabIndex = 0 + TabStop = True + Text = "Groups for User" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 20 + Underline = False + Visible = True + Width = 710 + _mPanelIndex = -1 + End + Begin WebButton btnAdd + AllowAutoDisable= False + Cancel = False + Caption = "Add" + ControlID = "" + Default = True + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 1 + Left = 414 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 3 + TabStop = True + Tooltip = "" + Top = 288 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebButton btnClose + AllowAutoDisable= False + Cancel = True + Caption = "Close" + ControlID = "" + Default = False + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + Left = 630 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Scope = 2 + TabIndex = 5 + TabStop = True + Tooltip = "" + Top = 288 + Visible = True + Width = 100 + _mPanelIndex = -1 + End + Begin WebListBox lstUserGroups + ColumnCount = 1 + ColumnWidths = "" + ControlID = "" + Enabled = True + HasHeader = False + Height = 200 + HighlightSortedColumn= True + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastColumnIndex = 0 + LastRowIndex = 0 + Left = 0 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + NoRowsMessage = "No Groups" + ProcessingMessage= "" + RowCount = 0 + RowSelectionType= 1 + Scope = 2 + SearchCriteria = "" + SelectedRowColor= &c0d6efd + SelectedRowIndex= 0 + TabIndex = 1 + TabStop = True + Tooltip = "" + Top = 66 + Visible = True + Width = 750 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstAddGroups + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 20 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = False + LockVertical = False + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 2 + TabStop = True + Tooltip = "" + Top = 288 + Visible = True + Width = 386 + _mPanelIndex = -1 + End + Begin WebButton btnRemove + AllowAutoDisable= False + Cancel = False + Caption = "Remove" + ControlID = "" + Default = False + Enabled = False + Height = 38 + Index = -2147483648 + Indicator = 4 + Left = 522 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + PanelIndex = 0 + Scope = 2 + TabIndex = 4 + TabStop = True + Tooltip = "" + Top = 288 + Visible = True + Width = 100 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Shown() + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Function GetSelectedAddGroup() As String + If (lstAddGroups.SelectedRowIndex < 0) Then Return "" + return lstAddGroups.SelectedRowText + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Function GetSelectedUserGroup() As String + If (lstUserGroups.SelectedRowIndex < 0) Then Return "" + Return lstUserGroups.CellTextAt(lstUserGroups.SelectedRowIndex, 0) + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Load() + Me.LoadUserGroups() + Me.LoadAddGroups() + + labTitle.Text = lstUserGroups.RowCount.ToString + " Groups for User " + esUsername + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadAddGroups() + lstAddGroups.RemoveAllRows + + Var sUserGroups() As String + For i As Integer = lstUserGroups.LastRowIndex DownTo 0 + sUserGroups.Add(lstUserGroups.CellTextAt(i, 0)) + Next + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + If (sUserGroups.IndexOf(rs.Column("groupname").StringValue) >= 0) Then + 'user already added to this group + rs.MoveToNextRow + Continue + End If + + lstAddGroups.AddRow(rs.Column("groupname").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + + If (lstAddGroups.LastRowIndex >= 0) Then lstAddGroups.SelectedRowIndex = 0 + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub LoadUserGroups() + lstUserGroups.RemoveAllRows + + Try + Var rs As RowSet = Session.DB.SelectSQL("SHOW GROUPS FOR USER '" + esUsername + "'") + If (rs = Nil) Then Return + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + lstUserGroups.AddRow(rs.Column("groupname").StringValue) + + rs.MoveToNextRow + Wend + End If + + rs.Close + + lstUserGroups.SelectedRowIndex = -1 + + Catch DatabaseException + + End Try + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub RefreshButtons() + Var sAddGroup As String = Me.GetSelectedAddGroup + Var bAddGroupSelected As Boolean = (sAddGroup <> "") + + Var bAddGroupAlreadyAssigned As Boolean = False + + If (sAddGroup <> "") Then + For i As Integer = lstUserGroups.LastRowIndex DownTo 0 + If (lstUserGroups.CellTextAt(i, 0) = sAddGroup) Then + bAddGroupAlreadyAssigned = True + Exit 'Loop + End If + Next + End If + + btnAdd.Enabled = bAddGroupSelected And (Not bAddGroupAlreadyAssigned) + + Var sRemoveGroup As String = Me.GetSelectedUserGroup() + Var bLoggedInUserRemovingAdminGroup As Boolean = (Session.DB.UserName = esUsername) And (sRemoveGroup = "admin") + btnRemove.Enabled = (sRemoveGroup <> "") And (Not bLoggedInUserRemovingAdminGroup) + + + End Sub + #tag EndMethod + + #tag Method, Flags = &h0 + Sub Show(Username As String) + esUsername = Username + + Me.Load() + + Me.RefreshButtons() + + Super.Show() + End Sub + #tag EndMethod + + + #tag Hook, Flags = &h0 + Event NeedsRefresh() + #tag EndHook + + + #tag Property, Flags = &h21 + Private ebNeedsRefresh As Boolean + #tag EndProperty + + #tag Property, Flags = &h21 + Private esUsername As String + #tag EndProperty + + +#tag EndWindowCode + +#tag Events btnAdd + #tag Event + Sub Pressed() + Var group As String = Self.GetSelectedAddGroup() + If (group = "") Then Return + + Try + + Session.DB.ExecuteSQL("ADD USER " + "'" + esUsername + "' TO GROUP '" + group + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Add User to Group" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not add user to group." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return + + End Try + + 'Success - no dialog + ebNeedsRefresh = True + Self.Load() + + For i As Integer = lstUserGroups.LastRowIndex DownTo 0 + If (lstUserGroups.CellTextAt(i, 0) = group) Then + lstUserGroups.SelectedRowIndex = i + Exit 'Loop + End If + Next + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnClose + #tag Event + Sub Pressed() + If ebNeedsRefresh Then NeedsRefresh + + Self.Close() + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstUserGroups + #tag Event + Sub SelectionChanged(rows() As Integer) + #Pragma unused rows + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events lstAddGroups + #tag Event + Sub SelectionChanged(item As WebMenuItem) + #Pragma unused item + + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnRemove + #tag Event + Sub Pressed() + Var group As String = Self.GetSelectedUserGroup() + If (group = "") Then Return + + Try + + Session.DB.ExecuteSQL("REMOVE USER " + "'" + esUsername + "' FROM GROUP '" + group + "'") + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Remove User from Group" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not remove user from group." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return + + End Try + + 'Success - no dialog + ebNeedsRefresh = True + Self.Load() + Self.RefreshButtons() + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=false + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/main/CubeSQLAdminPage.xojo_code b/webapp/main/CubeSQLAdminPage.xojo_code new file mode 100644 index 0000000..c68ff87 --- /dev/null +++ b/webapp/main/CubeSQLAdminPage.xojo_code @@ -0,0 +1,536 @@ +#tag WebPage +Begin WebPage CubeSQLAdminPage + AllowTabOrderWrap= True + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = False + Height = 400 + ImplicitInstance= False + Index = -2147483648 + Indicator = 0 + IsImplicitInstance= False + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + MinimumHeight = 400 + MinimumWidth = 600 + TabIndex = 0 + Title = "cubeSQL Admin" + Top = 0 + Visible = True + Width = 600 + _ImplicitInstance= False + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebToolbar tbrCubeSQLAdmin + ControlID = "" + Enabled = True + FullWidth = False + Height = 56 + Index = -2147483648 + Indicator = 8 + Left = 0 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Position = 0 + Scope = 2 + TabIndex = 0 + TabStop = True + Title = "" + Tooltip = "" + Top = 0 + Visible = True + Width = 600 + _mPanelIndex = -1 + End + Begin WebLabel labContainerTitle + Bold = True + ControlID = "" + Enabled = True + FontName = "" + FontSize = 18.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rctContainer" + Italic = False + Left = 0 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + Multiline = False + Parent = "nil" + Scope = 2 + TabIndex = 1 + TabStop = True + Text = "Container Title" + TextAlignment = 2 + TextColor = &c000000FF + Tooltip = "" + Top = 64 + Underline = False + Visible = True + Width = 600 + _mPanelIndex = -1 + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Opening() + Me.Title = "cubeSQL Admin - " + Session.DB.Host + ":" + Session.DB.Port.ToString + + me.ShowContainer(ContainerKey.Status) + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Sub CloseContainer() + If (Me.CurrentContainer <> Nil) Then + Me.CurrentContainer.Close + Me.CurrentContainer = Nil + me.CurrentContainerKey = ContainerKey.None + End If + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ShowContainer(containerItem As ContainerKey) + If (Me.CurrentContainer <> Nil) And (Me.CurrentContainerKey = containerItem) Then Return + + Var showContainer As cntBase + + Select Case containerItem + Case ContainerKey.Status + showContainer = New cntStatus + + Case ContainerKey.Registration + showContainer = New cntRegistration + + Case ContainerKey.Databases + showContainer = New cntDatabases + + Case ContainerKey.Groups + showContainer = New cntGroups + + Case ContainerKey.Users + showContainer = New cntUsers + + Case ContainerKey.Privileges + showContainer = new cntPrivileges + + Case ContainerKey.Console + showContainer = new cntConsole + + Case ContainerKey.Commands + showContainer = New cntCommands + + Case ContainerKey.Clients + showContainer = New cntClients + + Case ContainerKey.Log + showContainer = New cntLog + + End Select + + If (showContainer = Nil) Then Return + + Me.CloseContainer() + + labContainerTitle.Text = showContainer.Title + + Var top As Integer = labContainerTitle.Top + labContainerTitle.Height + showContainer.EmbedWithin(Self, 0, top, Self.Width, Self.Height - top) + + Me.CurrentContainer = showContainer + Me.CurrentContainerKey = containerItem + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private CurrentContainer As cntBase + #tag EndProperty + + #tag Property, Flags = &h21 + Private CurrentContainerKey As ContainerKey + #tag EndProperty + + +#tag EndWindowCode + +#tag Events tbrCubeSQLAdmin + #tag Event + Sub Opening() + Me.Indicator = WebUIControl.Indicators.Dark + Me.Style.BackgroundColor = Color.RGB(0,51,102) + Me.Style.ForegroundColor = Color.White + + Me.Title = "cubeSQL Admin" + Me.Icon = icon_128 + + Var btn As WebToolbarButton + + btn = New WebToolbarButton + btn.Style = WebToolbarButton.ButtonStyles.Menu + btn.Caption = "Server" + btn.Menu.AddMenuItem(New WebMenuItem("Registration", ContainerKey.Registration)) + btn.Menu.AddMenuItem(New WebMenuItem("Databases", ContainerKey.Databases)) + btn.Menu.AddMenuItem(New WebMenuItem("Console", ContainerKey.Console)) + Me.AddItem(btn) + + btn = New WebToolbarButton + btn.Style = WebToolbarButton.ButtonStyles.Menu + btn.Caption = "Security" + btn.Menu.AddMenuItem(New WebMenuItem("Groups", ContainerKey.Groups)) + btn.Menu.AddMenuItem(New WebMenuItem("Users", ContainerKey.Users)) + btn.Menu.AddMenuItem(New WebMenuItem("Privileges", ContainerKey.Privileges)) + Me.AddItem(btn) + + btn = New WebToolbarButton + btn.Style = WebToolbarButton.ButtonStyles.Menu + btn.Caption = "Information" + btn.Menu.AddMenuItem(New WebMenuItem("Commands", ContainerKey.Commands)) + btn.Menu.AddMenuItem(New WebMenuItem("Clients", ContainerKey.Clients)) + btn.Menu.AddMenuItem(New WebMenuItem("Log", ContainerKey.Log)) + Me.AddItem(btn) + + btn = New WebToolbarButton + btn.Style = WebToolbarButton.ButtonStyles.FlexibleSpace + Me.AddItem(btn) + + + btn = New WebToolbarButton + btn.Tag = "Logout" + 'btn.Icon = WebPicture.BootstrapIcon("escape", Color.White) + btn.Style = WebToolbarButton.ButtonStyles.PushButton + btn.Caption = "Logout" + Me.AddItem(btn) + + + End Sub + #tag EndEvent + #tag Event + Sub TitlePressed() + self.ShowContainer(ContainerKey.Status) + End Sub + #tag EndEvent + #tag Event + Sub Pressed(item As WebToolbarButton) + Select Case item.Tag + + Case "Logout" + Self.CloseContainer() + Session.Logout + Self.Close() + Return + + End Select + + + + End Sub + #tag EndEvent + #tag Event + Sub MenuSelected(item As WebToolbarButton, hitItem As WebMenuItem) + #Pragma unused item + + Self.ShowContainer(hitItem.Tag) + + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="MinimumHeight" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="MinimumWidth" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=true + Group="Behavior" + InitialValue="Untitled" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_ImplicitInstance" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="IsImplicitInstance" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="AllowTabOrderWrap" + Visible=false + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/main/LoginPage.xojo_code b/webapp/main/LoginPage.xojo_code new file mode 100644 index 0000000..4ffae30 --- /dev/null +++ b/webapp/main/LoginPage.xojo_code @@ -0,0 +1,1145 @@ +#tag WebPage +Begin WebPage LoginPage + AllowTabOrderWrap= True + Compatibility = "" + ControlCount = 0 + ControlID = "" + Enabled = False + Height = 518 + ImplicitInstance= False + Index = -2147483648 + Indicator = 0 + IsImplicitInstance= False + LayoutDirection = 0 + LayoutType = 0 + Left = 0 + LockBottom = False + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + MinimumHeight = 400 + MinimumWidth = 600 + TabIndex = 0 + Title = "cubeSQL Admin - Login" + Top = 0 + Visible = True + Width = 600 + _ImplicitInstance= False + _mDesignHeight = 0 + _mDesignWidth = 0 + _mName = "" + _mPanelIndex = -1 + Begin WebRectangle rectLogin + BackgroundColor = &cFFFFFF + ControlCount = 0 + ControlID = "" + Enabled = True + HasBackgroundColor= False + Height = 478 + Index = -2147483648 + Indicator = 0 + LayoutDirection = 0 + LayoutType = 0 + Left = 20 + LockBottom = False + LockedInPosition= True + LockHorizontal = True + LockLeft = False + LockRight = False + LockTop = True + LockVertical = False + Scope = 2 + TabIndex = 0 + TabStop = True + Tooltip = "" + Top = 20 + Visible = True + Width = 560 + _mDesignHeight = 0 + _mDesignWidth = 0 + _mPanelIndex = -1 + Begin WebLabel labHostname + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + Parent = "rectLogin" + Scope = 2 + TabIndex = 2 + TabPanelIndex = 0 + TabStop = True + Text = "Hostname:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 207 + Underline = False + Visible = True + Width = 166 + _mPanelIndex = -1 + End + Begin WebLabel labUsername + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rectLogin" + Scope = 2 + TabIndex = 4 + TabPanelIndex = 0 + TabStop = True + Text = "Username:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 253 + Underline = False + Visible = True + Width = 166 + _mPanelIndex = -1 + End + Begin WebLabel labPassword + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rectLogin" + Scope = 2 + TabIndex = 6 + TabPanelIndex = 0 + TabStop = True + Text = "Password:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 299 + Underline = False + Visible = True + Width = 166 + _mPanelIndex = -1 + End + Begin WebLabel labPort + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rectLogin" + Scope = 2 + TabIndex = 8 + TabPanelIndex = 0 + TabStop = True + Text = "Port:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 345 + Underline = False + Visible = True + Width = 166 + _mPanelIndex = -1 + End + Begin WebLabel labEncryption + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 0.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + PanelIndex = 0 + Parent = "rectLogin" + Scope = 2 + TabIndex = 10 + TabPanelIndex = 0 + TabStop = True + Text = "Encryption:" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 391 + Underline = False + Visible = True + Width = 166 + _mPanelIndex = -1 + End + Begin WebTextField edtHostname + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + Parent = "rectLogin" + ReadOnly = False + Scope = 2 + TabIndex = 3 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 207 + Visible = True + Width = 346 + _mPanelIndex = -1 + End + Begin WebTextField edtUsername + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 0 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rectLogin" + ReadOnly = False + Scope = 2 + TabIndex = 5 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 253 + Visible = True + Width = 346 + _mPanelIndex = -1 + End + Begin WebTextField edtPassword + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 1 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + Parent = "rectLogin" + ReadOnly = False + Scope = 2 + TabIndex = 7 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 299 + Visible = True + Width = 346 + _mPanelIndex = -1 + End + Begin WebTextField edtPort + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 3 + Height = 38 + Hint = "" + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rectLogin" + ReadOnly = False + Scope = 2 + TabIndex = 9 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 345 + Visible = True + Width = 150 + _mPanelIndex = -1 + End + Begin WebPopupMenu lstEncryption + ControlID = "" + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + InitialValue = "" + LastAddedRowIndex= 0 + LastRowIndex = 0 + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Parent = "rectLogin" + RowCount = 0 + Scope = 2 + SelectedRowIndex= 0 + SelectedRowText = "" + TabIndex = 11 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 391 + Visible = True + Width = 150 + _mPanelIndex = -1 + End + Begin WebImageViewer imgCubeSQL + ControlID = "" + DisplayMode = 0 + Enabled = True + Height = 128 + Image = 1922361343 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Left = 40 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Parent = "rectLogin" + Scope = 2 + SVGData = "" + TabIndex = 0 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 40 + URL = "" + Visible = True + Width = 128 + _mPanelIndex = -1 + _ProtectImage = False + End + Begin WebLabel labCubeSQL + Bold = False + ControlID = "" + Enabled = True + FontName = "" + FontSize = 32.0 + Height = 38 + Index = -2147483648 + Indicator = 0 + InitialParent = "rectLogin" + Italic = False + Left = 214 + LockBottom = False + LockedInPosition= True + LockHorizontal = False + LockLeft = True + LockRight = False + LockTop = True + LockVertical = False + Multiline = False + Parent = "rectLogin" + Scope = 2 + TabIndex = 1 + TabPanelIndex = 0 + TabStop = True + Text = "cubeSQL Admin" + TextAlignment = 0 + TextColor = &c000000FF + Tooltip = "" + Top = 81 + Underline = False + Visible = True + Width = 346 + _mPanelIndex = -1 + End + Begin WebButton btnConnect + AllowAutoDisable= False + Cancel = False + Caption = "Connect" + ControlID = "" + Default = True + Enabled = True + Height = 38 + Index = -2147483648 + Indicator = 1 + InitialParent = "rectLogin" + Left = 410 + LockBottom = True + LockedInPosition= True + LockHorizontal = False + LockLeft = False + LockRight = True + LockTop = False + LockVertical = False + Parent = "rectLogin" + Scope = 2 + TabIndex = 12 + TabPanelIndex = 0 + TabStop = True + Tooltip = "" + Top = 437 + Visible = True + Width = 150 + _mPanelIndex = -1 + End + Begin WebTextField edtSSLPemPwd + AllowAutoComplete= False + AllowSpellChecking= False + Caption = "" + ControlID = "" + Enabled = True + FieldType = 1 + Height = 38 + Hint = "SSL Cert: PEM Pwd" + Index = -2147483648 + Indicator = 0 + Left = 372 + LockBottom = False + LockedInPosition= False + LockHorizontal = False + LockLeft = True + LockRight = True + LockTop = True + LockVertical = False + MaximumCharactersAllowed= 0 + PanelIndex = 0 + Parent = "rectLogin" + ReadOnly = False + Scope = 2 + TabIndex = 13 + TabPanelIndex = 0 + TabStop = True + Text = "" + TextAlignment = 0 + Tooltip = "" + Top = 391 + Visible = False + Width = 188 + _mPanelIndex = -1 + End + End +End +#tag EndWebPage + +#tag WindowCode + #tag Event + Sub Opening() + Self.Prefill() + + End Sub + #tag EndEvent + + #tag Event + Sub Shown() + Self.Prefill() + ebShown = True + + End Sub + #tag EndEvent + + + #tag Method, Flags = &h21 + Private Function CheckAdmin(db As CubeSQLServer) As Boolean + If (db.UserName = "admin") Then Return True + + Try + Var rs As RowSet = db.SelectSQL("SHOW MY PRIVILEGES") + + If (rs = Nil) Then Return False + + If (rs.RowCount > 0) Then + rs.MoveToFirstRow + While (Not rs.AfterLastRow) + If (rs.Column("privilege").StringValue = "ADMIN") Then Return True + + rs.MoveToNextRow + Wend + End If + + rs.Close + + Return False + + Catch err As DatabaseException + Return False + + Finally + Return False + + End Try + + End Function + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Connect() + #Pragma BreakOnExceptions off + + Var db As New CubeSQLServer + + db.Host = edtHostname.Text.Trim + db.UserName = edtUsername.Text.Trim + db.Password = edtPassword.Text.Trim + db.Port = edtPort.Text.ToInteger + db.Encryption = lstEncryption.RowTagAt(lstEncryption.SelectedRowIndex) + db.Timeout = 10 + + Me.ConnectSSL(db) + + Try + If (Not db.Connect) Or (Not db.IsConnected) Then + Raise New DatabaseException(db.ErrMsg, db.ErrCode) + End If + + Catch err As DatabaseException + Var dialog As New WebMessageDialog + dialog.Title = "Connect" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Could not connect to cubeSQL." + dialog.Explanation = "Error" + If(err.ErrorNumber > 0, " " + err.ErrorNumber.ToString, "") + ": " + err.Message + dialog.Show + Return + + End Try + + If (Not Self.CheckAdmin(db)) Then + Var dialog As New WebMessageDialog + dialog.Title = "cubeSQL Admin Login" + dialog.Indicator = Indicators.Warning + dialog.ActionButton.Caption = "OK" + dialog.CancelButton.Visible = False + dialog.Message = "Insufficient privileges." + dialog.Explanation = "This application requires Admin privileges in order to function properly." + dialog.Show + Return + End If + + + If Session.Login(db) Then + 'Clear Password for next Login + 'Except if prefilled password + Var setUsername As String + Var setPassword As String + Me.Prefill_UserAndPwd(setUsername, setPassword) + If (edtUsername.Text.Trim <> setUsername) Or (edtPassword.Text.Trim <> setPassword) Then + edtPassword.Text = "" + End If + End If + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub ConnectSSL(db As CubeSQLServer) + #Pragma BreakOnExceptions off + + If (db.Encryption <> CubeSQLPlugin.kSSL) Then + db.SSLCertificate = Nil + db.RootCertificate = Nil + db.SSLCipherList = "" + Return + End If + + Var setSSLCertificate As String + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLCertificate", "CUBESQL_SSL_CERTIFICATE", setSSLCertificate) Then + Try + Var fileSSLCertificate As New FolderItem(setSSLCertificate, FolderItem.PathModes.Native) + If (fileSSLCertificate <> Nil) And fileSSLCertificate.Exists Then + db.SSLCertificate = fileSSLCertificate + End If + Catch err As IOException + Catch err As UnsupportedFormatException + End Try + End If + + Var setSSLCertificatePassword As String + If edtSSLPemPwd.Visible Then + setSSLCertificatePassword = edtSSLPemPwd.Text + db.SSLCertificatePassword = setSSLCertificatePassword.Trim + Else + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLCertificatePassword", "CUBESQL_SSL_CERTIFICATEPASSWORD", setSSLCertificatePassword) Then + Try + If setSSLCertificatePassword.EndsWith(".txt", ComparisonOptions.CaseInsensitive) Then + 'read from .txt file + Var fileSSLCertificatePassword As FolderItem = New FolderItem(setSSLCertificatePassword, FolderItem.PathModes.Native) + If (fileSSLCertificatePassword <> Nil) And fileSSLCertificatePassword.Exists Then + Try + Dim stream As TextInputStream = TextInputStream.Open(fileSSLCertificatePassword) + Dim s As String = stream.ReadAll(Encodings.UTF8) + stream.Close + + If (s.Trim <> "") Then db.SSLCertificatePassword = s.Trim + Catch e As IOException + End Try + End If + Else + 'use value + db.SSLCertificatePassword = setSSLCertificatePassword.Trim + End If + Catch err As IOException + Catch err As UnsupportedFormatException + End Try + End If + End If + + Var setRootCertificate As String + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLRootCertificate", "CUBESQL_SSL_ROOTCERTIFICATE", setRootCertificate) Then + Try + Var fileRootCertificate As New FolderItem(setRootCertificate, FolderItem.PathModes.Native) + If (fileRootCertificate <> Nil) And fileRootCertificate.Exists Then + db.RootCertificate = fileRootCertificate + End If + Catch err As IOException + Catch err As UnsupportedFormatException + End Try + End If + + + Var setSSLCipherList As String + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLCipherList", "CUBESQL_SSL_CIPHERLIST", setSSLCipherList) Then + Try + If setSSLCipherList.EndsWith(".txt", ComparisonOptions.CaseInsensitive) Then + 'read from .txt file + Var fileSSLCipherList As FolderItem = New FolderItem(setSSLCipherList, FolderItem.PathModes.Native) + If (fileSSLCipherList <> Nil) And fileSSLCipherList.Exists Then + Try + Dim stream As TextInputStream = TextInputStream.Open(fileSSLCipherList) + Dim s As String = stream.ReadAll(Encodings.UTF8) + stream.Close + + If (s.Trim <> "") Then db.SSLCipherList = s.Trim + Catch e As IOException + End Try + End If + Else + 'use value + db.SSLCipherList = setSSLCipherList.Trim + End If + Catch err As IOException + Catch err As UnsupportedFormatException + End Try + End If + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Prefill() + If ebShown Then Return + + Var setHostname As String + If (Not modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLHostname", "CUBESQL_HOSTNAME", setHostname)) Then + setHostname = "localhost" + End If + + Var setPort As String + If (Not modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLPort", "CUBESQL_PORT", setPort)) Then + setPort = "4430" + End If + If (setPort.ToInteger < 1) Then setPort = "4430" + + Var setEncryption As String + If (Not modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLEncryption", "CUBESQL_ENCRYPTION", setEncryption)) Then + setEncryption = "AES256" + End If + + Var setUsername As String + Var setPassword As String + Me.Prefill_UserAndPwd(setUsername, setPassword) + + edtHostname.Text = setHostname + edtPort.Text = setPort + edtUsername.Text = setUsername + edtPassword.Text = setPassword + + Select Case setEncryption + + Case "NONE" + lstEncryption.SelectRowWithTag(CubeSQLPlugin.kAESNONE) + + Case "AES128" + lstEncryption.SelectRowWithTag(CubeSQLPlugin.kAES128) + + Case "AES256" + lstEncryption.SelectRowWithTag(CubeSQLPlugin.kAES256) + + Case "SSL" + lstEncryption.SelectRowWithTag(CubeSQLPlugin.kSSL) + + End Select + + End Sub + #tag EndMethod + + #tag Method, Flags = &h21 + Private Sub Prefill_UserAndPwd(ByRef setUsername As String, ByRef setPassword As String) + setUsername = "" + setPassword = "" + + Var bUsernameIsSet As Boolean = True + If (Not modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLUsername", "CUBESQL_USERNAME", setUsername)) Then + bUsernameIsSet = False + setUsername = "admin" + End If + + If bUsernameIsSet Then + If (Not modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLPassword", "CUBESQL_PASSWORD", setPassword)) Then + 'never prefill a default password + 'except in DebugBuild - see above + End If + End If + + End Sub + #tag EndMethod + + + #tag Property, Flags = &h21 + Private ebShown As Boolean + #tag EndProperty + + +#tag EndWindowCode + +#tag Events lstEncryption + #tag Event + Sub Opening() + Me.RemoveAllRows + + Me.AddRow("NONE", CubeSQLPlugin.kAESNONE) + Me.AddRow("AES128", CubeSQLPlugin.kAES128) + Me.AddRow("AES256", CubeSQLPlugin.kAES256) + Me.AddRow("SSL", CubeSQLPlugin.kSSL) + + Me.SelectRowWithTag(CubeSQLPlugin.kAES256) + + End Sub + #tag EndEvent + #tag Event + Sub SelectionChanged(item As WebMenuItem) + Dim bSSLPemPwdVisible As Boolean = False + + If (Me.RowTagAt(Me.SelectedRowIndex) = CubeSQLPlugin.kSSL) Then + Var setSSLCertificate As String + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLCertificate", "CUBESQL_SSL_CERTIFICATE", setSSLCertificate) Then + bSSLPemPwdVisible = True + + Var setSSLCertificatePassword As String + If modCubeSQLAdmin.LaunchArgumentGetValue("--CubeSQLSSLCertificatePassword", "CUBESQL_SSL_CERTIFICATEPASSWORD", setSSLCertificatePassword) Then + bSSLPemPwdVisible = False + End If + End If + End If + + edtSSLPemPwd.Visible = bSSLPemPwdVisible + + End Sub + #tag EndEvent +#tag EndEvents +#tag Events btnConnect + #tag Event + Sub Pressed() + self.Connect() + End Sub + #tag EndEvent +#tag EndEvents +#tag ViewBehavior + #tag ViewProperty + Name="ControlCount" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mPanelIndex" + Visible=false + Group="Behavior" + InitialValue="-1" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="ControlID" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Enabled" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Height" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LayoutType" + Visible=true + Group="Behavior" + InitialValue="LayoutTypes.Fixed" + Type="LayoutTypes" + EditorType="Enum" + #tag EnumValues + "0 - Fixed" + "1 - Flex" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LockBottom" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockHorizontal" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockLeft" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockRight" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockTop" + Visible=true + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="LockVertical" + Visible=true + Group="Behavior" + InitialValue="False" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="MinimumHeight" + Visible=true + Group="Behavior" + InitialValue="400" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="MinimumWidth" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Title" + Visible=true + Group="Behavior" + InitialValue="Untitled" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="Visible" + Visible=false + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Width" + Visible=true + Group="Behavior" + InitialValue="600" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_ImplicitInstance" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignHeight" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mDesignWidth" + Visible=false + Group="Behavior" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="_mName" + Visible=false + Group="Behavior" + InitialValue="" + Type="String" + EditorType="MultiLineEditor" + #tag EndViewProperty + #tag ViewProperty + Name="IsImplicitInstance" + Visible=false + Group="Behavior" + InitialValue="" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="AllowTabOrderWrap" + Visible=false + Group="Behavior" + InitialValue="True" + Type="Boolean" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="TabIndex" + Visible=true + Group="Visual Controls" + InitialValue="" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Indicator" + Visible=false + Group="Visual Controls" + InitialValue="" + Type="WebUIControl.Indicators" + EditorType="Enum" + #tag EnumValues + "0 - Default" + "1 - Primary" + "2 - Secondary" + "3 - Success" + "4 - Danger" + "5 - Warning" + "6 - Info" + "7 - Light" + "8 - Dark" + "9 - Link" + #tag EndEnumValues + #tag EndViewProperty + #tag ViewProperty + Name="LayoutDirection" + Visible=true + Group="WebView" + InitialValue="LayoutDirections.LeftToRight" + Type="LayoutDirections" + EditorType="Enum" + #tag EnumValues + "0 - LeftToRight" + "1 - RightToLeft" + "2 - TopToBottom" + "3 - BottomToTop" + #tag EndEnumValues + #tag EndViewProperty +#tag EndViewBehavior diff --git a/webapp/modCubeSQLAdmin.xojo_code b/webapp/modCubeSQLAdmin.xojo_code new file mode 100644 index 0000000..f2a7672 --- /dev/null +++ b/webapp/modCubeSQLAdmin.xojo_code @@ -0,0 +1,118 @@ +#tag Module +Protected Module modCubeSQLAdmin + #tag Method, Flags = &h1 + Protected Function LaunchArgumentGetValue(argKey As String, envKey As String, ByRef argValue As String) As Boolean + // Gets the Launch Argument from + // 1. Launch Argument + // 2. Environment Variable + + argValue = dictArgs.Lookup(argKey, "").StringValue.Trim + If (argValue = "") Then argValue = System.EnvironmentVariable(envKey).Trim + + Return (argValue <> "") + + End Function + #tag EndMethod + + #tag Method, Flags = &h1, Description = 436F6E766572747320636F6D6D616E64206C696E6520617267756D656E747320746F20612064696374696F6E6172792E2045616368206B657920697320616E20617267756D656E74206E616D6520616E642074686520636F72726573706F6E64696E672076616C75652069732074686520617267756D656E742076616C75652E + Protected Sub StoreLaunchArguments(args() As String) + dictArgs = New Dictionary + + If (args = Nil) Then Return + + For Each argument As String In args + Var argParts() As String = argument.Split("=") + Var name As String = argParts(0) + Var value As String = If(argParts.LastIndex = 1, argParts(1), "") + + dictArgs.value(Name) = value + Next + + End Sub + #tag EndMethod + + + #tag ComputedProperty, Flags = &h21 + #tag Getter + Get + If (mdictArgs = Nil) Then Return New Dictionary + + Return mdictArgs + End Get + #tag EndGetter + #tag Setter + Set + mdictArgs = value + End Set + #tag EndSetter + Private dictArgs As Dictionary + #tag EndComputedProperty + + #tag Property, Flags = &h21 + Private mdictArgs As Dictionary + #tag EndProperty + + + #tag Constant, Name = constUrl_DeveloperKey, Type = String, Dynamic = False, Default = \"https://www.sqlabs.com/cubesql_devkey.php", Scope = Public + #tag EndConstant + + + #tag Enum, Name = ContainerKey, Type = Integer, Flags = &h0 + Status = 0 + Databases = 2 + Groups = 11 + Console = 3 + Registration=1 + None = -1 + Privileges = 13 + Commands = 21 + Log = 23 + Users = 12 + Clients = 22 + #tag EndEnum + + + #tag ViewBehavior + #tag ViewProperty + Name="Name" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Index" + Visible=true + Group="ID" + InitialValue="-2147483648" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Super" + Visible=true + Group="ID" + InitialValue="" + Type="String" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Left" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag ViewProperty + Name="Top" + Visible=true + Group="Position" + InitialValue="0" + Type="Integer" + EditorType="" + #tag EndViewProperty + #tag EndViewBehavior +End Module +#tag EndModule