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

Commit b31d40e

Browse files
committed
working with master version fdce87e
1 parent d2ab5f2 commit b31d40e

File tree

12 files changed

+252
-212
lines changed

12 files changed

+252
-212
lines changed

prototypes/desktop/story.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# 0.0.0.0:8000/api/story/getSingleStory/#
1414
# where # == story.id
1515
"getSingleStory/(\d+)", "getSingleStory",
16-
# 0.0.0.0:8000/api/story/getAllStoriesByPersonaAndPanel/persona/#/panel/#
16+
# 0.0.0.0:8000/api/story/getAllStoriesByWorkspaceAndPanel/persona/#/panel/#
1717
# where first # == workspace.id and second # == panel.id
1818
"getAllStoriesByWorkspaceAndPanel/workspace/(\d+)/panel/(\d+)", "getAllStoriesByWorkspaceAndPanel",
1919

@@ -65,35 +65,6 @@ def GET(self, story_id, connection_string=helper.get_connection_string(os.enviro
6565
# convert data to a string
6666
return json.dumps(data)
6767

68-
class getAllStoriesByPersona:
69-
""" Extract all the stories for a particular persona.
70-
input:
71-
* persona.id
72-
output:
73-
* story.id
74-
* story.name
75-
* story.url_name
76-
"""
77-
def GET(self, persona_id, connection_string=helper.get_connection_string(os.environ['DATABASE_URL'])):
78-
# connect to postgresql based on configuration in connection_string
79-
connection = psycopg2.connect(connection_string)
80-
# get a cursor to perform queries
81-
self.cursor = connection.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
82-
# execute query
83-
self.cursor.execute("""
84-
SELECT DISTINCT ON (st.id) st.id, st.name, st.url_name
85-
FROM gestalt_story AS st
86-
RIGHT JOIN gestalt_workspace_panel_story AS wps
87-
ON st.id = pps.story_id
88-
AND pps.persona_id = """ + persona_id + """
89-
WHERE st.id IS NOT NULL
90-
ORDER BY st.id;
91-
""")
92-
# obtain the data
93-
data = self.cursor.fetchall()
94-
# convert data to a string
95-
return json.dumps(data)
96-
9768
class getAllStoriesByWorkspaceAndPanel:
9869
""" Extract all the stories from a specific panel with a particular persona.
9970
input:

prototypes/desktop/www/js/app.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,15 @@ app.config(function($stateProvider, $urlRouterProvider, $compileProvider) {
7878

7979
// main
8080
.state("app", {
81-
url: "/{workspace}?:t",
81+
url: "/{currentWorkspaceUrl}?:t",
8282
abstract: true,
8383
templateUrl: "templates/app.html",
8484
controller: "appController",
8585
resolve: {
86-
authorized: ["$q", function($q) {
87-
if(localStorage.getItem("gestaltUser") === null) {
88-
return $q.reject("requires login");
89-
};
86+
authorized: ["$state", "authenticationFactory", function($state, authenticationFactory) {
87+
if(authenticationFactory.getCurrentPersona() === null) {
88+
$state.go("login");
89+
}
9090
}]
9191
},
9292
params: {
@@ -96,7 +96,7 @@ app.config(function($stateProvider, $urlRouterProvider, $compileProvider) {
9696

9797
// panel
9898
.state("app.panel", {
99-
url: "/{panel}",
99+
url: "/{currentPanelUrl}",
100100
views: {
101101
"panel": {
102102
templateUrl: "templates/panel.html",

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
$scope.showRight = showRight;
2222
$scope.close = close;
2323
$scope.slidePanelContent = {};
24+
// * panel navigation
25+
$scope.listOfPanels;
2426

2527
// --------------------------------------------------------------------
2628
// call functions
@@ -29,11 +31,17 @@
2931
// --------------------------------------------------------------------
3032
// define functions
3133
function activate() {
34+
// * slide panel
3235
addInteractivityToSlidePanel();
33-
addSlidePanelContent();
36+
addSlidePanelContent();
37+
// * panel navigation
38+
getListOfPanels();
3439
}
3540

36-
// * slide panel
41+
// ============================
42+
// * slide panel
43+
// ============================
44+
3745
function showLeft(event) {
3846
$scope.leftVisible = true;
3947
event.stopPropagation();
@@ -71,10 +79,11 @@
7179
* - workspaces associated with current persona
7280
*/
7381
var getListOfWorkspaces = function() {
74-
return layoutFactory.getAllWorkspaces(currentPersona.id)
75-
.then(function(listOfWorkspaces) {
76-
return listOfWorkspaces
77-
});
82+
return layoutFactory
83+
.getAllWorkspaces(currentPersona.id)
84+
.then(function(listOfWorkspaces) {
85+
return listOfWorkspaces
86+
});
7887

7988
};
8089
var setSlidePanelContent = function(listOfWorkspaces) {
@@ -93,9 +102,21 @@
93102
getListOfWorkspaces()
94103
.then(setSlidePanelContent);
95104

105+
}
96106

107+
// ============================
108+
// * panel navigation
109+
// ============================
110+
111+
function getListOfPanels() {
112+
return layoutFactory
113+
.getAllPanels(layoutFactory.getCurrentWorkspace().id)
114+
.then(function (listOfPanels) {
115+
$scope.listOfPanels = listOfPanels;
116+
});
97117
}
98118

119+
99120
}
100121

101122
})();

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
// set login-controller application and register its controller
66
angular
7-
.module("login-controller", ['ui.router'])
7+
.module("login-controller", [])
88
.controller("loginController", loginController);
99

1010
// add additional services to be used within the controller
@@ -25,41 +25,41 @@
2525
// define functions
2626
function activate() {
2727
// get a list of all personas to be displayed
28-
authenticationFactory.getAllPersonas()
29-
.then(function(listOfPersonas) {
30-
$scope.listOfPersonas = listOfPersonas;
31-
});
28+
authenticationFactory
29+
.getAllPersonas()
30+
.then(function(listOfPersonas) {
31+
$scope.listOfPersonas = listOfPersonas;
32+
});
3233

3334
}
3435

3536
function login(personaId, personaName) {
3637
// TODO: refactor this because the functionality is similar to slide-panel-directive's changeWorkspace function
37-
38-
39-
4038
var getDefaultWorkspace = function(personaId) {
4139
// get the persona's default workspace to be passed in to the transition function
42-
return layoutFactory.getDefaultWorkspace(personaId)
43-
.then(function(defaultWorkspace) {
44-
// set current workspace
45-
layoutFactory.setCurrentWorkspace(defaultWorkspace.id, defaultWorkspace.url_name);
46-
return defaultWorkspace.id;
47-
});
40+
return layoutFactory
41+
.getDefaultWorkspace(personaId)
42+
.then(function(defaultWorkspace) {
43+
// set current workspace
44+
layoutFactory.setCurrentWorkspace(defaultWorkspace.id, defaultWorkspace.url_name);
45+
return defaultWorkspace.id;
46+
});
4847
};
4948
var getDefaultPanel = function(workspaceId) {
5049
// get the workspace's default panel to be passed in to the transition function
51-
return layoutFactory.getDefaultPanel(workspaceId)
52-
.then(function(defaultPanel) {
53-
// set current panel
54-
layoutFactory.setCurrentPanel(defaultPanel.id, defaultPanel.url_name);
55-
return defaultPanel.id;
56-
});
50+
return layoutFactory
51+
.getDefaultPanel(workspaceId)
52+
.then(function(defaultPanel) {
53+
// set current panel
54+
layoutFactory.setCurrentPanel(defaultPanel.id, defaultPanel.url_name);
55+
return defaultPanel.id;
56+
});
5757
};
5858
var transition = function() {
5959
// transition to the persona's default workspace and the workspace's default panel
6060
$state.go("app.panel.visual", {
61-
workspace: layoutFactory.getCurrentWorkspace().url_name,
62-
panel: layoutFactory.getCurrentPanel().url_name,
61+
currentWorkspaceUrl: layoutFactory.getCurrentWorkspace().url_name,
62+
currentPanelUrl: layoutFactory.getCurrentPanel().url_name,
6363
grid: visual_config.tilemap,
6464
});
6565

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

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

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

1313
// define the controller
14-
function panelController($scope, $stateParams, authenticationFactory, contentFactory, layoutFactory) {
14+
function panelController($scope, contentFactory, layoutFactory) {
1515
// --------------------------------------------------------------------
1616
// define bindable members
17-
$scope.listOfStories = [];
17+
$scope.listOfStories;
1818

1919
// --------------------------------------------------------------------
2020
// call functions
@@ -23,19 +23,20 @@
2323
// --------------------------------------------------------------------
2424
// define functions
2525
function activate() {
26-
var currentPersonaId = authenticationFactory.getCurrentPersona().id;
26+
var currentWorkspaceId = layoutFactory.getCurrentWorkspace().id;
2727
var currentPanelId = layoutFactory.getCurrentPanel().id;
2828

2929
// get all stories from a panel
30-
getListOfStories(currentPersonaId, currentPanelId);
30+
getListOfStories(currentWorkspaceId, currentPanelId);
3131

3232
}
3333

34-
function getListOfStories(personaId, panelId) {
35-
contentFactory.getListOfStories(personaId, panelId)
36-
.then(function(listOfStories) {
37-
$scope.listOfStories = listOfStories;
38-
});
34+
function getListOfStories(workspaceId, panelId) {
35+
contentFactory
36+
.getAllStories(workspaceId, panelId)
37+
.then(function(listOfStories) {
38+
$scope.listOfStories = listOfStories;
39+
});
3940

4041
}
4142

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

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,51 @@
88
.controller("vizController", vizController);
99

1010
// add additional services to be used within the controller
11-
vizController.$inject = ["$scope", "$state", "contentFactory"];
11+
vizController.$inject = ["$q", "$scope", "$state", "contentFactory"];
1212

1313
// define the controller
14-
function vizController($scope, $state, contentFactory) {
15-
16-
var grid = $state.params.grid;
17-
18-
// data objects
19-
$scope.nodes;
20-
$scope.nodeGroups;
21-
$scope.geojson;
22-
23-
// country nodes
24-
contentFactory.getData("visualization/cdis/").then(function(data) {
25-
26-
// set scope
27-
$scope.nodes = data;
28-
29-
});
30-
31-
// node groups
32-
contentFactory.getData("visualization/countries/groups/").then(function(data) {
33-
34-
// set scope
35-
$scope.nodeGroups = data;
36-
37-
});
38-
39-
// geojson
40-
contentFactory.getData("visualization/geojson/" + grid + "/").then(function(data) {
41-
42-
// set scope
43-
$scope.geojson = data[0];
44-
45-
});
14+
function vizController($q, $scope, $state, contentFactory) {
15+
// --------------------------------------------------------------------
16+
// define bindable members
17+
$scope.nodes;
18+
$scope.nodeGroups;
19+
$scope.geojson;
20+
21+
// --------------------------------------------------------------------
22+
// call functions
23+
activate();
24+
25+
// --------------------------------------------------------------------
26+
// define functions
27+
function activate() {
28+
// TODO: for now set Economics workspace's vis as the default
29+
getEconomicsData();
30+
}
31+
32+
function getEconomicsData() {
33+
// retrieve data in parallel
34+
return $q.all([
35+
contentFactory.getCdis(),
36+
contentFactory.getCountryGroup(),
37+
contentFactory.getGeojson($state.params.grid)
38+
])
39+
.then(function(listOfNodes, listOfNodeGroups, geojson)
40+
{
41+
$scope.nodes = listOfNodes;
42+
$scope.nodeGroups = listOfNodeGroups;
43+
$scope.geojson = geojson;
44+
});
45+
}
46+
47+
function getGestaltData() {
48+
// TODO
49+
return
50+
}
51+
52+
function getOlympicsData() {
53+
// TODO
54+
return
55+
}
4656

4757
}
4858

0 commit comments

Comments
 (0)