more relay WIP
This commit is contained in:
parent
63c717fccf
commit
a611a8a9c0
|
@ -28,14 +28,15 @@ object Relay extends LilaController {
|
||||||
env.forms.create.bindFromRequest.fold(
|
env.forms.create.bindFromRequest.fold(
|
||||||
err => BadRequest(html.relay.create(err)).fuccess,
|
err => BadRequest(html.relay.create(err)).fuccess,
|
||||||
setup => env.api.create(setup, me) map { relay =>
|
setup => env.api.create(setup, me) map { relay =>
|
||||||
Redirect(routes.Relay.show(relay.id.value))
|
Redirect(routes.Relay.show(relay.slug, relay.id.value))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def show(id: String) = Open { implicit ctx =>
|
def show(slug: String, id: String) = Open { implicit ctx =>
|
||||||
OptionOk(env.api byId RelayModel.Id(id)) { relay =>
|
OptionFuResult(env.api byId RelayModel.Id(id)) { relay =>
|
||||||
html.relay.show(relay)
|
if (relay.slug != slug) Redirect(routes.Relay.show(relay.slug, relay.id.value)).fuccess
|
||||||
|
else Ok(html.relay.show(relay)).fuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
@(title: String)(body: Html)(implicit ctx: Context)
|
@(title: String)(body: Html)(implicit ctx: Context)
|
||||||
|
|
||||||
@moreCss = {
|
@moreCss = {
|
||||||
@cssAt("vendor/flatpickr/dist/flatpickr.min.css")
|
@cssTag("flatpickr.css")
|
||||||
@cssTag("material.form.css")
|
@cssTag("material.form.css")
|
||||||
@cssTag("event.crud.css")
|
@cssTag("event.crud.css")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
@(form: Form[_])(implicit ctx: Context)
|
@(form: Form[_])(implicit ctx: Context)
|
||||||
|
|
||||||
@moreCss = {
|
@moreCss = {
|
||||||
|
@cssTag("flatpickr.css")
|
||||||
@cssTag("material.form.css")
|
@cssTag("material.form.css")
|
||||||
@cssTag("relay.css")
|
@cssTag("relay.css")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@moreJs = {
|
||||||
|
@jsAt("vendor/flatpickr/dist/flatpickr.min.js")
|
||||||
|
@embedJs {
|
||||||
|
$(".flatpickr").flatpickr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@base.layout(
|
@base.layout(
|
||||||
title = "New live broadcast",
|
title = "New live broadcast",
|
||||||
moreCss = moreCss
|
moreCss = moreCss,
|
||||||
|
moreJs = moreJs
|
||||||
) {
|
) {
|
||||||
<div class="relay_form content_box small_box no_padding">
|
<div class="relay_form content_box small_box no_padding">
|
||||||
<h1 class="lichess_title">New live broadcast</h1>
|
<h1 class="lichess_title">New live broadcast</h1>
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
@(form: Form[_])(implicit ctx: Context)
|
@(form: Form[_])(implicit ctx: Context)
|
||||||
|
|
||||||
@base.form.group(form("name"), Html("Event name")) {
|
@base.form.group(form("name"), Html("Event name")) {
|
||||||
@base.form.input(form("name"))
|
@base.form.input(form("name"), required = true)
|
||||||
}
|
}
|
||||||
@defining(form("description")) { field =>
|
@defining(form("description")) { field =>
|
||||||
@base.form.group(field, Html("Event description")) {
|
@base.form.group(field, Html("Event description")) {
|
||||||
<textarea class="description" name="@field.name" id="@field.id">@field.value</textarea>
|
<textarea class="description" name="@field.name" id="@field.id" required>@field.value</textarea>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@base.form.group(form("startsAt"), Html("Start date <strong>UTC</strong>")) {
|
@base.form.group(form("startsAt"), Html("Start date <strong>UTC</strong>")) {
|
||||||
@base.form.flatpickr(form("startsAt"))
|
@base.form.flatpickr(form("startsAt"))
|
||||||
}
|
}
|
||||||
@base.form.group(form("pgnUrl"), Html("Live PGN URL")) {
|
@base.form.group(form("pgnUrl"), Html("Live PGN URL")) {
|
||||||
@base.form.input(form("pgnUrl"))
|
@base.form.input(form("pgnUrl"), typ = "url", required = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@base.form.submit()
|
@base.form.submit()
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
@base.layout(
|
@base.layout(
|
||||||
title = "Live tournament broadcasts",
|
title = "Live tournament broadcasts",
|
||||||
moreCss = cssTag("relay.css")) {
|
moreCss = cssTag("relay-list.css")) {
|
||||||
<div class="content_box no_padding relays">
|
<div class="content_box no_padding relays">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<h1>Live tournament broadcasts</h1>
|
<h1>Live tournament broadcasts</h1>
|
||||||
|
|
|
@ -1,8 +1,39 @@
|
||||||
@(r: lila.relay.Relay)(implicit ctx: Context)
|
@(r: lila.relay.Relay, data: lila.relay.JsonView.JsData)(implicit ctx: Context)
|
||||||
|
|
||||||
|
@moreCss = {
|
||||||
|
@cssTag("analyse.css")
|
||||||
|
@cssTag("study.css")
|
||||||
|
@cssTag("relay.css")
|
||||||
|
}
|
||||||
|
|
||||||
|
@moreJs = {
|
||||||
|
@jsAt(s"compiled/lichess.analyse${isProd??(".min")}.js")
|
||||||
|
@embedJs {
|
||||||
|
lichess = lichess || {};
|
||||||
|
lichess.relay = {
|
||||||
|
relay: @Html(J.stringify(data.relay)),
|
||||||
|
study: @Html(J.stringify(data.study)),
|
||||||
|
data: @Html(J.stringify(data.analysis)),
|
||||||
|
i18n: @board.userAnalysisI18n(),
|
||||||
|
explorer: {
|
||||||
|
endpoint: "@explorerEndpoint",
|
||||||
|
tablebaseEndpoint: "@tablebaseEndpoint"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@side = {
|
||||||
|
<div class="side_box study_box"></div>
|
||||||
|
}
|
||||||
|
|
||||||
@base.layout(
|
@base.layout(
|
||||||
title = r.name,
|
title = relay.relay.name,
|
||||||
moreCss = cssTag("relay.css")
|
side = side.some,
|
||||||
) {
|
underchat = none,
|
||||||
<h1 class="lichess_title">@r.name</h1>
|
moreCss = moreCss,
|
||||||
|
moreJs = moreJs,
|
||||||
|
chessground = false,
|
||||||
|
zoomable = true) {
|
||||||
|
<div class="analyse cg-512">@miniBoardContent</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@(r: lila.relay.Relay.WithStudy)(implicit ctx: Context)
|
@(r: lila.relay.Relay.WithStudy)(implicit ctx: Context)
|
||||||
<a class="overlay" href="@routes.Relay.show(r.relay.id.value)"></a>
|
<a class="overlay" href="@routes.Relay.show(r.relay.slug, r.relay.id.value)"></a>
|
||||||
<h2>
|
<h2>
|
||||||
<i class="icon" data-icon=""></i>
|
<i class="icon" data-icon=""></i>
|
||||||
<strong>@r.relay.name</strong>
|
<strong>@r.relay.name</strong>
|
||||||
|
|
|
@ -153,7 +153,7 @@ POST /study/$id<\w{8}>/clear-chat controllers.Study.clearChat(id: String)
|
||||||
GET /relay controllers.Relay.index
|
GET /relay controllers.Relay.index
|
||||||
GET /relay/new controllers.Relay.form
|
GET /relay/new controllers.Relay.form
|
||||||
POST /relay/new controllers.Relay.create
|
POST /relay/new controllers.Relay.create
|
||||||
GET /relay/$id<\w{8}> controllers.Relay.show(id: String)
|
GET /relay/:slug/$id<\w{8}> controllers.Relay.show(slug: String, id: String)
|
||||||
|
|
||||||
# Learn
|
# Learn
|
||||||
GET /learn controllers.Learn.index
|
GET /learn controllers.Learn.index
|
||||||
|
|
8
modules/relay/src/main/JsonView.scala
Normal file
8
modules/relay/src/main/JsonView.scala
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package lila.relay
|
||||||
|
|
||||||
|
import play.api.libs.json._
|
||||||
|
|
||||||
|
object JsonView {
|
||||||
|
|
||||||
|
case class JsData(study: JsObject, analysis: JsObject)
|
||||||
|
}
|
|
@ -20,6 +20,8 @@ case class Relay(
|
||||||
|
|
||||||
def studyId = Study.Id(id.value)
|
def studyId = Study.Id(id.value)
|
||||||
|
|
||||||
|
def slug = lila.common.String slugify name
|
||||||
|
|
||||||
override def toString = s"id:$id pgnUrl:$pgnUrl"
|
override def toString = s"id:$id pgnUrl:$pgnUrl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.joda.time.DateTime
|
||||||
import reactivemongo.bson._
|
import reactivemongo.bson._
|
||||||
|
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.study.StudyApi
|
import lila.study.{ StudyApi, Study }
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final class RelayApi(
|
final class RelayApi(
|
||||||
|
@ -16,6 +16,15 @@ final class RelayApi(
|
||||||
|
|
||||||
def byId(id: Relay.Id) = coll.byId[Relay](id.value)
|
def byId(id: Relay.Id) = coll.byId[Relay](id.value)
|
||||||
|
|
||||||
|
def byIdWithStudy(id: Relay.Id): Fu[Option[Relay.WithStudy]] =
|
||||||
|
byId(id) flatMap {
|
||||||
|
_ ?? { relay =>
|
||||||
|
studyApi.byId(relay.studyId) map2 { (study: Study) =>
|
||||||
|
Relay.WithStudy(relay, study)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def all: Fu[Relay.Selection] =
|
def all: Fu[Relay.Selection] =
|
||||||
created.flatMap(withStudy) zip
|
created.flatMap(withStudy) zip
|
||||||
started.flatMap(withStudy) zip
|
started.flatMap(withStudy) zip
|
||||||
|
|
4
public/stylesheets/flatpickr.css
Normal file
4
public/stylesheets/flatpickr.css
Normal file
File diff suppressed because one or more lines are too long
7
public/stylesheets/relay-list.css
Normal file
7
public/stylesheets/relay-list.css
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
.relay_form h1.lichess_title {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 0!important;
|
||||||
|
}
|
||||||
|
.relay_form textarea.description {
|
||||||
|
height: 10em;
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
.relay_form h1.lichess_title {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 0!important;
|
|
||||||
}
|
|
||||||
.relay_form textarea.description {
|
|
||||||
height: 10em;
|
|
||||||
}
|
|
Loading…
Reference in a new issue