Added cluster selection and creation path.
This commit is contained in:
parent
a93cb22fb5
commit
052fab1d91
|
@ -2,4 +2,11 @@
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
prepend_view_path Rails.root.join('frontend')
|
prepend_view_path Rails.root.join('frontend')
|
||||||
|
|
||||||
|
def valid_cluster?
|
||||||
|
return false unless session[:cluster_uuid]
|
||||||
|
return false unless Cluster.get(session[:cluster_uuid])
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,17 +3,19 @@
|
||||||
# This is the landing for a specific tally cluster
|
# This is the landing for a specific tally cluster
|
||||||
class ClusterController < ApplicationController
|
class ClusterController < ApplicationController
|
||||||
before_action :only_for_unknown
|
before_action :only_for_unknown
|
||||||
def new; end
|
def show
|
||||||
|
@clusters = Cluster.list
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
# TODO: This will need to modify a shared object to insert a new tally cluster.
|
cluster = Cluster.new(params[:cluster])
|
||||||
session[:cluster] = params[:cluster]
|
session[:cluster_uuid] = cluster.uuid;
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def only_for_unknown
|
def only_for_unknown
|
||||||
redirect_to root_path if session[:cluster]
|
redirect_to root_path if valid_cluster?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,6 +8,6 @@ class CounterController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def associate!
|
def associate!
|
||||||
redirect_to cluster_path unless session[:cluster]
|
redirect_to cluster_path unless valid_cluster?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ require 'securerandom'
|
||||||
|
|
||||||
# A collective for a tally
|
# A collective for a tally
|
||||||
class Cluster
|
class Cluster
|
||||||
attr_reader :count, :name, :status, :uuid
|
attr_reader :count, :name, :status, :uuid, :created_on
|
||||||
@@clusters = {}
|
@@clusters = {}
|
||||||
|
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
|
@ -13,6 +13,7 @@ class Cluster
|
||||||
@count = 0
|
@count = 0
|
||||||
@status = :open
|
@status = :open
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
|
@created_on = Time.new
|
||||||
@@clusters[@uuid] = self
|
@@clusters[@uuid] = self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<%= c("page") do %>
|
|
||||||
<%= c("cluster-list") %>
|
|
||||||
<%= c("cluster-new") %>
|
|
||||||
<% end %>
|
|
3
app/views/cluster/show.html.erb
Normal file
3
app/views/cluster/show.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<%= c("page") do %>
|
||||||
|
<%= c("cluster-view") %>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="cluster-list">
|
||||||
|
<% clusters.each do |cluster| %>
|
||||||
|
<%= c("cluster", cluster: cluster) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -1 +1,3 @@
|
||||||
import "./cluster-list.pcss";
|
import "./cluster-list.pcss";
|
||||||
|
|
||||||
|
import "components/cluster/cluster";
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
/* placeholder */
|
.cluster-list {
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
.create-cluster-form {
|
.create-cluster-form {
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
& input {
|
& input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
|
|
4
frontend/components/cluster-view/_cluster-view.html.erb
Normal file
4
frontend/components/cluster-view/_cluster-view.html.erb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<div class="cluster-view">
|
||||||
|
<%= c("cluster-list", clusters: @clusters.values) %>
|
||||||
|
<%= c("cluster-new") %>
|
||||||
|
</div>
|
8
frontend/components/cluster-view/cluster-view.css
Normal file
8
frontend/components/cluster-view/cluster-view.css
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
.cluster-view {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
4
frontend/components/cluster-view/cluster-view.js
Normal file
4
frontend/components/cluster-view/cluster-view.js
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import "./cluster-view.css";
|
||||||
|
|
||||||
|
import "components/cluster-new/cluster-new";
|
||||||
|
import "components/cluster-list/cluster-list";
|
6
frontend/components/cluster/_cluster.html.erb
Normal file
6
frontend/components/cluster/_cluster.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<a href="cluster/<%=cluster.uuid%>" class="cluster">
|
||||||
|
<span class="panel-icon"><i class="fa fa-sort" aria-hidden="true"></i></span>
|
||||||
|
<span class="panel-text">
|
||||||
|
<%= cluster.name %></span>
|
||||||
|
<span class="panel-subtext"> created on <%= cluster.created_on.strftime("%Y-%m-%d %H:%M:%S")%></span>
|
||||||
|
</a>
|
1
frontend/components/cluster/cluster.js
Normal file
1
frontend/components/cluster/cluster.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import "./cluster.pcss";
|
40
frontend/components/cluster/cluster.pcss
Normal file
40
frontend/components/cluster/cluster.pcss
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
.cluster {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
padding: 0.5em 0.75em;
|
||||||
|
|
||||||
|
& .panel-icon {
|
||||||
|
display: inline-block;
|
||||||
|
font-size: 14px;
|
||||||
|
height: 1em;
|
||||||
|
line-height: 1em;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: top;
|
||||||
|
width: 1em;
|
||||||
|
color: #7a7a7a;
|
||||||
|
margin-right: 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .panel-text {
|
||||||
|
font-weight: 800;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .panel-subtext {
|
||||||
|
font-weight: 100;
|
||||||
|
opacity: 40%;
|
||||||
|
}
|
||||||
|
&:hover,
|
||||||
|
&:focus {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
|
||||||
|
& .panel-icon {
|
||||||
|
color: #3273dc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(:last-child) {
|
||||||
|
border-bottom: 1px solid #ededed;
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,3 +5,8 @@ body {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import "init";
|
import "init";
|
||||||
|
|
||||||
import "components/page/page";
|
import "components/page/page";
|
||||||
import "components/cluster-list/cluster-list";
|
import "components/cluster-view/cluster-view";
|
||||||
import "components/cluster-new/cluster-new";
|
|
||||||
|
|
Reference in New Issue
Block a user