get events into the client on initial and later load
This commit is contained in:
parent
223d31c4f4
commit
769b57cdd2
6 changed files with 9 additions and 3 deletions
|
@ -16,6 +16,7 @@ class MapsController < ApplicationController
|
||||||
@allmessages = @map.messages.sort_by(&:created_at)
|
@allmessages = @map.messages.sort_by(&:created_at)
|
||||||
@allstars = @map.stars
|
@allstars = @map.stars
|
||||||
@allrequests = @map.access_requests
|
@allrequests = @map.access_requests
|
||||||
|
@allevents = @map.events
|
||||||
end
|
end
|
||||||
format.json { render json: @map }
|
format.json { render json: @map }
|
||||||
format.csv { redirect_to action: :export, format: :csv }
|
format.csv { redirect_to action: :export, format: :csv }
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Map < ApplicationRecord
|
||||||
has_many :collaborators, through: :user_maps, source: :user
|
has_many :collaborators, through: :user_maps, source: :user
|
||||||
|
|
||||||
has_many :webhooks, as: :hookable
|
has_many :webhooks, as: :hookable
|
||||||
has_many :events, -> { includes :user }, as: :eventable, dependent: :destroy
|
has_many :events, -> { includes :user }, dependent: :destroy
|
||||||
|
|
||||||
# This method associates the attribute ":image" with a file attachment
|
# This method associates the attribute ":image" with a file attachment
|
||||||
has_attached_file :screenshot,
|
has_attached_file :screenshot,
|
||||||
|
@ -95,7 +95,8 @@ class Map < ApplicationRecord
|
||||||
collaborators: editors,
|
collaborators: editors,
|
||||||
messages: messages.sort_by(&:created_at),
|
messages: messages.sort_by(&:created_at),
|
||||||
stars: stars,
|
stars: stars,
|
||||||
requests: access_requests
|
requests: access_requests,
|
||||||
|
events: events.chronologically
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class EventSerializer < ActiveModel::Serializer
|
class EventSerializer < ActiveModel::Serializer
|
||||||
attributes :id, :sequence_id, :kind, :map_id, :created_at
|
attributes :id, :kind, :map_id, :created_at
|
||||||
|
|
||||||
has_one :actor, serializer: Api::V2::UserSerializer, root: 'users'
|
has_one :actor, serializer: Api::V2::UserSerializer, root: 'users'
|
||||||
has_one :map, serializer: Api::V2::MapSerializer
|
has_one :map, serializer: Api::V2::MapSerializer
|
||||||
|
|
|
@ -18,5 +18,6 @@
|
||||||
Metamaps.ServerData.Mappings = <%= @allmappings.to_json.html_safe %>;
|
Metamaps.ServerData.Mappings = <%= @allmappings.to_json.html_safe %>;
|
||||||
Metamaps.ServerData.Messages = <%= @allmessages.to_json.html_safe %>;
|
Metamaps.ServerData.Messages = <%= @allmessages.to_json.html_safe %>;
|
||||||
Metamaps.ServerData.Stars = <%= @allstars.to_json.html_safe %>;
|
Metamaps.ServerData.Stars = <%= @allstars.to_json.html_safe %>;
|
||||||
|
Metamaps.ServerData.Events = <%= @allevents.to_json.html_safe %>;
|
||||||
Metamaps.ServerData.VisualizeType = "ForceDirected";
|
Metamaps.ServerData.VisualizeType = "ForceDirected";
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -35,6 +35,7 @@ const DataModel = {
|
||||||
|
|
||||||
Collaborators: new MapperCollection(),
|
Collaborators: new MapperCollection(),
|
||||||
Creators: new MapperCollection(),
|
Creators: new MapperCollection(),
|
||||||
|
Events: [],
|
||||||
Mappers: new MapperCollection(),
|
Mappers: new MapperCollection(),
|
||||||
Mappings: new MappingCollection(),
|
Mappings: new MappingCollection(),
|
||||||
Maps: {
|
Maps: {
|
||||||
|
@ -68,6 +69,7 @@ const DataModel = {
|
||||||
|
|
||||||
if (serverData.Collaborators) self.Collaborators = new MapperCollection(serverData.Collaborators)
|
if (serverData.Collaborators) self.Collaborators = new MapperCollection(serverData.Collaborators)
|
||||||
if (serverData.Creators) self.Creators = new MapperCollection(serverData.Creators)
|
if (serverData.Creators) self.Creators = new MapperCollection(serverData.Creators)
|
||||||
|
if (serverData.Events) self.Events = serverData.Events
|
||||||
if (serverData.Mappers) self.Mappers = new MapperCollection(serverData.Mappers)
|
if (serverData.Mappers) self.Mappers = new MapperCollection(serverData.Mappers)
|
||||||
if (serverData.Mappings) self.Mappings = new MappingCollection(serverData.Mappings)
|
if (serverData.Mappings) self.Mappings = new MappingCollection(serverData.Mappings)
|
||||||
if (serverData.Messages) self.Messages = serverData.Messages
|
if (serverData.Messages) self.Messages = serverData.Messages
|
||||||
|
|
|
@ -80,6 +80,7 @@ const Map = {
|
||||||
DataModel.Mappings = new DataModel.MappingCollection(data.mappings)
|
DataModel.Mappings = new DataModel.MappingCollection(data.mappings)
|
||||||
DataModel.Messages = data.messages
|
DataModel.Messages = data.messages
|
||||||
DataModel.Stars = data.stars
|
DataModel.Stars = data.stars
|
||||||
|
DataModel.Events = data.events
|
||||||
DataModel.attachCollectionEvents()
|
DataModel.attachCollectionEvents()
|
||||||
|
|
||||||
var map = Active.Map
|
var map = Active.Map
|
||||||
|
|
Loading…
Reference in a new issue