From 1c6f0d7121a15651175b4e951022a562f49dcba4 Mon Sep 17 00:00:00 2001 From: Andrei Abozau Date: Thu, 19 Oct 2017 12:06:07 +0300 Subject: [PATCH 01/75] Add base functionality and components, etc. for realize teams. --- mobile-app/src/config/routes.js | 12 +++ mobile-app/src/config/store.js | 3 + mobile-app/src/reducers/index.js | 3 +- mobile-app/src/reducers/teams/actions.js | 4 + mobile-app/src/reducers/teams/index.js | 6 ++ mobile-app/src/reducers/teams/operations.js | 3 + mobile-app/src/reducers/teams/reducer.js | 28 +++++ mobile-app/src/reducers/teams/selectors.js | 11 ++ mobile-app/src/reducers/teams/types.js | 2 + mobile-app/src/reducers/user/reducers.js | 6 ++ mobile-app/src/reducers/user/selectors.js | 11 ++ mobile-app/src/screens/Profile/Profile.js | 28 ++++- mobile-app/src/screens/Profile/styles.js | 40 ++++++++ mobile-app/src/screens/Settings/Settings.js | 13 ++- mobile-app/src/screens/Teams/Teams.js | 84 +++++++++++++++ .../components/CountryModal/CountryModal.js | 96 ++++++++++++++++++ .../Teams/components/CountryModal/index.js | 1 + .../Teams/components/CountryModal/styles.js | 30 ++++++ .../src/screens/Teams/components/Item/Item.js | 25 +++++ .../screens/Teams/components/Item/index.js | 3 + .../screens/Teams/components/Item/styles.js | 31 ++++++ .../Teams/images/icon_ui_arrowdown.png | Bin 0 -> 291 bytes .../Teams/images/icon_ui_arrowdown@2x.png | Bin 0 -> 472 bytes .../Teams/images/icon_ui_arrowdown@3x.png | Bin 0 -> 594 bytes mobile-app/src/screens/Teams/index.js | 1 + mobile-app/src/screens/Teams/styles.js | 41 ++++++++ 26 files changed, 476 insertions(+), 6 deletions(-) create mode 100644 mobile-app/src/reducers/teams/actions.js create mode 100644 mobile-app/src/reducers/teams/index.js create mode 100644 mobile-app/src/reducers/teams/operations.js create mode 100644 mobile-app/src/reducers/teams/reducer.js create mode 100644 mobile-app/src/reducers/teams/selectors.js create mode 100644 mobile-app/src/reducers/teams/types.js create mode 100644 mobile-app/src/screens/Teams/Teams.js create mode 100644 mobile-app/src/screens/Teams/components/CountryModal/CountryModal.js create mode 100644 mobile-app/src/screens/Teams/components/CountryModal/index.js create mode 100644 mobile-app/src/screens/Teams/components/CountryModal/styles.js create mode 100644 mobile-app/src/screens/Teams/components/Item/Item.js create mode 100644 mobile-app/src/screens/Teams/components/Item/index.js create mode 100644 mobile-app/src/screens/Teams/components/Item/styles.js create mode 100644 mobile-app/src/screens/Teams/images/icon_ui_arrowdown.png create mode 100644 mobile-app/src/screens/Teams/images/icon_ui_arrowdown@2x.png create mode 100644 mobile-app/src/screens/Teams/images/icon_ui_arrowdown@3x.png create mode 100644 mobile-app/src/screens/Teams/index.js create mode 100644 mobile-app/src/screens/Teams/styles.js diff --git a/mobile-app/src/config/routes.js b/mobile-app/src/config/routes.js index 4dd3643529..649275e5ab 100644 --- a/mobile-app/src/config/routes.js +++ b/mobile-app/src/config/routes.js @@ -10,6 +10,7 @@ import Details from '../screens/Details'; import Profile from '../screens/Profile'; import Settings from '../screens/Settings'; import MyActivity from '../screens/MyActivity'; +import Teams from '../screens/Teams'; import { Header, HEADER_BUTTONS_IMAGES } from '../components/Header'; import { CreateMarkerButton } from '../screens/CreateMarkerButton'; import { @@ -338,6 +339,17 @@ const AppNavigator = StackNavigator( />, }), }, + Teams: { + screen: Teams, + navigationOptions: ({ navigation }) => ({ + header: () => +
navigation.goBack(null)} + title="Teams" + leftButtonImage={HEADER_BUTTONS_IMAGES.arrowBack} + />, + }), + }, DenyTerms: { screen: DenyTerms, navigationOptions: { diff --git a/mobile-app/src/config/store.js b/mobile-app/src/config/store.js index f6c00de8a3..3530fb3350 100644 --- a/mobile-app/src/config/store.js +++ b/mobile-app/src/config/store.js @@ -8,6 +8,7 @@ import { trashpileReducer, appReducer, userReducer, + teamsReducer, } from '../reducers'; const rootReducer = combineReducers({ @@ -15,6 +16,7 @@ const rootReducer = combineReducers({ trashpile: trashpileReducer, app: appReducer, user: userReducer, + teams: teamsReducer, }); const resetStateOnSignOutReducer = reducer => (state, action) => { @@ -28,6 +30,7 @@ const resetStateOnSignOutReducer = reducer => (state, action) => { user: undefined, location: state.location, trashpile: state.trashpile, + teams: state.teams, }; return reducer(stateWithoutSensitiveData, action); }; diff --git a/mobile-app/src/reducers/index.js b/mobile-app/src/reducers/index.js index 73784e9080..73a3333d10 100644 --- a/mobile-app/src/reducers/index.js +++ b/mobile-app/src/reducers/index.js @@ -1,7 +1,8 @@ import appReducer from './app'; import { locationReducer } from './location'; import { trashpileReducer } from './trashpile'; +import { teamsReducer } from './teams'; export { default as userReducer } from './user'; -export { trashpileReducer, appReducer, locationReducer }; +export { trashpileReducer, appReducer, locationReducer, teamsReducer }; diff --git a/mobile-app/src/reducers/teams/actions.js b/mobile-app/src/reducers/teams/actions.js new file mode 100644 index 0000000000..78f6fbfcd4 --- /dev/null +++ b/mobile-app/src/reducers/teams/actions.js @@ -0,0 +1,4 @@ +import types from './types'; + +export default { +}; diff --git a/mobile-app/src/reducers/teams/index.js b/mobile-app/src/reducers/teams/index.js new file mode 100644 index 0000000000..feca445536 --- /dev/null +++ b/mobile-app/src/reducers/teams/index.js @@ -0,0 +1,6 @@ +import actions from './actions'; +import reducer from './reducer'; +import selectors from './selectors'; +import operations from './operations'; + +export { actions, reducer as teamsReducer, selectors, operations }; diff --git a/mobile-app/src/reducers/teams/operations.js b/mobile-app/src/reducers/teams/operations.js new file mode 100644 index 0000000000..a8b4d26aa2 --- /dev/null +++ b/mobile-app/src/reducers/teams/operations.js @@ -0,0 +1,3 @@ +import actions from './actions'; + +export default { ...actions }; diff --git a/mobile-app/src/reducers/teams/reducer.js b/mobile-app/src/reducers/teams/reducer.js new file mode 100644 index 0000000000..78f7578e59 --- /dev/null +++ b/mobile-app/src/reducers/teams/reducer.js @@ -0,0 +1,28 @@ +import types from './types'; + +const INITIAL_STATE = [ + { + id: 1, + name: 'Test team 1', + description: '', + }, + { + id: 2, + name: 'Test team 2', + description: '', + }, + { + id: 3, + name: 'Test team 3', + description: '', + }, + { + id: 4, + name: 'Test team 4', + description: '', + }, +]; + +export default (state = INITIAL_STATE, action) => { + return state; +}; diff --git a/mobile-app/src/reducers/teams/selectors.js b/mobile-app/src/reducers/teams/selectors.js new file mode 100644 index 0000000000..d22f1c31bf --- /dev/null +++ b/mobile-app/src/reducers/teams/selectors.js @@ -0,0 +1,11 @@ +import { createSelector } from 'reselect'; + +const stateSelector = state => state.teams; + +const teamsSelector = createSelector(stateSelector, state => { + return state; +}); + +export default { + teamsSelector, +}; diff --git a/mobile-app/src/reducers/teams/types.js b/mobile-app/src/reducers/teams/types.js new file mode 100644 index 0000000000..02a61bed5e --- /dev/null +++ b/mobile-app/src/reducers/teams/types.js @@ -0,0 +1,2 @@ +export default { +}; diff --git a/mobile-app/src/reducers/user/reducers.js b/mobile-app/src/reducers/user/reducers.js index 3b7593fa0d..237c4614c7 100644 --- a/mobile-app/src/reducers/user/reducers.js +++ b/mobile-app/src/reducers/user/reducers.js @@ -42,6 +42,9 @@ const profileReducer = (state = profileInitialState, action) => { loading: true, }; case types.FETCH_PROFILE_SUCCESS: + // TODO! Delete when backend is ready + action.payload.team = 1; + // return { ...state, loading: false, @@ -62,6 +65,9 @@ const profileReducer = (state = profileInitialState, action) => { updatingError: undefined, }; case types.UPDATE_PROFILE_DONE: + // TODO! Delete when backend is ready + action.payload.team = 1; + // return { ...state, updating: false, diff --git a/mobile-app/src/reducers/user/selectors.js b/mobile-app/src/reducers/user/selectors.js index 5d06599bf8..9b0cad8c58 100644 --- a/mobile-app/src/reducers/user/selectors.js +++ b/mobile-app/src/reducers/user/selectors.js @@ -1,5 +1,6 @@ import { createSelector } from 'reselect'; import { selectors as trashpileSelector } from '../trashpile'; +import { selectors as teamsSelector } from '../teams'; import { COUNTRY_LIST, USER_ROLES } from '../../shared/constants'; @@ -46,6 +47,15 @@ const getProfileCountry = createSelector(getProfile, (profile) => { } return COUNTRY_LIST.find(c => c.code === profile.country); }); +const getProfileTeam = createSelector(getProfile, teamsSelector.teamsSelector, + (profile, teams) => { + if (!profile || !profile.team) { + return undefined; + } + return teams.find(t => t.id === profile.team); + } +); + const getRole = createSelector(getProfile, (profile) => { if (!profile) { return undefined; @@ -65,6 +75,7 @@ export default { isProfileLoading, getProfileError, getProfileCountry, + getProfileTeam, getCachedLocation, didAgreeToTerms, getToken, diff --git a/mobile-app/src/screens/Profile/Profile.js b/mobile-app/src/screens/Profile/Profile.js index 1b83d6580c..750a2da399 100644 --- a/mobile-app/src/screens/Profile/Profile.js +++ b/mobile-app/src/screens/Profile/Profile.js @@ -4,6 +4,7 @@ import { compose } from 'recompose'; import { connect } from 'react-redux'; import { Divider } from '../../components/Divider'; +import { SimpleButton } from '../../components/Buttons'; import { selectors as userSelectors } from '../../reducers/user'; import { withNavigationHelpers } from '../../services/Navigation'; import styles from './styles'; @@ -16,7 +17,7 @@ class Profile extends Component { return ; }; render() { - const { profile, country } = this.props; + const { profile, country, team } = this.props; return ( @@ -29,18 +30,36 @@ class Profile extends Component { {country && - {country.name} - } - + + } + {team && + + + + My Team + + + + {team.name} + + + + + + + } ); } @@ -50,6 +69,7 @@ const mapStateToProps = (state) => { return { profile: userSelectors.getProfile(state), country: userSelectors.getProfileCountry(state), + team: userSelectors.getProfileTeam(state), }; }; diff --git a/mobile-app/src/screens/Profile/styles.js b/mobile-app/src/screens/Profile/styles.js index 950c29976f..701447837f 100644 --- a/mobile-app/src/screens/Profile/styles.js +++ b/mobile-app/src/screens/Profile/styles.js @@ -42,4 +42,44 @@ export default EStyleSheet.create({ marginTop: getHeightPercentage(20), alignItems: 'center', }, + teamContainer: { + paddingHorizontal: getWidthPercentage(20), + paddingVertical: getHeightPercentage(20), + flexDirection: 'column', + alignItems: 'flex-start', + backgroundColor: '$white', + }, + teamTitle: { + fontFamily: '$boldFont', + fontSize: 20, + color: '$textColor', + paddingRight: 20, + width: getWidthPercentage(165), + }, + teamText: { + fontFamily: '$font', + fontSize: 20, + color: '$textColor', + paddingRight: 20, + textAlign: 'left', + width: getWidthPercentage(165), + }, + teamNameContainer: { + paddingHorizontal: getWidthPercentage(20), + paddingVertical: getHeightPercentage(20), + display: 'flex', + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + }, + teamLeaveButton: { + width: 50, + justifyContent: 'center', + alignItems: 'center', + borderBottomLeftRadius: '$radius10', + borderBottomRightRadius: '$radius10', + height: getHeightPercentage(35), + color: '$white', + backgroundColor: '#3e8ede', + }, }); diff --git a/mobile-app/src/screens/Settings/Settings.js b/mobile-app/src/screens/Settings/Settings.js index 37bab097fe..248bf1e78e 100644 --- a/mobile-app/src/screens/Settings/Settings.js +++ b/mobile-app/src/screens/Settings/Settings.js @@ -60,6 +60,10 @@ class Settings extends Component { })); }; + handleTeamPress = () => { + this.props.navigation.navigate('Teams'); + }; + handleCountryChanged = (country) => { this.setState({ showCountryModal: false, @@ -104,7 +108,7 @@ class Settings extends Component { }; render() { - const { country } = this.props; + const { country, team } = this.props; const countrySubtitle = country ? country.name : this.props.t('label_country_picker_placeholder'); @@ -118,6 +122,12 @@ class Settings extends Component { subtitle={countrySubtitle} onPress={this.handleCountryItemPress} /> + { return { profile: userSels.getProfile(state), country: userSels.getProfileCountry(state), + team: userSels.getProfileTeam(state), isProfileUpdating: userSels.isProfileUpdating(state), }; }; diff --git a/mobile-app/src/screens/Teams/Teams.js b/mobile-app/src/screens/Teams/Teams.js new file mode 100644 index 0000000000..aaa9c11c27 --- /dev/null +++ b/mobile-app/src/screens/Teams/Teams.js @@ -0,0 +1,84 @@ +import React, { Component } from 'react'; +import { View, Text } from 'react-native'; +import { compose } from 'recompose'; +import { connect } from 'react-redux'; +import { translate } from 'react-i18next'; + +import { Divider } from '../../components/Divider'; +import { SimpleButton } from '../../components/Buttons'; +import { withNavigationHelpers } from '../../services/Navigation'; + +import { + operations as userOps, + selectors as userSels, +} from '../../reducers/user'; + +import { + operations as teamsOps, + selectors as teamsSels, +} from '../../reducers/teams'; + +import styles from './styles'; + +class Teams extends Component { + constructor(props) { + super(props); + this.handleTeamChange = this.handleTeamChange.bind(this); + } + + handleTeamChange = (team) => { + console.log(e); + this.props.updateProfile({ team: team.id }); + }; + + render() { + const team = this.props.team; + const teams = !team ? this.props.teams : + this.props.teams.filter(function(obj) { + return obj.id !== team.id; + }); + return ( + + {teams.map(function(teamsItem, key){ + return ( + + + + + {teamsItem.name} + + + {teamsItem.description && teamsItem.description} + + + + this.handleTeamChange(teamsItem)} + text="Join" + /> + + + + + ); + })} + + ); + } +} +const mapState = (state) => { + return { + team: userSels.getProfileTeam(state), + teams: teamsSels.teamsSelector(state), + }; +}; +const mapDispatch = { + updateProfile: userOps.updateProfile, +}; + +export default compose( + connect(mapState, mapDispatch), + withNavigationHelpers(), + translate(), +)(Teams); diff --git a/mobile-app/src/screens/Teams/components/CountryModal/CountryModal.js b/mobile-app/src/screens/Teams/components/CountryModal/CountryModal.js new file mode 100644 index 0000000000..28281b43e8 --- /dev/null +++ b/mobile-app/src/screens/Teams/components/CountryModal/CountryModal.js @@ -0,0 +1,96 @@ +// TODO if the need arises, port this component to a more general variant + +import React, { Component } from 'react'; +import { FormInput } from 'react-native-elements'; + +import { + TouchableOpacity, + Modal, + View, + ScrollView, + Text, + ActivityIndicator, +} from 'react-native'; + +import PropTypes from 'prop-types'; + +import { Header } from '../../../../components/Header'; + +import styles from './styles'; + +const Item = ({ key, label, onPress }) => { + return ( + + + {label} + + + ); +}; + +class CountryModal extends Component { + constructor(props) { + super(props); + this.state = { loading: true }; + } + + componentDidMount() { + setTimeout(() => { + this.setState({ loading: false }); + }, 500); + } + + render() { + const { loading } = this.state; + const { onClose, countries, onPress, search, onSearchChange, visible } = this.props; + + return ( + + +
+ + {loading + ? + + + : + + {countries.map((c) => { + return Item({ + key: c.code, + label: c.name, + onPress: () => onPress(c), + }); + })} + + } + + + ); + } +} + +CountryModal.defaultProps = { + onPress: () => null, + onSearchChange: () => null, + onClose: () => null, + search: undefined, +}; +CountryModal.propTypes = { + countries: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired, + onPress: PropTypes.func, + search: PropTypes.string, + onSearchChange: PropTypes.func, + onClose: PropTypes.func, +}; + +export default CountryModal; diff --git a/mobile-app/src/screens/Teams/components/CountryModal/index.js b/mobile-app/src/screens/Teams/components/CountryModal/index.js new file mode 100644 index 0000000000..6bd083fa15 --- /dev/null +++ b/mobile-app/src/screens/Teams/components/CountryModal/index.js @@ -0,0 +1 @@ +export { default as CountryModal } from './CountryModal'; \ No newline at end of file diff --git a/mobile-app/src/screens/Teams/components/CountryModal/styles.js b/mobile-app/src/screens/Teams/components/CountryModal/styles.js new file mode 100644 index 0000000000..8aef327f61 --- /dev/null +++ b/mobile-app/src/screens/Teams/components/CountryModal/styles.js @@ -0,0 +1,30 @@ +import EStyleSheet from 'react-native-extended-stylesheet'; +import { StyleSheet } from 'react-native'; +import { getHeightPercentage } from '../../../../shared/helpers'; + +export default EStyleSheet.create({ + inputContainer: { + marginTop: getHeightPercentage(20), + paddingHorizontal: 5, + }, + listContainer: { + marginTop: getHeightPercentage(5), + }, + loadingContainer: { + flex: 1, + alignItems: 'center', + justifyContent: 'center', + }, + item: { + // height: getHeightPercentage(25), + borderBottomWidth: StyleSheet.hairlineWidth, + borderBottomColor: '#bbb', + justifyContent: 'center', + }, + itemText: { + fontSize: 16, + fontFamily: '$font', + margin: 10, + // textAlign: 'center', + }, +}); diff --git a/mobile-app/src/screens/Teams/components/Item/Item.js b/mobile-app/src/screens/Teams/components/Item/Item.js new file mode 100644 index 0000000000..5d651baf4a --- /dev/null +++ b/mobile-app/src/screens/Teams/components/Item/Item.js @@ -0,0 +1,25 @@ +import React from 'react'; +import { View, Text, TouchableOpacity, Image } from 'react-native'; +import styles from './styles'; + +const Item = ({ title, buttonText, onPress, optionSelected, imageStyles }) => { + const Container = onPress ? TouchableOpacity : View; + + return ( + + + {title} + + + + {optionSelected} + + + + + + + ); +}; + +export default Item; diff --git a/mobile-app/src/screens/Teams/components/Item/index.js b/mobile-app/src/screens/Teams/components/Item/index.js new file mode 100644 index 0000000000..54e4799135 --- /dev/null +++ b/mobile-app/src/screens/Teams/components/Item/index.js @@ -0,0 +1,3 @@ +import Item from './Item'; + +export { Item }; diff --git a/mobile-app/src/screens/Teams/components/Item/styles.js b/mobile-app/src/screens/Teams/components/Item/styles.js new file mode 100644 index 0000000000..d5889c1fe9 --- /dev/null +++ b/mobile-app/src/screens/Teams/components/Item/styles.js @@ -0,0 +1,31 @@ +import EStyleSheet from 'react-native-extended-stylesheet'; + +import { getWidthPercentage, getHeightPercentage } from '../../../../shared/helpers'; + +export default EStyleSheet.create({ + container: { + paddingHorizontal: getWidthPercentage(20), + paddingTop: getHeightPercentage(20), + }, + title: { + fontFamily: '$font', + fontSize: '$fontDefaultSize', + color: '$textColor', + }, + content: { + flexDirection: 'row', + alignItems: 'center', + borderBottomWidth: 1, + borderBottomColor: '#DCDCDC', + paddingBottom: getHeightPercentage(5), + }, + optionText: { + fontFamily: '$boldFont', + fontSize: '$fontDefaultSize', + color: '$textColor', + }, + imageContainer: { + flex: 1, + alignItems: 'flex-end', + }, +}); diff --git a/mobile-app/src/screens/Teams/images/icon_ui_arrowdown.png b/mobile-app/src/screens/Teams/images/icon_ui_arrowdown.png new file mode 100644 index 0000000000000000000000000000000000000000..dc31d4f8d491b23aecbbe9792d3c995c096d7b67 GIT binary patch literal 291 zcmV+;0o?wHP)Px#-AP12R2Ug!wC}rL$jJ1c+aX`Et$~s89|IQPIqA9R*S|lS8JQSYvH<1t|NUc- z-#_7ja>M`s$>^FuiogB+v7h1pf9?N3YrxdR zw48zQzuy0U5R+kwLF(WdKpdwD_w4@uW84O^2`mY82C`zX7>GayAWeV%G3){Q>k}6X phbG7w$nsd(zB8Y3A$uNK5devwYfHdvdb6P)Px$l1W5CR5%gEltC{8Q4q&x-fkr>A|WJ-rj8`sBu*r49JP_OBBF_ViErQ|5b*^> z9JCi4RcTzD_2A%A8}uL?xDai3ylK77irx0L7jv1H_x}6)@64NBOk~J-DO+)n(LWSA z&L*+O>rNxGYmL`znh~abevuxtaCW=2PeiFY5b$3!!2N zycT9xAccT8&H2E1t3LPx%3`s;mR7ef&mOD!WK@fmv))O`21MvYtF!=!rVx@%&+N2P*v9T2bBBK5cA%XaS zfM8{1A!3m#J_>CG3md^GLTuDRG^lxuI~Ok`xG{T|)5?KmcV}mIK8Bs$1^ANj=u-=0_+>LwR7=>?#E(7H^+ep)ul3t5FiGLs76LT z69}`%%l;cd1R<%M0wUzb<8=Dta5S21cN4A=YB#5{(7g&8DEUPeOK8+_2L`M2J|nbL-- z@lD4T@ttE9fOz62loOb5KyE=fg;4@k3sntFSsmcF>h|^T&ftd~h+ Date: Thu, 19 Oct 2017 13:16:03 +0300 Subject: [PATCH 02/75] Add endpoint to change team --- .idea/World-Cleanup-Day.iml | 12 + .idea/inspectionProfiles/Project_Default.xml | 7 + .idea/jsLibraryMappings.xml | 6 + .idea/markdown-navigator.xml | 72 ++++ .../markdown-navigator/profiles_settings.xml | 3 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + .idea/workspace.xml | 315 ++++++++++++++++++ backend-api/api/controllers/users.js | 6 + backend-api/api/v1.0.yaml | 29 ++ backend-db/modules/db/couchdb/index.js | 3 +- backend-db/modules/db/types.js | 2 + backend-db/plugins/accounts.js | 4 +- mobile-app/src/reducers/app/reducers.js | 1 + mobile-app/src/reducers/teams/operations.js | 19 +- mobile-app/src/screens/Teams/Teams.js | 13 +- module-logger/yarn-error.log | 73 ++++ module-service-factory/yarn-error.log | 301 +++++++++++++++++ module-util/yarn-error.log | 47 +++ 20 files changed, 924 insertions(+), 9 deletions(-) create mode 100644 .idea/World-Cleanup-Day.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/jsLibraryMappings.xml create mode 100644 .idea/markdown-navigator.xml create mode 100644 .idea/markdown-navigator/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 module-logger/yarn-error.log create mode 100644 module-service-factory/yarn-error.log create mode 100644 module-util/yarn-error.log diff --git a/.idea/World-Cleanup-Day.iml b/.idea/World-Cleanup-Day.iml new file mode 100644 index 0000000000..24643cc374 --- /dev/null +++ b/.idea/World-Cleanup-Day.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000..e62fe69269 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000000..d23208fbb7 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml new file mode 100644 index 0000000000..34c321cb9f --- /dev/null +++ b/.idea/markdown-navigator.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml new file mode 100644 index 0000000000..57927c5a72 --- /dev/null +++ b/.idea/markdown-navigator/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000..28a804d893 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000..95b65fdbe4 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000..94a25f7f4c --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000000..74b0b38a6c --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,315 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + int + ModifyTeam + modifyOwnUserProfile + CountryCode + country + createAccount + pictureURL + + + $PROJECT_DIR$/backend-api/api + $PROJECT_DIR$/backend-api/modules + $PROJECT_DIR$ + $PROJECT_DIR$/backend-db + + + + + + + + + + + true + + false + true + true + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -199,6 +327,18 @@ + + + + + + + + + + + + - - - + - - - - + + - - + + - + + + @@ -258,58 +482,405 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - + + - + - - + + - + - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend-api/.gitignore b/backend-api/.gitignore index 4fdf7d34f9..90843324ab 100644 --- a/backend-api/.gitignore +++ b/backend-api/.gitignore @@ -1,4 +1,4 @@ .vscode/ node_modules/ -.idea .idea/ +yarn-error.log diff --git a/backend-api/api/controllers/teamtrashpoints.js b/backend-api/api/controllers/teamtrashpoints.js new file mode 100644 index 0000000000..c25507fe71 --- /dev/null +++ b/backend-api/api/controllers/teamtrashpoints.js @@ -0,0 +1,14 @@ +'use strict'; +const senecaRequestMw = require('../../modules/swagger-setup/middleware/seneca'); + +module.exports = { + getCountTeamTrashpoints: senecaRequestMw( + 'role:db,cmd:getCountTeamTrashpoints', + ), + getTeamTrashpoint: senecaRequestMw( + 'role:db,cmd:getTeamTrashpoint', + req => ({ + id: req.swagger.params.id.value, + }), + ) +}; diff --git a/backend-api/api/v1.0.yaml b/backend-api/api/v1.0.yaml index 10f5428f9e..30c36ecb89 100644 --- a/backend-api/api/v1.0.yaml +++ b/backend-api/api/v1.0.yaml @@ -237,6 +237,20 @@ paths: $ref: "#/definitions/Team" "default": $ref: "#/responses/ErrorSet" + /teamtrashpoints: + x-swagger-router-controller: teamtrashpoints + get: + description: List all teams with trashpoints counter. + operationId: getCountTeamTrashpoints + responses: + "200": + description: List of teams with trashpoints counter. + schema: + type: array + items: + $ref: "#/definitions/TeamTrashpoint" + "default": + $ref: "#/responses/ErrorSet" #----------------------------------------------------------------------------- /areas/user: x-swagger-router-controller: areas @@ -791,6 +805,19 @@ definitions: description: description: Desctiption of team type: string + TeamTrashpoint: + type: object + required: [id, name] + properties: + id: + description: A unique code of team + type: string + name: + description: A name of team + type: string + trashpoints: + description: Count of trashpoints of team + type: string #----------------------------------------------------------------------------- # Account properties. #----------------------------------------------------------------------------- diff --git a/backend-auth/.gitignore b/backend-auth/.gitignore index 8d056c8e97..90843324ab 100644 --- a/backend-auth/.gitignore +++ b/backend-auth/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/backend-db/.gitignore b/backend-db/.gitignore index 8d056c8e97..90843324ab 100644 --- a/backend-db/.gitignore +++ b/backend-db/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/backend-db/modules/db/couchdb/design/index.js b/backend-db/modules/db/couchdb/design/index.js index 72805ac425..7f875962ca 100644 --- a/backend-db/modules/db/couchdb/design/index.js +++ b/backend-db/modules/db/couchdb/design/index.js @@ -178,6 +178,19 @@ const designDocs = { }, }, }, + countByTeam: { + $version: 1, + views: { + view: { + map: function (doc) { + if (doc.$doctype === 'teamtrashpoints' && doc.team) { + emit(doc.team, null); + } + }, + reduce: '_count', + }, + }, + }, }, areas: { all: { diff --git a/backend-db/modules/db/couchdb/index.js b/backend-db/modules/db/couchdb/index.js index 14492e9937..ad48c48b79 100644 --- a/backend-db/modules/db/couchdb/index.js +++ b/backend-db/modules/db/couchdb/index.js @@ -710,6 +710,16 @@ const layer = { }); return await layer.getTeamTrashpoint(id); }, + countTrashpointsForTeam: async team => { + const ret = await adapter.getRawDocs('TeamTrashpoint', '_design/countByTeam/_view/view', { + key: team, + group: true, + }); + if (!ret.length) { + return 0; + } + return parseInt(ret.pop()); + }, }; module.exports = layer; diff --git a/backend-db/plugins/teamtrashpoints.js b/backend-db/plugins/teamtrashpoints.js index 9568e35f2d..76a91ba062 100644 --- a/backend-db/plugins/teamtrashpoints.js +++ b/backend-db/plugins/teamtrashpoints.js @@ -33,5 +33,23 @@ module.exports = function () { }); }); + lucius.register('role:db,cmd:getCountTeamTrashpoints', async function (connector, args, __) { + return connector.input(args) + .use(async function ({}, responder) { + let teams = await db.getAllTeams(); + let teamsCount = []; + + for (let team of teams) { + let total = await db.countTrashpointsForTeam(team.id); + teamsCount.push({ + id: team.id, + name: team.name, + trashpoints: total + }); + } + return responder.success(teamsCount); + }); + }); + return PLUGIN_NAME; }; diff --git a/backend-geo/.gitignore b/backend-geo/.gitignore index 8d056c8e97..90843324ab 100644 --- a/backend-geo/.gitignore +++ b/backend-geo/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/mobile-app/.gitignore b/mobile-app/.gitignore index 3fbd35dc6b..a0bd77cb9f 100644 --- a/mobile-app/.gitignore +++ b/mobile-app/.gitignore @@ -2,10 +2,10 @@ node_modules/ .expo/ npm-debug.* -.idea - +.idea/ +yarn-error.log *.DS_STORE app.json -env.js \ No newline at end of file +env.js diff --git a/mobile-app/src/reducers/trashpile/operations.js b/mobile-app/src/reducers/trashpile/operations.js index ee8de7191f..a2da76a95a 100644 --- a/mobile-app/src/reducers/trashpile/operations.js +++ b/mobile-app/src/reducers/trashpile/operations.js @@ -178,6 +178,7 @@ export const handleUpload = async ({ photos, markerId }) => { if ((photos || []).length === 0) { return true; } + console.log('photos', photos); const photosResponse = await getUploadURIsForPhotos(photos, markerId); const uploadedPhotosIds = { @@ -185,7 +186,7 @@ export const handleUpload = async ({ photos, markerId }) => { failed: [], backendConfirmed: false, }; - + console.log('photosResponse', photosResponse); if (photosResponse) { const thumbnailsPhotos = photosResponse.data .filter(pr => pr.type === TRASHPOINT_IMAGE_TYPES.THUMBNAIL) @@ -210,7 +211,7 @@ export const handleUpload = async ({ photos, markerId }) => { }); const handledPhotos = [...thumbnailsPhotos, ...mediumPhotos]; - + console.log('handledPhotos', handledPhotos); const uploadedPhotosResponses = await uploadPhotosOnAzure(handledPhotos); if (uploadedPhotosResponses) { diff --git a/module-logger/.gitignore b/module-logger/.gitignore index 8d056c8e97..90843324ab 100644 --- a/module-logger/.gitignore +++ b/module-logger/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/module-logger/yarn-error.log b/module-logger/yarn-error.log index c54374fffa..2951c4ac1e 100644 --- a/module-logger/yarn-error.log +++ b/module-logger/yarn-error.log @@ -70,4 +70,4 @@ Lockfile: stack-trace "0.0.x" Trace: - Error: ENOENT: no such file or directory, open '/module-logger/node_modules/eyes/test/eyes-test.js' + Error: ENOENT: no such file or directory, utime '/module-logger/node_modules/async/.jshintrc' diff --git a/module-lucius/.gitignore b/module-lucius/.gitignore index 8d056c8e97..90843324ab 100644 --- a/module-lucius/.gitignore +++ b/module-lucius/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/module-service-factory/.gitignore b/module-service-factory/.gitignore index 8d056c8e97..90843324ab 100644 --- a/module-service-factory/.gitignore +++ b/module-service-factory/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/module-service-factory/yarn-error.log b/module-service-factory/yarn-error.log index b71a2d1622..5f9286441d 100644 --- a/module-service-factory/yarn-error.log +++ b/module-service-factory/yarn-error.log @@ -298,4 +298,4 @@ Lockfile: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" Trace: - Error: ENOENT: no such file or directory, open '/module-service-factory/node_modules/archy/.travis.yml' + Error: ENOENT: no such file or directory, open '/module-service-factory/node_modules/split2/.README.md.un~' diff --git a/module-util/.gitignore b/module-util/.gitignore index 8d056c8e97..90843324ab 100644 --- a/module-util/.gitignore +++ b/module-util/.gitignore @@ -1,2 +1,4 @@ .vscode/ node_modules/ +.idea/ +yarn-error.log diff --git a/web-app/.gitignore b/web-app/.gitignore index 21afa450b9..c4a70ce637 100644 --- a/web-app/.gitignore +++ b/web-app/.gitignore @@ -1,7 +1,7 @@ .vscode/ node_modules/ -.idea +.idea/ build src/env.js - -.DS_STORE \ No newline at end of file +yarn-error.log +.DS_STORE From 3af2039a04a280763d14cb27ce67da450ee7be85 Mon Sep 17 00:00:00 2001 From: Andrei Abozau Date: Thu, 2 Nov 2017 13:16:59 +0200 Subject: [PATCH 18/75] Remove .idea/ and yarn-error.log files from git --- .idea/workspace.xml | 45 ++-- module-logger/yarn-error.log | 73 ------- module-service-factory/yarn-error.log | 301 -------------------------- module-util/yarn-error.log | 47 ---- 4 files changed, 14 insertions(+), 452 deletions(-) delete mode 100644 module-logger/yarn-error.log delete mode 100644 module-service-factory/yarn-error.log delete mode 100644 module-util/yarn-error.log diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 39802b0218..9c974cf227 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,37 +2,12 @@ - - - - - - - - - - - - - - - - - - - + - - - - - - - @@ -390,7 +365,7 @@ - + 1508681862940 @@ -448,11 +423,18 @@ - - @@ -460,6 +442,7 @@ + @@ -472,7 +455,6 @@ - @@ -491,7 +473,8 @@ -