Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TV import files now reset old mappings #314

Merged
merged 5 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ group :development do
end

group :test do
gem "factory_bot_rails"
gem 'minitest', '5.10.3', '!= 5.10.2'
# Performance testing
#gem 'rails-perftest'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ GEM
docile (1.3.1)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
ffi (1.10.0)
figaro (1.1.1)
thor (~> 0.14)
Expand Down Expand Up @@ -301,6 +306,7 @@ DEPENDENCIES
db_fixtures_dump (= 0.1.1)
derailed_benchmarks (~> 1.3, >= 1.3.2)
devise (>= 4.6.0)
factory_bot_rails
figaro (= 1.1.1)
friendly_id (~> 5.2.4)
fuzzy_match (= 2.1.0)
Expand Down
46 changes: 31 additions & 15 deletions app/assets/javascripts/lib/data_manager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data_manager = angular.module(
'archivist.data_manager.response_units',
'archivist.data_manager.response_domains',
'archivist.data_manager.datasets',
'archivist.data_manager.dataset_imports',
'archivist.data_manager.variables',
'archivist.data_manager.variables_instrument',
'archivist.data_manager.resolution',
Expand Down Expand Up @@ -35,6 +36,7 @@ data_manager.factory(
'Topics',
'InstrumentStats',
'Datasets',
'DatasetImports',
'Variables',
'VariablesInstrument',
'Auth',
Expand All @@ -53,6 +55,7 @@ data_manager.factory(
Topics,
InstrumentStats,
Datasets,
DatasetImports,
Variables,
VariablesInstrument,
Auth
Expand All @@ -67,6 +70,7 @@ data_manager.factory(
DataManager.ResponseUnits = ResponseUnits
DataManager.ResponseDomains = ResponseDomains
DataManager.Datasets = Datasets
DataManager.DatasetImports = DatasetImports
DataManager.Variables = Variables
DataManager.VariablesInstrument = VariablesInstrument
DataManager.Auth = Auth
Expand All @@ -78,7 +82,6 @@ data_manager.factory(
DataManager.Data.InstrumentStats = {}
DataManager.Data.Users = {}
DataManager.Data.Groups = {}
DataManager.Data.Clusters = {}

DataManager.Instruments.clearCache()
DataManager.Constructs.clearCache()
Expand All @@ -99,6 +102,16 @@ data_manager.factory(
DataManager.Data.Datasets = DataManager.Datasets.query params, success, error
DataManager.Data.Datasets

DataManager.getDatasetImports = (params, success, error) ->
console.log(DataManager)
DataManager.Data.DatasetImports = DataManager.DatasetImports.query params, success, error
DataManager.Data.DatasetImports

DataManager.getDatasetImportsx = (params, success, error) ->
console.log(DataManager)
DataManager.Data.DatasetImport = DataManager.DatasetImports.get params
DataManager.Data.DatasetImport

DataManager.getInstrument = (instrument_id, options = {}, success, error)->
console.log 'getInstrument'

Expand Down Expand Up @@ -321,19 +334,6 @@ data_manager.factory(
else
cb?()

DataManager.getCluster = (type, id, force = false, cb)->
index = type + '/' + id
if (not DataManager.Data.Clusters[index]?) or force
DataManager.Data.Clusters[index] =
GetResource(
'/clusters/' + index + '.json',
true,
cb
)
else
cb?()
return DataManager.Data.Clusters[index]

DataManager.resolveConstructs = (options)->
DataManager.ConstructResolver ?= new ResolutionService.ConstructResolver DataManager.Data.Constructs
DataManager.ConstructResolver.broken_resolve()
Expand Down Expand Up @@ -371,10 +371,26 @@ data_manager.factory(
DataManager.updateTopic = (model, topic_id)->
console.log(model)
delete model.topic
delete model.strand
delete model.suggested_topic
model.$update_topic({topic_id: if Number.isInteger(topic_id) then topic_id else null })

DataManager.addSources = (model, new_sources, x, y)->
console.log(model)
model.$add_mapping {
sources:
id: new_sources
x: x
y: y
}

DataManager.addVariables = (model, variables)->
console.log(model)
model.$add_mapping {
variable_names: variables
x: null
y: null
}

DataManager.getInstrumentStats = (id, cb)->
DataManager.Data.InstrumentStats[id] = {$resolved: false}
DataManager.Data.InstrumentStats[id].$promise = InstrumentStats(id)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
dataset_imports = angular.module('archivist.data_manager.dataset_imports', [
'ngResource',
])

dataset_imports.factory(
'DatasetImports',
[
'WrappedResource',
(WrappedResource)->
new WrappedResource(
'datasets/:dataset_id/imports/:id.json',
{
id: '@id',
dataset_id: '@dataset_id'
},
{
save: {method: 'PUT'},
create: {method: 'POST'}
}
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ questions.factory(
grid.clearCache() if grid?
}
]
)
)
2 changes: 1 addition & 1 deletion app/assets/javascripts/lib/resource.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ resource.factory('GetResource', [
)
sub_promise.then(cb) if typeof cb is 'function'
rsrc
])
])
14 changes: 12 additions & 2 deletions app/assets/javascripts/sections/datasets/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ datasets = angular.module('archivist.datasets', [
'ngRoute',
'archivist.datasets.index',
'archivist.datasets.show',
'archivist.datasets.edit'
'archivist.datasets.edit',
'archivist.datasets.imports',
'archivist.datasets.imports.show'
])

datasets.config(
Expand All @@ -26,5 +28,13 @@ datasets.config(
templateUrl: 'partials/datasets/edit.html'
controller: 'DatasetsEditController'
)
.when('/datasets/:id/imports',
templateUrl: 'partials/datasets/imports/index.html'
controller: 'DatasetsImportsController'
)
.when('/datasets/:dataset_id/imports/:id',
templateUrl: 'partials/datasets/imports/show.html'
controller: 'DatasetsImportsShowController'
)
]
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
imports = angular.module('archivist.datasets.imports',
[
'ngVis',
'archivist.data_manager'
]
)

imports.controller(
'DatasetsImportsController',
[
'$scope',
'$routeParams',
'VisDataSet',
'DataManager'
(
$scope,
$routeParams,
VisDataSet,
DataManager
)->
$scope.dataset = DataManager.getDataset(
$routeParams.id,
{},
->
$scope.page['title'] = $scope.dataset.name + ' | Edit'
$scope.breadcrumbs = [
{
label: 'Datasets',
link: '/admin/datasets',
active: false
},
{
label: $scope.dataset.name,
link: '/datasets/' + $scope.dataset.id,
active: false
},
{
label: 'Imports',
link: false,
active: true
}
]
)
$scope.imports = DataManager.getDatasetImports(dataset_id: $routeParams.id)
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
show = angular.module('archivist.datasets.imports.show',
[
'ngVis',
'archivist.data_manager'
]
)

show.controller(
'DatasetsImportsShowController',
[
'$scope',
'$routeParams',
'VisDataSet',
'DataManager'
(
$scope,
$routeParams,
VisDataSet,
DataManager
)->
$scope.dataset = DataManager.getDataset(
$routeParams.dataset_id,
{},
->
$scope.page['title'] = $scope.dataset.name + ' | Edit'
$scope.breadcrumbs = [
{
label: 'Datasets',
link: '/admin/datasets',
active: false
},
{
label: $scope.dataset.name,
link: '/datasets/' + $scope.dataset.id,
active: false
},
{
label: 'Imports',
link: '/datasets/' + $scope.dataset.id + '/imports',
active: false
},
{
label: $routeParams.id,
link: false,
active: true
}
]
)
$scope.import = DataManager.getDatasetImportsx(dataset_id: $routeParams.dataset_id, id: $routeParams.id)
]
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#= require ./list
#= require ./show
#= require ./edit
#= require ./edit
#= require ./imports
#= require ./imports/show
66 changes: 6 additions & 60 deletions app/assets/javascripts/sections/datasets/modules/show/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ show.controller(
)
$scope.pageSize = 20

$scope.clusterMenuOptions = [
[
'Remove Topic',
($itemScope)->
console.log 'Removing topic'
console.log $itemScope
]
]

$scope.graphData = {}
$scope.graphOptions =
interaction:
Expand All @@ -68,52 +59,8 @@ show.controller(
type = 'Variable'
id = data.nodes[0] - 20000000

$scope.current_cluster_selection = $scope.graphData.nodes.get data.nodes[0]
console.log $scope

$scope.loadNetworkData = (object)->
$scope.current_cluster_selection =
topic:
name: ''
nodes = new VisDataSet()
edges = new VisDataSet()

$scope.cluster = DataManager.getCluster(
'Variable',
object.id,
true,
(response)->
groupings = {}
for strand in $scope.cluster.strands
for member in strand.members
member.id += if member.type == 'Variable' then 20000000 else 10000000
member.group = 'strand:' + strand.id.toString()
member.borderWidth = if member.topic? then 3 else 1
member.color =
border: if strand.good then 'black' else 'red'

tooltip = '<span'
tooltip += ' style="color: red;"' if not strand.good
tooltip += '>' + member.text
tooltip += '<br/>' + member.topic.name if member.topic?
tooltip += '</span>'

member.title = tooltip
nodes.add member
if member.sources?
for source in member.sources
edges.add {
from: member.id,
to: source.id + if source.type == 'Variable' then 20000000 else 10000000,
dashes: not source.interstrand
}
console.log nodes
)

$scope.graphData =
nodes: nodes,
edges: edges

$scope.split_mapping = (model, other, x = null, y = null)->
model.$split_mapping {
other:
Expand All @@ -126,14 +73,13 @@ show.controller(
$scope.detectKey = (event, variable, x = null, y = null)->
if event.keyCode == 13
new_sources = event.target.value.split ','
variable.$add_mapping {
sources:
id: new_sources
x: x
y: y
}
DataManager.addSources(variable, new_sources, x, y).then(->
$scope.model.orig_topic = $scope.model.topic
, (reason)->
variable.errors = reason.data.message
)
console.log variable

console.log $scope
]
)
)