added nim compilation task to sbt deploy task
switched to fake form with POST method for file download
This commit is contained in:
25
build.sbt
25
build.sbt
@@ -1,3 +1,5 @@
|
|||||||
|
import xsbti.compile.CompileAnalysis
|
||||||
|
|
||||||
name := "jpacrepo"
|
name := "jpacrepo"
|
||||||
|
|
||||||
organization := "com.oggio88"
|
organization := "com.oggio88"
|
||||||
@@ -44,6 +46,26 @@ artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) =>
|
|||||||
|
|
||||||
//javacOptions += "-g"
|
//javacOptions += "-g"
|
||||||
|
|
||||||
|
val compileNim = TaskKey[File]("compileNim", "Compile nim code of web interface", KeyRanks.ATask)
|
||||||
|
compileNim := {
|
||||||
|
val result = new File("src/main/webapp/jpacrepo.js")
|
||||||
|
val cmd = s"nim js -d:release -d:serverURL= -o:${result.getPath} nim/jpacrepo.nim"
|
||||||
|
println(cmd)
|
||||||
|
sys.process.stringToProcess(cmd).! match
|
||||||
|
{
|
||||||
|
case 0 =>
|
||||||
|
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
//compile in Compile <+= compileNim
|
||||||
|
packagedArtifact in(Compile, Keys.`package`) := {
|
||||||
|
val res = (packagedArtifact in(Compile, Keys.`package`)).value
|
||||||
|
val res2 = compileNim.value
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
val wildflyUsername = SettingKey[String]("wildfly-username", "The account username to use to connect to wildfly with jboss-cli.sh")
|
val wildflyUsername = SettingKey[String]("wildfly-username", "The account username to use to connect to wildfly with jboss-cli.sh")
|
||||||
val wildflyPassword = SettingKey[String]("wildfly-password", "The account password to use to connect to wildfly with jboss-cli.sh")
|
val wildflyPassword = SettingKey[String]("wildfly-password", "The account password to use to connect to wildfly with jboss-cli.sh")
|
||||||
val wildflyURL = SettingKey[String]("wildfly-url", "The username to use to connect to wildfly with jboss-cli.sh")
|
val wildflyURL = SettingKey[String]("wildfly-url", "The username to use to connect to wildfly with jboss-cli.sh")
|
||||||
@@ -54,7 +76,6 @@ wildflyURL := "localhost:1234"
|
|||||||
|
|
||||||
val deploy2Wildfly = TaskKey[Unit]("deploy2Wildfly", "Deploy to a wildfly server instance", KeyRanks.ATask)
|
val deploy2Wildfly = TaskKey[Unit]("deploy2Wildfly", "Deploy to a wildfly server instance", KeyRanks.ATask)
|
||||||
|
|
||||||
|
|
||||||
deploy2Wildfly := {
|
deploy2Wildfly := {
|
||||||
val cmd = s"/opt/wildfly/bin/jboss-cli.sh " +
|
val cmd = s"/opt/wildfly/bin/jboss-cli.sh " +
|
||||||
s"--controller='${wildflyURL.value}' " +
|
s"--controller='${wildflyURL.value}' " +
|
||||||
@@ -64,7 +85,7 @@ deploy2Wildfly := {
|
|||||||
println(cmd)
|
println(cmd)
|
||||||
sys.process.stringToProcess(cmd).! match
|
sys.process.stringToProcess(cmd).! match
|
||||||
{
|
{
|
||||||
case 0 => "OK"
|
case 0 =>
|
||||||
case _ => throw new RuntimeException("Error occurred during deploy")
|
case _ => throw new RuntimeException("Error occurred during deploy")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Submodule nim/htmlutils updated: 4e52526abb...366e6f0be1
@@ -9,6 +9,8 @@ from sequtils import map, apply
|
|||||||
|
|
||||||
var pkgMap : JsonNode
|
var pkgMap : JsonNode
|
||||||
|
|
||||||
|
const serverURL {.strdefine.}: string = "http://oggio88.soon.it/jpacrepo/"
|
||||||
|
|
||||||
type DownloadPanel = ref object
|
type DownloadPanel = ref object
|
||||||
badge : Node
|
badge : Node
|
||||||
listgroup : Node
|
listgroup : Node
|
||||||
@@ -52,22 +54,18 @@ proc newDownloadPanel(parent : Node) : DownloadPanel =
|
|||||||
node.appendChild(document.createTextNode(" Download"))
|
node.appendChild(document.createTextNode(" Download"))
|
||||||
let clickHandler = proc(e : Event) =
|
let clickHandler = proc(e : Event) =
|
||||||
let pkglist : seq[string] = sequtils.toSeq(dp.pkgs.items())
|
let pkglist : seq[string] = sequtils.toSeq(dp.pkgs.items())
|
||||||
let r = newXMLHTTPRequest()
|
let form = cast[Formelement](document.createElement("form"))
|
||||||
let load_cb = proc(e : Event) =
|
form.style.display = "none"
|
||||||
var blob : Blob = r.responseAsBlob #newBlob(r.response, "application/x-tar")
|
form.setAttribute("method", "post")
|
||||||
let anchor = document.createElement("a")
|
form.setAttribute("action", serverURL & "rest/pkg/downloadTar")
|
||||||
let url = createObjectURL(blob)
|
let tf= document.createElement("input")
|
||||||
anchor.setAttribute("href", url)
|
tf.setAttribute("name", "pkgs")
|
||||||
anchor.setAttribute("download", "archive.tar")
|
let txt = sequtils.foldl(pkglist, a & " " & b)
|
||||||
anchor.click()
|
echo txt
|
||||||
revokeObjectURL(url)
|
tf.value(txt)
|
||||||
r.addEventListener("load", load_cb)
|
form.appendChild(tf)
|
||||||
r.open("post", "rest/pkg/downloadTar")
|
document.body.appendChild(form)
|
||||||
r.responseType = "blob"
|
form.submit()
|
||||||
r.setRequestHeader("Accept", "application/x-tar")
|
|
||||||
r.setRequestHeader("Content-Type", "application/json")
|
|
||||||
r.send($(%*pkglist))
|
|
||||||
|
|
||||||
node.addEventListener("click", clickHandler)
|
node.addEventListener("click", clickHandler)
|
||||||
cb:
|
cb:
|
||||||
dp.footer = node
|
dp.footer = node
|
||||||
@@ -269,7 +267,6 @@ htmlDocument document, document.body:
|
|||||||
class ["col-sm-9"]
|
class ["col-sm-9"]
|
||||||
cb:
|
cb:
|
||||||
table = node
|
table = node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -277,6 +274,6 @@ let r = newXMLHTTPRequest()
|
|||||||
let load_cb = proc(e : Event) =
|
let load_cb = proc(e : Event) =
|
||||||
pkgMap = parseJson($r.responseText)
|
pkgMap = parseJson($r.responseText)
|
||||||
r.addEventListener("load", load_cb)
|
r.addEventListener("load", load_cb)
|
||||||
r.open("get", "rest/pkg/map")
|
r.open("get", serverURL & "rest/pkg/map")
|
||||||
r.setRequestHeader("Accept", "application/json")
|
r.setRequestHeader("Accept", "application/json")
|
||||||
r.send()
|
r.send()
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.0")
|
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.0")
|
||||||
|
|
||||||
|
@@ -363,8 +363,10 @@ public class PacmanWebService
|
|||||||
@POST
|
@POST
|
||||||
@Path("/downloadTar")
|
@Path("/downloadTar")
|
||||||
@Produces("application/x-tar")
|
@Produces("application/x-tar")
|
||||||
public Response downloadTar(List<String> files)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
|
public Response downloadTar(@FormParam("pkgs") String formData)
|
||||||
{
|
{
|
||||||
|
String[] files = formData.split(" ");
|
||||||
for(String fname : files)
|
for(String fname : files)
|
||||||
{
|
{
|
||||||
if(!ctx.getFile(fname).exists()) throw new NotFoundException(String.format("Package file '%s' does not exist", fname));
|
if(!ctx.getFile(fname).exists()) throw new NotFoundException(String.format("Package file '%s' does not exist", fname));
|
||||||
|
Reference in New Issue
Block a user