relay private beta
This commit is contained in:
parent
d29dd1135d
commit
bc11863140
|
@ -18,13 +18,13 @@ object Relay extends LilaController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def form = Auth { implicit ctx => me =>
|
def form = Secure(_.Beta) { implicit ctx => me =>
|
||||||
NoLame {
|
NoLame {
|
||||||
Ok(html.relay.create(env.forms.create)).fuccess
|
Ok(html.relay.create(env.forms.create)).fuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def create = AuthBody { implicit ctx => implicit me =>
|
def create = SecureBody(_.Beta) { implicit ctx => me =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
env.forms.create.bindFromRequest.fold(
|
env.forms.create.bindFromRequest.fold(
|
||||||
err => BadRequest(html.relay.create(err)).fuccess,
|
err => BadRequest(html.relay.create(err)).fuccess,
|
||||||
|
@ -34,13 +34,13 @@ object Relay extends LilaController {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def edit(slug: String, id: String) = Auth { implicit ctx => implicit me =>
|
def edit(slug: String, id: String) = Auth { implicit ctx => me =>
|
||||||
OptionFuResult(env.api.byIdAndOwner(RelayModel.Id(id), me)) { relay =>
|
OptionFuResult(env.api.byIdAndOwner(RelayModel.Id(id), me)) { relay =>
|
||||||
Ok(html.relay.edit(relay, env.forms.edit(relay))).fuccess
|
Ok(html.relay.edit(relay, env.forms.edit(relay))).fuccess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def update(slug: String, id: String) = AuthBody { implicit ctx => implicit me =>
|
def update(slug: String, id: String) = AuthBody { implicit ctx => me =>
|
||||||
OptionFuResult(env.api.byIdAndOwner(RelayModel.Id(id), me)) { relay =>
|
OptionFuResult(env.api.byIdAndOwner(RelayModel.Id(id), me)) { relay =>
|
||||||
implicit val req = ctx.body
|
implicit val req = ctx.body
|
||||||
env.forms.edit(relay).bindFromRequest.fold(
|
env.forms.edit(relay).bindFromRequest.fold(
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
<div>
|
<div>
|
||||||
<a href="@routes.Tv.index">Lichess TV</a>
|
<a href="@routes.Tv.index">Lichess TV</a>
|
||||||
<a href="@routes.Tv.games">@trans.currentGames()</a>
|
<a href="@routes.Tv.games">@trans.currentGames()</a>
|
||||||
|
@if(isGranted(_.Beta)) {
|
||||||
|
<a href="@routes.Relay.index">Broadcasts</a>
|
||||||
|
}
|
||||||
<a href="@routes.Video.index">@trans.videoLibrary()</a>
|
<a href="@routes.Video.index">@trans.videoLibrary()</a>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
@(sel: lila.relay.Relay.Selection)(implicit ctx: Context)
|
@(sel: lila.relay.Relay.Selection)(implicit ctx: Context)
|
||||||
|
|
||||||
@sublist(relays: List[lila.relay.Relay.WithStudy]) = {
|
@sublist(name: String, relays: List[lila.relay.Relay.WithStudy]) = {
|
||||||
@if(relays.isEmpty) {
|
@if(relays.nonEmpty) {
|
||||||
<div class="norelays">
|
<section>
|
||||||
<p>None yet.</p>
|
<h2>@name</h2>
|
||||||
</div>
|
<div class="list">
|
||||||
} else {
|
@relays.map { r =>
|
||||||
<div class="list">
|
<div class="relay">
|
||||||
@relays.map { r =>
|
@widget(r)
|
||||||
<div class="relay">
|
</div>
|
||||||
@widget(r)
|
}
|
||||||
</div>
|
</div>
|
||||||
}
|
</section>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,17 +22,8 @@ moreCss = cssTag("relay-list.css")) {
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<h1>Live tournament broadcasts</h1>
|
<h1>Live tournament broadcasts</h1>
|
||||||
</div>
|
</div>
|
||||||
<section>
|
@sublist("Ongoing", sel.started)
|
||||||
<h2>Ongoing</h2>
|
@sublist("Upcoming", sel.created)
|
||||||
@sublist(sel.started)
|
@sublist("Completed", sel.closed)
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2>Upcoming</h2>
|
|
||||||
@sublist(sel.created)
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h2>Completed</h2>
|
|
||||||
@sublist(sel.closed)
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,11 @@ private final class RelayFetch(
|
||||||
case Some(delay) => fuccess(delay)
|
case Some(delay) => fuccess(delay)
|
||||||
case None => api.getNbViewers(r) map {
|
case None => api.getNbViewers(r) map {
|
||||||
case 0 => 30
|
case 0 => 30
|
||||||
case nb => (11 - nb / 2) atLeast 2
|
case nb => (16 - nb) atLeast 5
|
||||||
}
|
}
|
||||||
}) map { seconds =>
|
}) map { seconds =>
|
||||||
sync.copy(nextAt = DateTime.now plusSeconds {
|
sync.copy(nextAt = DateTime.now plusSeconds {
|
||||||
seconds atLeast { if (sync.log.isOk) 2 else 5 }
|
seconds atLeast { if (sync.log.isOk) 5 else 10 }
|
||||||
} some)
|
} some)
|
||||||
}
|
}
|
||||||
} flatMap { api.setSync(r.id, _) }
|
} flatMap { api.setSync(r.id, _) }
|
||||||
|
|
|
@ -26,13 +26,15 @@ export default class RelayCtrl {
|
||||||
c.relay = this.convertDate(r);
|
c.relay = this.convertDate(r);
|
||||||
if (!c.tags.find(t => t[0] === 'Result' && t[1] !== '*')) {
|
if (!c.tags.find(t => t[0] === 'Result' && t[1] !== '*')) {
|
||||||
const delay = (Date.now() - r.lastMoveAt!) % 1000;
|
const delay = (Date.now() - r.lastMoveAt!) % 1000;
|
||||||
console.log(delay);
|
console.log(delay, r.lastMoveAt);
|
||||||
setTimeout(() => setInterval(this.redraw, 1000), delay);
|
setTimeout(() => {
|
||||||
|
this.clockInterval = setInterval(this.redraw, 1000);
|
||||||
|
}, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
convertDate = (r: StudyChapterRelay): StudyChapterRelay => {
|
private convertDate = (r: StudyChapterRelay): StudyChapterRelay => {
|
||||||
if (typeof r.secondsSinceLastMove !== 'undefined' && !r.lastMoveAt) {
|
if (typeof r.secondsSinceLastMove !== 'undefined' && !r.lastMoveAt) {
|
||||||
r.lastMoveAt = Date.now() - r.secondsSinceLastMove * 1000;
|
r.lastMoveAt = Date.now() - r.secondsSinceLastMove * 1000;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +51,7 @@ export default class RelayCtrl {
|
||||||
this.data.sync.log.push(event);
|
this.data.sync.log.push(event);
|
||||||
this.data.sync.log = this.data.sync.log.slice(-20);
|
this.data.sync.log = this.data.sync.log.slice(-20);
|
||||||
this.cooldown = true;
|
this.cooldown = true;
|
||||||
setTimeout(() => { this.cooldown = false; this.redraw(); }, 3000);
|
setTimeout(() => { this.cooldown = false; this.redraw(); }, 4500);
|
||||||
this.redraw();
|
this.redraw();
|
||||||
if (event.error) console.warn(`relay synchronisation error: ${event.error}`);
|
if (event.error) console.warn(`relay synchronisation error: ${event.error}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue