Skip to content

Commit

Permalink
Develop (#1)
Browse files Browse the repository at this point in the history
* Refactor strings resource and update dependencies

Moved strings resources from the "launchpad" module to the "commonCompose" module and updated Compose and AndroidX versions. Additionally, the "app" module was added to settings.gradle.kts and the new module's build file structure was introduced. This change provides a unified location for storing string resources across modules and keeps the dependencies up to date.

* Update JVM toolchain, plugin version, and upgrade dependencies

JVM toolchain has been updated to use libs.versions.java and vendor was set to JvmVendorSpec.AZUL on shared, pdnsClient and server build files. Foojay resolver convention plugin was added to settings.gradle.kts. Java version in libs.versions file has been bumped up to 17 and ktor version has been updated to 2.3.10. This improves the toolchain control and keeps the project up-to-date with the latest stable versions of the plugins and dependencies.

* Add new database migration for pdns scheme

The new file 'pdns.ts' within database migrations has been created. This migration file includes definitions for new tables (domains, records, supermasters, comments, domainmetadata, cryptokeys, tsigkeys) and associated indexes in the database. Corresponding 'up' and 'down' methods have been written to handle the creation and removal of these tables and indexes.

* Update resource package name and add Github workflow

Updated the package name of resources in the build.gradle.kts, TextField.kt, Res.kt, LoginScreen.kt, RegisterScreen.kt, and Screen.kt files from 'pdnsmanager.commoncompose.resources' to 'pdnsmanager.commonCompose.resources'. Added Github workflow 'page-release.yml' for building and pushing Wasm Assets on every published release.
  • Loading branch information
mdsadiqueinam authored Apr 13, 2024
1 parent 2841b52 commit bb263c5
Show file tree
Hide file tree
Showing 20 changed files with 341 additions and 62 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/page-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Wasm Assets

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest # Adjust OS if needed
steps:
- uses: actions/checkout@v4 # Checkout the source code

- name: Run Gradle Build
run: ./gradlew :launchpad:wasmJsBrowserProductionWebpack

- name: Extract Wasm Assets
run: |
# Assuming launchpad/build/dist/wasmJs/productionExecutable exists after build
mkdir -p ./wasmJs # Create a folder to store extracted assets locally
cp -r launchpad/build/dist/wasmJs/productionExecutable/* ./wasmJs/
- name: Checkout Destination Repo (shallow clone)
uses: actions/checkout@v4 # Checkout the destination repository (shallow clone)
with:
repository: https://github.com/mdsadique-inam/launchpad
ref: main # Adjust branch if needed
token: ${{ secrets.PUSH_TOKEN }} # Use a secret for access token
fetch-depth: 1 # Only download the latest commit for efficiency

- name: Push Wasm Assets to /docs
run: |
git config user.name "mdsadique-inam" # Replace with your name
git config user.email "[email protected]" # Replace with your email
git checkout -b main # Create a new branch (replace with desired branch)
mv ./wasmJs/* ./docs/ # Move extracted assets to /docs folder
git add docs/ # Add the /docs folder to Git
git commit -m "Update Wasm assets from build"
git push origin main # Push the new branch
74 changes: 74 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.jetbrainsCompose)
alias(libs.plugins.serialization)
}

kotlin {
@OptIn(ExperimentalWasmDsl::class)
wasmJs {
moduleName = "app"
browser {
commonWebpackConfig {
outputFileName = "app.js"
devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
static = (static ?: mutableListOf()).apply {
// Serve sources to debug inside browser
add(project.projectDir.path)
add(project.projectDir.path + "/commonMain/")
add(project.projectDir.path + "/wasmJsMain/")
}
proxy = (proxy ?: mutableMapOf()).apply {
put("/api", mapOf(
"target" to "http://localhost:8000",
"pathRewrite" to mapOf(
"/api" to ""
)
))
}
}
}
}
binaries.executable()
}

sourceSets {
all {
languageSettings {
optIn("androidx.compose.material3.ExperimentalMaterial3Api")
optIn("org.jetbrains.compose.resources.ExperimentalResourceApi")
}
}

commonMain.dependencies {
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.ui)
implementation(compose.components.uiToolingPreview)
implementation(compose.components.resources)
implementation(compose.materialIconsExtended)
implementation(projects.commonCompose)
implementation(projects.shared)
implementation(projects.pdnsClient)
implementation(projects.koinCompose)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.navigation.compose)
implementation(libs.bundles.ktor.client)
implementation(libs.kotlinx.serialization.core)
implementation(libs.kotlinx.coroutines.core)
}
val wasmJsMain by getting {
dependencies {
implementation(libs.bundles.ktor.client.wasm)
}
}
}
}

compose.experimental {
web.application {}
}
Empty file.
6 changes: 6 additions & 0 deletions commonCompose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,10 @@ kotlin {

compose.experimental {
web.application {}
}

compose.resources {
publicResClass = true
packageOfResClass = "pdnsmanager.commonCompose.resources"
generateResClass = auto
}
15 changes: 14 additions & 1 deletion commonCompose/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<resources>
<string name="error">Error</string>
<string name="login">Login</string>
<string name="login_to_powerdns_manager">Login to PowerDNS manager</string>
<string name="register">Register</string>
<string name="create_an_account_in_powerdns_manager">Create an account in PowerDNS manager</string>
<string name="icon_warning">Icon warning</string>
<string name="show_password">Show Password</string>
<string name="hide_password">Hide Password</string>
<string name="error">Error</string>
<string name="dont_have_an_account_create_one">Don't have an account? Create one</string>
<string name="signup">Sign Up</string>
<string name="full_name">Full Name</string>
<string name="username">Username</string>
<string name="email">Email</string>
<string name="password">Password</string>
<string name="confirm_password">Confirm Password</string>
<string name="username_or_email">Username / Email</string>
<string name="already_have_an_account_login">Already have an account? Login</string>
</resources>
19 changes: 15 additions & 4 deletions commonCompose/src/commonMain/kotlin/ui/components/Button.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package ui.components

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButtonColors
import androidx.compose.material3.IconButtonDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon
Expand Down Expand Up @@ -60,6 +57,20 @@ fun PMCTextButton(
}
}


@Composable
fun PMCTextButton(
text: String,
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
loading: Boolean = false,
) {
PMCTextButton(onClick = onClick, modifier = modifier, enabled = enabled, loading = loading) {
Text(text)
}
}

@Composable
fun PMCIconButton(
onClick: () -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import org.jetbrains.compose.resources.stringResource
import pdnsmanager.commoncompose.generated.resources.Res
import pdnsmanager.commoncompose.generated.resources.hide_password
import pdnsmanager.commoncompose.generated.resources.show_password
import pdnsmanager.commonCompose.resources.Res
import pdnsmanager.commonCompose.resources.error
import pdnsmanager.commonCompose.resources.hide_password
import pdnsmanager.commonCompose.resources.show_password

@Composable
fun PMCOutlinedTextField(
Expand Down Expand Up @@ -74,7 +75,7 @@ fun PMCOutlinedTextField(
verticalAlignment = Alignment.CenterVertically
) {
if (isError) {
Icon(Icons.Filled.Error, "error", tint = MaterialTheme.colorScheme.error)
Icon(Icons.Filled.Error, stringResource(Res.string.error), tint = MaterialTheme.colorScheme.error)
}
trailingIcon?.invoke()
}
Expand Down
2 changes: 1 addition & 1 deletion commonCompose/src/commonMain/kotlin/ui/states/Res.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import org.jetbrains.compose.resources.ExperimentalResourceApi
import pdnsmanager.commoncompose.generated.resources.Res
import pdnsmanager.commonCompose.resources.Res

@OptIn(ExperimentalResourceApi::class)
@Composable
Expand Down
130 changes: 130 additions & 0 deletions database/migrations/20240304093131_pdns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import type { Knex } from "knex";

export async function up(knex: Knex): Promise<any> {
return knex.schema.raw(`
CREATE TABLE domains (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
master VARCHAR(128) DEFAULT NULL,
last_check INT DEFAULT NULL,
type TEXT NOT NULL,
notified_serial BIGINT DEFAULT NULL,
account VARCHAR(40) DEFAULT NULL,
options TEXT DEFAULT NULL,
catalog TEXT DEFAULT NULL,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
);
CREATE UNIQUE INDEX name_index ON domains(name);
CREATE INDEX catalog_idx ON domains(catalog);
CREATE TABLE records (
id BIGSERIAL PRIMARY KEY,
domain_id INT DEFAULT NULL,
name VARCHAR(255) DEFAULT NULL,
type VARCHAR(10) DEFAULT NULL,
content VARCHAR(65535) DEFAULT NULL,
ttl INT DEFAULT NULL,
prio INT DEFAULT NULL,
disabled BOOL DEFAULT 'f',
ordername VARCHAR(255),
auth BOOL DEFAULT 't',
CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id)
ON DELETE CASCADE,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
);
CREATE INDEX rec_name_index ON records(name);
CREATE INDEX nametype_index ON records(name,type);
CREATE INDEX domain_id ON records(domain_id);
CREATE INDEX recordorder ON records (domain_id, ordername text_pattern_ops);
CREATE TABLE supermasters (
ip INET NOT NULL,
nameserver VARCHAR(255) NOT NULL,
account VARCHAR(40) NOT NULL,
PRIMARY KEY(ip, nameserver)
);
CREATE TABLE comments (
id SERIAL PRIMARY KEY,
domain_id INT NOT NULL,
name VARCHAR(255) NOT NULL,
type VARCHAR(10) NOT NULL,
modified_at INT NOT NULL,
account VARCHAR(40) DEFAULT NULL,
comment VARCHAR(65535) NOT NULL,
CONSTRAINT domain_exists
FOREIGN KEY(domain_id) REFERENCES domains(id)
ON DELETE CASCADE,
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
);
CREATE INDEX comments_domain_id_idx ON comments (domain_id);
CREATE INDEX comments_name_type_idx ON comments (name, type);
CREATE INDEX comments_order_idx ON comments (domain_id, modified_at);
CREATE TABLE domainmetadata (
id SERIAL PRIMARY KEY,
domain_id INT REFERENCES domains(id) ON DELETE CASCADE,
kind VARCHAR(32),
content TEXT
);
CREATE INDEX domainidmetaindex ON domainmetadata(domain_id);
CREATE TABLE cryptokeys (
id SERIAL PRIMARY KEY,
domain_id INT REFERENCES domains(id) ON DELETE CASCADE,
flags INT NOT NULL,
active BOOL,
published BOOL DEFAULT TRUE,
content TEXT
);
CREATE INDEX domainidindex ON cryptokeys(domain_id);
CREATE TABLE tsigkeys (
id SERIAL PRIMARY KEY,
name VARCHAR(255),
algorithm VARCHAR(50),
secret VARCHAR(255),
CONSTRAINT c_lowercase_name CHECK (((name)::TEXT = LOWER((name)::TEXT)))
);
CREATE UNIQUE INDEX namealgoindex ON tsigkeys(name, algorithm);
`)
}


export async function down(knex: Knex): Promise<any> {
return knex.schema.raw(`
DROP INDEX namealgoindex;
DROP TABLE tsigkeys;
DROP INDEX domainidindex;
DROP TABLE cryptokeys;
DROP INDEX domainidmetaindex;
DROP TABLE domainmetadata;
DROP INDEX comments_order_idx;
DROP INDEX comments_name_type_idx;
DROP INDEX comments_domain_id_idx;
DROP TABLE comments;
DROP TABLE supermasters;
DROP INDEX recordorder;
DROP INDEX domain_id;
DROP INDEX nametype_index;
DROP INDEX rec_name_index;
DROP TABLE records;
DROP INDEX catalog_idx;
DROP INDEX name_index;
DROP INDEX domains;
`)
}

7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[versions]
java = "VERSION_17"
agp = "8.2.0"
compose = "1.6.10-dev1557"
androidx = "2.8.0-dev1557"
compose = "1.6.10-dev1580"
androidx = "2.8.0-dev1580"
junit = "4.13.2"
kotlin = "1.9.23"
kotlinx-serialization = "1.6.3"
coroutines = "1.8.0"
ktor = "2.3.9"
ktor = "2.3.10"
ktor-wasm = "3.0.0-wasm2"
exposed = "0.48.0"
postgres = "42.7.3"
Expand Down
17 changes: 1 addition & 16 deletions launchpad/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
<resources>
<string name="login">Login</string>
<string name="login_to_powerdns_manager">Login to PowerDNS manager</string>
<string name="register">Register</string>
<string name="create_an_account_in_powerdns_manager">Create an account in PowerDNS manager</string>
<string name="icon_warning">Icon warning</string>
<string name="show_password">Show Password</string>
<string name="hide_password">Hide Password</string>
<string name="dont_have_an_account_create_one">Don't have an account? Create one</string>
<string name="signup">Sign Up</string>
<string name="full_name">Full Name</string>
<string name="username">Username</string>
<string name="email">Email</string>
<string name="password">Password</string>
<string name="confirm_password">Confirm Password</string>
<string name="username_or_email">Username / Email</string>
<string name="already_have_an_account_login">Already have an account? Login</string>

</resources>
Loading

0 comments on commit bb263c5

Please sign in to comment.