Skip to content

Commit

Permalink
Initial version of the react integration
Browse files Browse the repository at this point in the history
- We check in the JSX file of the tutorial directly into e-mission

- We include ngReact in the dependencies
- We include `<script` tags for the react libraries and ngReact itself
- We include babel in the npm dependencies
- We add a command `compile-react` to run babel to compile the JSX
- We add a README instruction on how to run it and generate the js file
- We change the app to depend on react and to create a directive with the
  `TutorialComponent`
- We add a new file `survey.html` which basically includes only the `<tutorial`
  tag in the main body
- We read the file into the scope taking i18n into account, similar to the
  other files in the intro
- We add a new slide for the new `survey.html`, using the scope variable, of course

With this change, we can see tutorial during the onboarding
e-mission/e-mission-docs#643 (comment)

This is consistent with my action item in
e-mission/e-mission-docs#643 (comment)

Note that since `package.cordovabuild.json` currently does not include any
commands, this is only supported in the devapp (serve) option. using a full
native build will not allow react components to be added.

This is fine since this is a temporary measure, which will be addressed when we
break this dependency.
  • Loading branch information
shankari committed Jul 13, 2021
1 parent 7d034e8 commit 45b6461
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ $ cp ..... www/json/connectionConfig.json
```
$ source setup/activate_serve.sh
```

### (Temporary) Every time the react component is changed

```
$ npm run compile-react
```

### Running

Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"angular-translate": "^2.18.1",
"angular-translate-loader-static-files": "^2.18.1",
"angular-translate-interpolation-messageformat": "^2.18.1",
"bottleneck": "^2.19.5"
"bottleneck": "^2.19.5",
"ngReact": "^0.5.2"
}
}
5 changes: 4 additions & 1 deletion package.serve.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
},
"scripts": {
"setup-serve": "./bin/download_settings_controls.js && ./bin/setup_autodeploy.js",
"compile-react": "babel www/components/itinerum_tutorial/ --out-dir www/components/itinerum_tutorial/ --presets react-app/prod",
"serve": "phonegap --verbose serve"
},
"devDependencies": {
"phonegap": "9.0.0+cordova.9.0.0",
"cordova": "9.0.0",
"@ionic/cli": "6.10.1",
"bower": "1.8.8"
"bower": "1.8.8",
"babel-cli": "^6.26.0",
"babel-preset-react-app": "^3.1.2"
},
"dependencies": {
"fs-extra": "^9.0.1",
Expand Down
95 changes: 95 additions & 0 deletions www/components/itinerum_tutorial/Tutorial.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* src/app/help-panel/Tutorial.jsx
*/

class TutorialComponent extends React.Component {
render() {
return(
<div className="content-wrapper">
<div className="row">
{/* bootstrap grid as margin */}
<div className="col-xs-2" />

<div className="col-xs-12 col-md-10 col-lg-8">
{/* create new grids for laying out tutorial */}
<div className="row">
<div className="col-xs-12 text-center tutorial-title">
<h2><b>Itinerum Dashboard Guide</b></h2>
</div>
</div>

{/* Permissions guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6">
<b>Permissions</b>
<p>Allows administrators to control access to web dashboard. A sign-up code can be provided to additional researchers to view survey data.</p>
</div>
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-key-variant" />
</div>
</div>

{/* Survey wizard guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-star-circle" />
</div>
<div className="col-xs-12 col-sm-6">
<b>Survey Wizard</b>
<p>A drag-and-drop survey building interface. Drag field types from the right to central survey stack to add questions to the survey. Question can be repositioned after initial drop. Click “edit” to change the prompt question and the field’s column name in answers database table.</p>
</div>
</div>

{/* Survey Stats guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6">
<b>Metrics</b>
<p>Provides dashboard overview charts and metrics for the ongoing survey.</p>
</div>
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-chart-areaspline" />
</div>
</div>

{/* Participants guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-face" />
</div>
<div className="col-xs-12 col-sm-6">
<b>Participants</b>
<p>A searchable table view of mobile users and their survey responses. Clicking on a user within the table will select their UUID within the GPS Points view.</p>
</div>
</div>

{/* GPS Points guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6">
<b>GPS Points</b>
<p>Allows admins and researchers to view any participating users points. Participants are limited to this view to display their own collected points.</p>
</div>
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-crosshairs-gps" />
</div>
</div>

{/* Data Management guide */}
<div className="row tutorial-row">
<div className="col-xs-12 col-sm-6 help-icon">
<i className="mdi mdi-cloud-download" />
</div>
<div className="col-xs-12 col-sm-6">
<b>Data Management</b>
<p>Provides downloads for survey data, uploading of subway stations and resetting of an active survey.</p>
</div>
</div>

</div>

{/* bootstrap grid as margin */}
<div className="col-xs-2" />
</div>
</div>
)
}
}
6 changes: 6 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
<!-- Manually installed javascript for libraries that are not published through bower -->
<!-- cordova script (this will be a 404 in the browser) -->
<script type="text/javascript" src="cordova.js"></script>
<script src="lib/react/react.min.js"></script>
<script src="lib/react/react-dom.min.js"></script>
<script src="lib/ngReact/ngReact.min.js"></script>

<!-- React components -->
<script src="components/itinerum_tutorial/Tutorial.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
Expand Down
6 changes: 5 additions & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// 'emission.controllers' is found in controllers.js
'use strict';

angular.module('emission', ['ionic',
angular.module('emission', ['ionic', 'react',
'emission.controllers','emission.services', 'emission.plugin.logger',
'emission.splash.customURLScheme', 'emission.splash.referral',
'emission.splash.updatecheck', 'emission.services.email',
Expand Down Expand Up @@ -72,6 +72,10 @@ angular.module('emission', ['ionic',
console.log("Ending run");
})

.directive('tutorial', function (reactDirective) {
return reactDirective(TutorialComponent);
})

.config(function($stateProvider, $urlRouterProvider, $translateProvider, $compileProvider) {
console.log("Starting config");
// alert("config");
Expand Down
6 changes: 4 additions & 2 deletions www/js/intro.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ angular.module('emission.intro', ['emission.splash.startprefs',
var allIntroFiles = Promise.all([
i18nUtils.geti18nFileName("templates/", "intro/summary", ".html"),
i18nUtils.geti18nFileName("templates/", "intro/consent", ".html"),
i18nUtils.geti18nFileName("templates/", "intro/survey", ".html"),
i18nUtils.geti18nFileName("templates/", "intro/sensor_explanation", ".html"),
i18nUtils.geti18nFileName("templates/", "intro/login", ".html")
]);
Expand All @@ -67,8 +68,9 @@ angular.module('emission.intro', ['emission.splash.startprefs',
console.log("intro files are "+allIntroFilePaths);
$scope.summaryFile = allIntroFilePaths[0];
$scope.consentFile = allIntroFilePaths[1];
$scope.explainFile = allIntroFilePaths[2];
$scope.loginFile = allIntroFilePaths[3];
$scope.surveyFile = allIntroFilePaths[2];
$scope.explainFile = allIntroFilePaths[3];
$scope.loginFile = allIntroFilePaths[4];
});
});

Expand Down
3 changes: 3 additions & 0 deletions www/templates/intro/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<ion-slide>
<ng-include src="consentFile"></ng-include>
</ion-slide>
<ion-slide>
<ng-include src="surveyFile"></ng-include>
</ion-slide>
<ion-slide>
<ng-include src="explainFile"></ng-include>
</ion-slide>
Expand Down
8 changes: 8 additions & 0 deletions www/templates/intro/survey.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ion-content class="has-footer">
<tutorial/>
</ion-content>
<ion-footer-bar class="no-bgColor" id="intro-footer">
<button class="button button-block button-outline button-positive" ng-click="next()">
SUBMIT
</button>
</ion-footer-bar>

0 comments on commit 45b6461

Please sign in to comment.