Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Commit eee4cdf

Browse files
committed
merge with lindsay's changes (not working yet)
1 parent 9509ca3 commit eee4cdf

28 files changed

Lines changed: 651 additions & 644 deletions

prototypes/desktop/helper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,4 @@ def get_connection_string(database_url):
88
DATABASE_HOST = list_db_cfg[2]
99
DATABASE_PORT = list_db_cfg[4]
1010
connection_string = "host=" + DATABASE_HOST + " user=" + DATABASE_USER + " password=" + list_db_cfg[3] + " dbname=" + DATABASE_NAME
11-
return connection_string
12-
13-
table_prefix = "gestalt_"
11+
return connection_string

prototypes/desktop/story.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import helper
88

9+
# TODO: handle persona_panel_stories && story_idea_metrics
10+
911
urls = (
1012

1113
# 0.0.0.0:8000/api/story/getAllStories
@@ -33,7 +35,7 @@ def GET(self, connection_string=helper.get_connection_string(os.environ['DATABAS
3335
self.cursor = connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
3436
# execute query
3537
self.cursor.execute("""
36-
SELECT * FROM """ + helper.table_prefix + """story;
38+
SELECT * FROM gestalt_story;
3739
""")
3840
# obtain the data
3941
data = self.cursor.fetchall()
@@ -57,7 +59,7 @@ def GET(self, story_id, connection_string=helper.get_connection_string(os.enviro
5759
# execute query
5860
self.cursor.execute("""
5961
SELECT *
60-
FROM """ + helper.table_prefix + """story AS story
62+
FROM gestalt_story AS story
6163
WHERE story.id = """ + story_id + """;
6264
""")
6365
# obtain the data
@@ -66,15 +68,14 @@ def GET(self, story_id, connection_string=helper.get_connection_string(os.enviro
6668
return json.dumps(data)
6769

6870
class getAllStoriesByWorkspaceAndPanel:
69-
""" Extract all the stories from a specific panel with a particular persona.
71+
""" Extract all the stories from a specific panel with a particular workspace and persona.
7072
input:
7173
* workspace.id
7274
* panel.id
7375
output:
7476
* story.id
7577
* story.name
7678
* story.url_name
77-
* story_ideas
7879
"""
7980
def GET(self, workspace_id, panel_id, connection_string=helper.get_connection_string(os.environ['DATABASE_URL'])):
8081
# connect to postgresql based on configuration in connection_string

prototypes/desktop/visualization.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# rest API backend endpoints
1212
"flows/unique_targets/(.*)/", "flows",
1313
"story/metric/(\d+)/", "metrics",
14-
"angular/directives/(.*)/", "ng_directives",
15-
"countries/groups/", "node_groups",
16-
"geojson/(.*)/", "geojson",
14+
"angular/directives/(.*)/", "ng_directives",
15+
"countries/groups/", "node_groups",
16+
"geojson/(.*)/", "geojson",
1717
"(.*)/", "nodes"
1818

1919
)
@@ -27,22 +27,22 @@ def GET(self, source_id, connection_string=helper.get_connection_string(os.envir
2727
# execute query
2828
self.cursor.execute("""
2929
select gn.name as source_name,
30-
cy.iso2code as source,
31-
gnt.name as target_name,
32-
cyt.iso2code as target,
33-
cy.id as source_id,
34-
count(cdis.target_id) as value
35-
from """ + helper.table_prefix + """cdis cdis
36-
left join """ + helper.table_prefix + """geography_name gn on gn.id = cdis.source_id
37-
left join """ + helper.table_prefix + """geography_name gnt on gnt.id = cdis.target_id
38-
left join """ + helper.table_prefix + """country cy on cy.id = cdis.source_id
39-
left join """ + helper.table_prefix + """country cyt on cyt.id = cdis.target_id
40-
where source_id = """ + source_id + """ and cyt.iso2code is not null
41-
group by gn.name,
42-
cy.iso2code,
43-
cy.id,
44-
gnt.name,
45-
cyt.iso2code
30+
cy.iso2code as source,
31+
gnt.name as target_name,
32+
cyt.iso2code as target,
33+
cy.id as source_id,
34+
count(cdis.target_id) as value
35+
from """ + helper.table_prefix + """cdis cdis
36+
left join """ + helper.table_prefix + """geography_name gn on gn.id = cdis.source_id
37+
left join """ + helper.table_prefix + """geography_name gnt on gnt.id = cdis.target_id
38+
left join """ + helper.table_prefix + """country cy on cy.id = cdis.source_id
39+
left join """ + helper.table_prefix + """country cyt on cyt.id = cdis.target_id
40+
where source_id = """ + source_id + """ and cyt.iso2code is not null
41+
group by gn.name,
42+
cy.iso2code,
43+
cy.id,
44+
gnt.name,
45+
cyt.iso2code
4646
""")
4747
# obtain the data
4848
data = self.cursor.fetchall()
@@ -57,17 +57,17 @@ def GET(self, table, connection_string=helper.get_connection_string(os.environ['
5757
self.cursor = connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
5858
# execute query
5959
self.cursor.execute("""
60-
select distinct on (gn.name) gn.name,
61-
cy.iso2code as iso,
62-
cy.id,
63-
count(distinct cdis.target_id) as count
64-
from """ + helper.table_prefix + """country cy
65-
left join """ + helper.table_prefix + """geography_name gn on gn.id = cy.name_id
66-
left join """ + helper.table_prefix + """geography geo on geo.name_id = cy.name_id
67-
left join """ + helper.table_prefix + """cdis cdis on source_id = cy.id
68-
group by gn.name,
69-
cy.iso2code,
70-
cy.id
60+
select distinct on (gn.name) gn.name,
61+
cy.iso2code as iso,
62+
cy.id,
63+
count(distinct cdis.target_id) as count
64+
from """ + helper.table_prefix + """country cy
65+
left join """ + helper.table_prefix + """geography_name gn on gn.id = cy.name_id
66+
left join """ + helper.table_prefix + """geography geo on geo.name_id = cy.name_id
67+
left join """ + helper.table_prefix + """cdis cdis on source_id = cy.id
68+
group by gn.name,
69+
cy.iso2code,
70+
cy.id
7171
""")
7272
# obtain the data
7373
data = self.cursor.fetchall()
@@ -146,20 +146,20 @@ def GET(self, grid, connection_string=helper.get_connection_string(os.environ['D
146146
row_to_json(f) as properties,
147147
row_to_json(c) as geometry
148148
from t,
149-
""" + helper.table_prefix + """geography geo
149+
""" + helper.table_prefix + """geography geo
150150
left join (
151-
select geo.id,
151+
select geo.id,
152152
gn.name,
153153
cy.iso2code as iso
154154
from """ + helper.table_prefix + """geography geo
155155
left join """ + helper.table_prefix + """geography_name gn on gn.id = geo.name_id
156156
left join """ + helper.table_prefix + """country cy on cy.id = geo.name_id
157-
) f on f.id = geo.id
158-
left join (
159-
with t as (
160-
select 'Polygon'::text
161-
)
162-
select t.text as type,
157+
) f on f.id = geo.id
158+
left join (
159+
with t as (
160+
select 'Polygon'::text
161+
)
162+
select t.text as type,
163163
geo.hexagon_polygon as coordinates
164164
from t,
165165
""" + helper.table_prefix + """geography geo
@@ -172,7 +172,7 @@ def GET(self, grid, connection_string=helper.get_connection_string(os.environ['D
172172
data = self.cursor.fetchall()
173173
# convert data to a string
174174
return json.dumps(data)
175-
175+
176176
class ng_directives:
177177
def GET(self, vis_id, connection_string=helper.get_connection_string(os.environ['DATABASE_URL'])):
178178
# connect to postgresql based on configuration in connection_string
@@ -182,13 +182,13 @@ def GET(self, vis_id, connection_string=helper.get_connection_string(os.environ[
182182
# execute query
183183
self.cursor.execute("""
184184
select *
185-
from gestalt_vis
186-
where id = """ + vis_id + """;
185+
from gestalt_vis
186+
where id = """ + vis_id + """;
187187
""")
188188
# obtain the data
189189
data = self.cursor.fetchall()
190190
# convert data to a string
191191
return json.dumps(data)
192192

193193
# instantiate the application
194-
app = web.application(urls, locals())
194+
app = web.application(urls, locals())

prototypes/desktop/workspace.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import helper
88

9+
# TODO: handle persona_workspaces && workspace_panels
10+
911
urls = (
1012

1113
# 0.0.0.0:8000/api/workspace/getDefaultWorkspaceByPersona/#, where # == persona.id
@@ -47,7 +49,6 @@ def GET(self, persona_id, connection_string=helper.get_connection_string(os.envi
4749
# convert data to a string
4850
return json.dumps(data)
4951

50-
5152
class getAllWorkspacesByPersona:
5253
""" Extract all workspaces for a particular persona.
5354
input:

prototypes/desktop/www/index.html

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@
3636
<!----------->
3737
<!-- STYLE -->
3838
<!----------->
39-
40-
<!-- maps -->
41-
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.15.0/mapbox-gl.css' rel='stylesheet'>
42-
<link href='https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.css' rel='stylesheet'>
43-
44-
<link rel="stylesheet" href="css/directives.css">
45-
<link rel="stylesheet" href="css/directives/slide-panel.css">
39+
40+
<!-- maps -->
41+
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.15.0/mapbox-gl.css' rel='stylesheet'>
42+
<link href='https://api.mapbox.com/mapbox.js/v2.4.0/mapbox.css' rel='stylesheet'>
43+
44+
<link rel="stylesheet" href="css/directives.css">
45+
<link rel="stylesheet" href="css/directives/slide-panel.css">
4646
<link rel="stylesheet" href="css/directives/panel-nav.css">
4747
<link rel="stylesheet" href="css/directives/tile-grid-map.css">
4848
<link rel="stylesheet" href="css/directives/group-nodes.css">
4949
<link rel="stylesheet" href="css/directives/bar-chart.css">
5050
<link rel="stylesheet" href="css/directives/story-controls.css">
5151
<link rel="stylesheet" href="css/directives/heatmap-grid.css">
52-
53-
<link rel="stylesheet" href="css/ionicons.min.css">
52+
53+
<link rel="stylesheet" href="css/ionicons.min.css">
5454
<link rel="stylesheet" href="css/desktop.css">
5555
<link rel="stylesheet" ng-href="css/{{theme.current}}.css">
5656

@@ -86,20 +86,20 @@
8686
<script src="js/directives/tile-grid-map-directive.js"></script>
8787
<script src="js/directives/bar-chart-directive.js"></script>
8888
<script src="js/directives/story-controls-directive.js"></script>
89-
<script src="js/directives/dynamic-directive-directive.js"></script>
90-
<script src="js/directives/story-idea-metric-directive.js"></script>
89+
<script src="js/directives/dynamic-directive-directive.js"></script>
90+
<script src="js/directives/story-idea-metric-directive.js"></script>
9191
<script src="js/directives/heatmap-grid-directive.js"></script>
92-
93-
<!-- factories -->
94-
<script src="js/desktop.factories.js"></script>
95-
<script src="js/factories/layout-factory.js"></script>
96-
<script src="js/factories/authentication-factory.js"></script>
97-
<script src="js/factories/base64-factory.js"></script>
98-
<script src="js/factories/content-factory.js"></script>
99-
<script src="js/factories/plotly-factory.js"></script>
100-
<script src="js/factories/d3-factory.js"></script>
101-
<script src="js/factories/mapbox-factory.js"></script>
102-
<script src="js/factories/agent-factory.js"></script>
92+
93+
<!-- services -->
94+
<script src="js/desktop.services.js"></script>
95+
<script src="js/services/layout-service.js"></script>
96+
<script src="js/services/authentication-service.js"></script>
97+
<script src="js/services/base64-service.js"></script>
98+
<script src="js/services/content-service.js"></script>
99+
<script src="js/services/plotly-service.js"></script>
100+
<script src="js/services/d3-service.js"></script>
101+
<script src="js/services/mapbox-service.js"></script>
102+
<script src="js/services/agent-service.js"></script>
103103

104104
</head>
105105

prototypes/desktop/www/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var app = angular.module("app", [
33
"angularMoment",
44
"desktop.controllers",
55
"desktop.directives",
6-
"desktop.factories"
6+
"desktop.services"
77
]);
88

99
/***********************/

prototypes/desktop/www/js/controllers/app-controller.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
.controller("appController", appController);
99

1010
// add additional services to be used within the controller
11-
appController.$inject = ["$rootScope", "$scope", "$state", "$stateParams", "authenticationFactory", "layoutFactory"];
11+
appController.$inject = ["$rootScope", "$scope", "$state", "$stateParams", "authenticationService", "layoutService"];
1212

1313
// define the controller
14-
function appController($rootScope, $scope, $state, $stateParams, authenticationFactory, layoutFactory) {
14+
function appController($rootScope, $scope, $state, $stateParams, authenticationService, layoutService) {
1515
// --------------------------------------------------------------------
1616
// define bindable members
1717
// * slide panel
@@ -79,7 +79,7 @@
7979
* - workspaces associated with current persona
8080
*/
8181
var getListOfWorkspaces = function() {
82-
return layoutFactory
82+
return layoutService
8383
.getAllWorkspaces(currentPersona.id)
8484
.then(function(listOfWorkspaces) {
8585
return listOfWorkspaces
@@ -90,15 +90,15 @@
9090
$scope.slidePanelContent = {
9191
currentPersona: currentPersona.name,
9292
theme: $scope.$parent.theme,
93-
currentWorkspaceId: layoutFactory.getCurrentWorkspace().id,
93+
currentWorkspaceId: layoutService.getCurrentWorkspace().id,
9494
listOfWorkspaces: listOfWorkspaces
9595
};
9696

9797
};
9898

9999
// get all workspaces associated with the current persona
100100
// in order to fill the content of the slide panel
101-
var currentPersona = authenticationFactory.getCurrentPersona();
101+
var currentPersona = authenticationService.getCurrentPersona();
102102
getListOfWorkspaces()
103103
.then(setSlidePanelContent);
104104

@@ -109,8 +109,8 @@
109109
// ============================
110110

111111
function getListOfPanels() {
112-
return layoutFactory
113-
.getAllPanels(layoutFactory.getCurrentWorkspace().id)
112+
return layoutService
113+
.getAllPanels(layoutService.getCurrentWorkspace().id)
114114
.then(function (listOfPanels) {
115115
$scope.listOfPanels = listOfPanels;
116116
});

prototypes/desktop/www/js/controllers/login-controller.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
.controller("loginController", loginController);
99

1010
// add additional services to be used within the controller
11-
loginController.$inject = ["$scope", "$state", "$templateCache", "authenticationFactory", "layoutFactory"];
11+
loginController.$inject = ["$scope", "$state", "$templateCache", "authenticationService", "layoutService"];
1212

1313
// define the controller
14-
function loginController($scope, $state, $templateCache, authenticationFactory, layoutFactory) {
14+
function loginController($scope, $state, $templateCache, authenticationService, layoutService) {
1515
// --------------------------------------------------------------------
1616
// define bindable members
1717
$scope.listOfPersonas = [];
@@ -25,7 +25,7 @@
2525
// define functions
2626
function activate() {
2727
// get a list of all personas to be displayed
28-
authenticationFactory
28+
authenticationService
2929
.getAllPersonas()
3030
.then(function(listOfPersonas) {
3131
$scope.listOfPersonas = listOfPersonas;
@@ -37,35 +37,35 @@
3737
// TODO: refactor this because the functionality is similar to slide-panel-directive's changeWorkspace function
3838
var getDefaultWorkspace = function(personaId) {
3939
// get the persona's default workspace to be passed in to the transition function
40-
return layoutFactory
40+
return layoutService
4141
.getDefaultWorkspace(personaId)
4242
.then(function(defaultWorkspace) {
4343
// set current workspace
44-
layoutFactory.setCurrentWorkspace(defaultWorkspace.id, defaultWorkspace.url_name);
44+
layoutService.setCurrentWorkspace(defaultWorkspace.id, defaultWorkspace.url_name);
4545
return defaultWorkspace.id;
4646
});
4747
};
4848
var getDefaultPanel = function(workspaceId) {
4949
// get the workspace's default panel to be passed in to the transition function
50-
return layoutFactory
50+
return layoutService
5151
.getDefaultPanel(workspaceId)
5252
.then(function(defaultPanel) {
5353
// set current panel
54-
layoutFactory.setCurrentPanel(defaultPanel.id, defaultPanel.url_name);
54+
layoutService.setCurrentPanel(defaultPanel.id, defaultPanel.url_name);
5555
return defaultPanel.id;
5656
});
5757
};
5858
var transition = function() {
5959
// transition to the persona's default workspace and the workspace's default panel
6060
$state.go("app.panel", {
61-
currentWorkspaceUrl: layoutFactory.getCurrentWorkspace().url_name,
62-
currentPanelUrl: layoutFactory.getCurrentPanel().url_name,
61+
currentWorkspaceUrl: layoutService.getCurrentWorkspace().url_name,
62+
currentPanelUrl: layoutService.getCurrentPanel().url_name,
6363
});
6464

6565
};
6666

6767
// set current persona
68-
authenticationFactory.setCurrentPersona(personaId, personaName);
68+
authenticationService.setCurrentPersona(personaId, personaName);
6969

7070
// get the persona's default workspace and the workspace's default panel
7171
// in order to transition

0 commit comments

Comments
 (0)