-
Notifications
You must be signed in to change notification settings - Fork 1
Fixed some problems #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Antonio171003
wants to merge
13
commits into
wiringbits:main
Choose a base branch
from
Antonio171003:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d049867
Update React-Admin version to '4.14.4'
Antonio171003 112e1a5
Added tables from DB
Antonio171003 f6e188c
Fixed the filter functionality when the parameter is a reference.
Antonio171003 abc5068
Fixed an Internal Server Error, Caused when attempting to filter by a…
Antonio171003 70ee180
Fixed : Failed prop type: Invalid prop `children` of type `array` sup…
Antonio171003 39daeb2
Format
Antonio171003 d874d43
Revert "Added tables from DB"
Antonio171003 d401e5f
Fixed Internal server error
Antonio171003 5cbf089
Corrections to the filter
Antonio171003 16ba68d
Fixed Internal server error
Antonio171003 5806701
Fixed bugs related to image handling (saving and reading).
Antonio171003 ef10525
Changes required for the PR
Antonio171003 9aa43c4
Changes required for the PR
Antonio171003 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
spra-play-server/src/main/scala/net/wiringbits/spra/admin/models/FieldValue.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.wiringbits.spra.admin.models | ||
|
||
trait FieldValue[T] extends Serializable { | ||
val value: T | ||
} | ||
|
||
case class StringValue(value: String) extends FieldValue[String] | ||
case class ByteArrayValue(value: Array[Byte]) extends FieldValue[Array[Byte]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
spra-play-server/src/main/scala/net/wiringbits/spra/admin/utils/StringParse.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.wiringbits.spra.admin.utils | ||
|
||
import scala.util.{Failure, Success, Try} | ||
|
||
object StringParse { | ||
|
||
def stringToByteArray(value: String): Array[Byte] = { | ||
// Removes whitespace characters (\\s) and brackets ([, ]) to prepare the string for byte array conversion | ||
Try(value.replaceAll("[\\[\\]\\s]", "").split(",").map(_.toByte)) match | ||
case Success(value) => value | ||
case Failure(_) => Array.emptyByteArray | ||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/DataProvider.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
package net.wiringbits.spra.ui.web.facades | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.JSImport | ||
|
||
@js.native | ||
trait DataProvider extends js.Object | ||
|
||
@js.native | ||
@JSImport("ra-data-simple-rest", JSImport.Default) | ||
Antonio171003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// https://www.npmjs.com/package/ra-data-simple-rest | ||
def simpleRestProvider(url: String): DataProvider = js.native | ||
|
||
@js.native | ||
@JSImport("react-admin", "withLifecycleCallbacks") | ||
Antonio171003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// https://marmelab.com/react-admin/withLifecycleCallbacks.html | ||
object WithLifecycleCallbacks extends js.Object { | ||
def apply(dataProvider: DataProvider, callbacks: js.Array[js.Object]): DataProvider = js.native | ||
} |
31 changes: 27 additions & 4 deletions
31
spra-web/src/main/scala/net/wiringbits/spra/ui/web/facades/package.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
package net.wiringbits.spra.ui.web | ||
|
||
import scala.scalajs.js | ||
import scala.scalajs.js.annotation.JSImport | ||
import net.wiringbits.spra.ui.web.utils.Images.* | ||
import org.scalajs.dom.File | ||
|
||
package object facades { | ||
@js.native | ||
@JSImport("ra-data-simple-rest", JSImport.Default) | ||
def simpleRestProvider(url: String): DataProvider = js.native | ||
|
||
def createDataProvider(url: String): DataProvider = { | ||
val baseDataProvider = simpleRestProvider(url) | ||
WithLifecycleCallbacks( | ||
baseDataProvider, | ||
js.Array( | ||
js.Dynamic.literal( | ||
resource = "images", | ||
afterRead = (record: js.Dynamic, dataProvider: js.Any) => { | ||
val hexImage = record.data.asInstanceOf[String] | ||
val urlImage = convertHexToImage(hexImage) | ||
record.updateDynamic("data")(urlImage) | ||
record | ||
}, | ||
beforeSave = (data: js.Dynamic, dataProvider: js.Any) => { | ||
val rawFile = data.data.rawFile.asInstanceOf[File] | ||
convertImageToByteArray(rawFile).`then` { value => | ||
data.updateDynamic("data")(value.asInstanceOf[js.Any]) | ||
data | ||
} | ||
} | ||
) | ||
) | ||
) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.