Skip to content

Commit 090b677

Browse files
committed
[smarcet] - #10167
* survey data tagging / edition [spalenque] - #13074 * merge tags feature [spalenque] - #13075 * stats revamp
1 parent 8a14dd6 commit 090b677

File tree

60 files changed

+3197
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3197
-196
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,7 @@ auth.json
8888
autocomplete/
8989
*.patch
9090
*.mo
91-
blog
91+
blog
92+
db.ini
93+
env/
94+
*.pyc

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"jquery-ui": "~1.11.4",
2424
"jquery-validate": "~1.14.0",
2525
"bootstrap": "3.3.6",
26-
"fontawesome": "4.5.0",
27-
"bootstrap-tagsinput": "0.7.1",
26+
"fontawesome": "4.7.0",
27+
"bootstrap-tagsinput": "0.8.0",
2828
"bootstrap-datepicker": "~1.4.0",
2929
"pwstrength-bootstrap": "~1.2.7",
3030
"jquery-cookie": "~1.4.1",

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
],
1010
"require": {
1111
"php": ">=5.3.2",
12-
"silverstripe/cms": "3.1.19",
13-
"silverstripe/framework": "3.1.19",
12+
"silverstripe/cms": "3.1.20",
13+
"silverstripe/framework": "3.1.20",
1414
"ezyang/htmlpurifier": "dev-master",
1515
"undefinedoffset/sortablegridfield": "0.5.4",
1616
"tractorcow/silverstripe-colorpicker": "3.0.*@dev",

marketplace/code/ui/admin/SangriaPageMarketPlaceExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function ViewOpenStackProductsByRegion(){
165165
Requirements::clear();
166166
// css
167167

168-
Requirements::css('marketplace/ui/source/css/sangria.css');
168+
Requirements::css('sangria/ui/source/css/sangria.css');
169169
Requirements::css("themes/openstack/bower_assets/bootstrap/dist/css/bootstrap.min.css");
170170
Requirements::css("themes/openstack/bower_assets/fontawesome/css/font-awesome.min.css");
171171
Requirements::css('//fonts.googleapis.com/css?family=Open+Sans:300,400,700');

marketplace/ui/source/js/sangria-marketplace-openstack-powered-products/store.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,9 @@ import thunk from 'redux-thunk';
1717
import {openStackPoweredProducts} from './reducers';
1818
import { genericReducers } from "~core-utils/reducers";
1919

20-
/*const createStoreWithMiddleware = applyMiddleware(
21-
thunk,
22-
)(createStore);*/
23-
2420
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
2521

2622
let reducer = reduceReducers(openStackPoweredProducts, genericReducers);
2723
const store = createStore(reducer, composeEnhancers(applyMiddleware(thunk)));
2824

29-
//const store = createStoreWithMiddleware(openStackPoweredProducts);
30-
3125
export default store;

openstack/code/utils/apis/AbstractRestfulJsonApi.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
abstract class AbstractRestfulJsonApi extends Controller
2020
{
2121

22+
private static $api_prefix = null;
23+
24+
/**
25+
* @return bool
26+
*/
27+
protected function isApiCall()
28+
{
29+
$class = get_class($this);
30+
$request = $this->getRequest();
31+
32+
if (is_null($request)) {
33+
return false;
34+
}
35+
36+
$api_prefix = Config::inst()->get($class, 'api_prefix', Config::UNINHERITED);
37+
38+
if(!empty($api_prefix))
39+
return strpos(strtolower($request->getURL()), $api_prefix) !== false;
40+
41+
return false;
42+
}
43+
2244
/**
2345
* @param string $action
2446
* @return CachedMethod
@@ -158,11 +180,6 @@ public function __construct()
158180
register_shutdown_function(array($this, 'shutdown_function'));
159181
}
160182

161-
/**
162-
* @return mixed
163-
*/
164-
abstract protected function isApiCall();
165-
166183
/**
167184
* @param $realm
168185
* @return SS_HTTPResponse

package.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515
},
1616
"dependencies": {
1717
"amdefine": "^1.0.0",
18+
"babel-cli": "^6.24.1",
1819
"babel-polyfill": "^6.16.0",
20+
"bootstrap": "3.3.6",
21+
"bootstrap-3-typeahead": "^4.0.2",
22+
"bootstrap-tagsinput": "^0.7.1",
23+
"chart.js": "^2.6.0",
1924
"classnames": "^2.2.5",
25+
"font-awesome": "^4.7.0",
2026
"has-flag": "^2.0.0",
27+
"jquery": "^3.2.1",
2128
"mousetrap": "^1.6.0",
29+
"randomcolor": "^0.5.3",
2230
"react": "^15.4.1",
31+
"react-chartjs2": "^1.1.2",
32+
"react-confirm-bootstrap": "^3.1.4",
2333
"react-dom": "^15.4.1",
34+
"react-modal-bootstrap": "^1.1.1",
2435
"react-redux": "^5.0.5",
2536
"reduce-reducers": "^0.1.2",
2637
"redux-thunk": "^2.2.0",
@@ -37,7 +48,6 @@
3748
"license": "Apache-2.0",
3849
"devDependencies": {
3950
"autoprefixer-loader": "^3.2.0",
40-
"babel": "^6.5.2",
4151
"babel-core": "^6.14.0",
4252
"babel-loader": "^6.2.5",
4353
"babel-polyfill": "^6.16.0",
@@ -46,9 +56,12 @@
4656
"babel-preset-stage-2": "^6.18.0",
4757
"babel-preset-stage-3": "^6.17.0",
4858
"bower": "^1.7.9",
59+
"browser-sync-webpack-plugin": "^1.1.4",
4960
"css-loader": "^0.25.0",
61+
"expose-loader": "^0.7.3",
5062
"extract-text-webpack-plugin": "^1.0.1",
5163
"file-loader": "^0.9.0",
64+
"imports-loader": "^0.7.1",
5265
"json-loader": "^0.5.4",
5366
"less": "^2.7.1",
5467
"less-loader": "^2.2.3",

sangria/_config/routes.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Name: sangriaroutes
3+
After: 'framework/routes#coreroutes'
4+
---
5+
Director:
6+
rules:
7+
'api/v1/sangria': 'SangriaApi'

sangria/code/SangriaPage.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,19 @@ function init()
4343
Security::permissionFailure();
4444
}
4545
parent::init();
46+
47+
Requirements::css('fonts.googleapis.com/css?family=PT+Sans&subset=latin');
48+
Requirements::css('themes/openstack/css/blueprint/screen.css', 'screen, projection');
49+
Requirements::css('themes/openstack/css/blueprint/print.css', 'print');
50+
Requirements::css('themes/openstack/css/dropdown.css', 'screen, projection, print');
51+
4652
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
53+
Requirements::css("themes/openstack/javascript/datetimepicker/jquery.datetimepicker.css");
54+
Requirements::css("themes/openstack/css/deployment.survey.page.css");
55+
4756
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js');
4857
Requirements::javascript('themes/openstack/javascript/jquery.tablednd.js');
49-
Requirements::css("themes/openstack/javascript/datetimepicker/jquery.datetimepicker.css");
5058
Requirements::javascript("themes/openstack/javascript/datetimepicker/jquery.datetimepicker.js");
51-
Requirements::css("themes/openstack/css/deployment.survey.page.css");
5259
Requirements::javascript("themes/openstack/javascript/deployment.survey.filters.js");
5360

5461
self::$default_start_date = date('Y/m/d', strtotime('-1 months')) . ' 00:00';

sangria/code/SangriaPageViewCurrentStoriesExtension.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,23 @@
1919
final class SangriaPageViewCurrentStoriesExtension extends Extension
2020
{
2121

22+
static $allowed_actions = [
23+
'ViewCurrentStories',
24+
'UpdateStories',
25+
'SetAdminSS',
26+
'UnPublishFromUserStories',
27+
];
28+
2229
public function onBeforeInit()
2330
{
2431

25-
Config::inst()->update(get_class($this), 'allowed_actions', array(
26-
'ViewCurrentStories',
27-
'UpdateStories',
28-
'SetAdminSS',
29-
'UnPublishFromUserStories',
30-
));
31-
32-
Config::inst()->update(get_class($this->owner), 'allowed_actions', array(
33-
'ViewCurrentStories',
34-
'UpdateStories',
35-
'SetAdminSS',
36-
'UnPublishFromUserStories',
37-
));
32+
Config::inst()->update(get_class($this), 'allowed_actions', self::$allowed_actions);
33+
34+
Config::inst()->update(get_class($this->owner), 'allowed_actions', self::$allowed_actions);
3835
}
3936

4037
public function ViewCurrentStories(){
41-
Requirements::javascript("themes/openstack/javascript/sangria/view.current.stories.js");
38+
Requirements::javascript("sangria/ui/source/UserStories.js");
4239
return $this->owner->Customise(array())->renderWith(array('SangriaPage_ViewCurrentStories','SangriaPage','SangriaPage'));
4340
}
4441

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2017 OpenStack Foundation
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
**/
15+
class SangriaApi extends AbstractRestfulJsonApi
16+
{
17+
private static $api_prefix = 'api/v1/sangria';
18+
19+
/**
20+
* @return bool
21+
*/
22+
protected function authorize()
23+
{
24+
//check permissions
25+
if(!Permission::check("SANGRIA_ACCESS"))
26+
return false;
27+
return true;
28+
}
29+
30+
static $url_handlers = [
31+
'$SUBROUTE' => 'handleSubRoute',
32+
];
33+
34+
static $allowed_actions = [
35+
'handleSubRoute'
36+
];
37+
38+
/**
39+
* @param SS_HTTPRequest $request
40+
* @return array|mixed|SS_HTTPResponse
41+
*/
42+
public function handleSubRoute(SS_HTTPRequest $request){
43+
// @see https://docs.silverstripe.org/en/3/developer_guides/extending/extensions/
44+
45+
$subroute = $request->param('SUBROUTE');
46+
$response = new SS_HTTPResponse('route not found', 404);
47+
$res = $this->extend('handleSubRoute', $subroute, $request);
48+
49+
if(!is_null($res) && is_array($res) && count($res) > 0){
50+
$res = $res[0];
51+
if($res instanceof SS_HTTPResponse)
52+
return $res;
53+
}
54+
55+
return $response;
56+
}
57+
}

sangria/templates/Layout/SangriaPage.ss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<ul>
114114
<li><a href="$Link(SurveyBuilderListSurveys)">Full Survey</a></li>
115115
<li><a href="$Link(SurveyBuilderListDeployments)">Deployment Data Only</a></li>
116+
<li><a href="$Link(ViewSurveyFreeAnswersList)">Free Text Answers List</a></li>
116117
</ul>
117118

118119
<li>Statistics</li>

sangria/templates/SangriaPage.ss

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
<% base_tag %>
1010

11-
<!-- Google Fonts -->
12-
<link href='{$CurrentProtocol}fonts.googleapis.com/css?family=PT+Sans&subset=latin' rel='stylesheet' type='text/css'>
13-
14-
<!-- Framework CSS -->
15-
<link rel="stylesheet" href="/themes/openstack/css/blueprint/screen.css" type="text/css" media="screen, projection">
16-
<link rel="stylesheet" href="/themes/openstack/css/blueprint/print.css" type="text/css" media="print">
17-
1811
<!-- IE CSS -->
1912
<!--[if lt IE 8]><link rel="stylesheet" href="/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
2013

@@ -46,39 +39,5 @@
4639
$Message
4740
$Layout
4841
</div>
49-
50-
51-
<script type="text/javascript">
52-
jQuery(document).ready(function($){
53-
54-
$('table.stories').tableDnD({
55-
dragHandle: ".dragHandle"
56-
});
57-
58-
59-
$('form.UpdateStories').on('submit',function(e){
60-
var i = 1;
61-
$(this).find('.order').each(function(){
62-
$(this).val(i);
63-
i++;
64-
})
65-
});
66-
67-
$('td.userStoryTitle').click(function(e){
68-
var target = $(e.target);
69-
if(!target.is('input') && !target.is('a')){
70-
var val = $(this).find('input[type=text]').val();
71-
$(this).find('span').html( val ).toggle();
72-
$(this).find('input').toggle();
73-
}
74-
});
75-
76-
$('td.userStoryTitle').blur(function(){
77-
console.log($(this).val());
78-
$(this).parent().find('span').html( $(this).val() );
79-
});
80-
81-
});
82-
</script>
8342
</body>
8443
</html>

sangria/ui/source/UserStories.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright 2017 OpenStack Foundation
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
**/
13+
jQuery(document).ready(function($){
14+
15+
$('table.stories').tableDnD({
16+
dragHandle: ".dragHandle"
17+
});
18+
19+
20+
$('form.UpdateStories').on('submit',function(e){
21+
var i = 1;
22+
$(this).find('.order').each(function(){
23+
$(this).val(i);
24+
i++;
25+
})
26+
});
27+
28+
$('td.userStoryTitle').click(function(e){
29+
var target = $(e.target);
30+
if(!target.is('input') && !target.is('a')){
31+
var val = $(this).find('input[type=text]').val();
32+
$(this).find('span').html( val ).toggle();
33+
$(this).find('input').toggle();
34+
}
35+
});
36+
37+
$('td.userStoryTitle').blur(function(){
38+
$(this).parent().find('span').html( $(this).val() );
39+
});
40+
41+
$('.unpublish_ss').live('click',function(e){
42+
if(!window.confirm("Are you sure that you want to unpublish this user story?")){
43+
e.preventDefault();
44+
e.stopPropagation();
45+
return false;
46+
}
47+
return true;
48+
});
49+
50+
});

0 commit comments

Comments
 (0)