From c3c0aafcd5110bea65ef488e309397a7acec9982 Mon Sep 17 00:00:00 2001 From: "yasir.aktunc" Date: Thu, 20 Feb 2020 21:27:07 +0300 Subject: [PATCH 1/5] Tenant edit begin --- .../src/components/routing/routingConfig.tsx | 8 +- .../src/components/sidebar/sidebar.tsx | 147 ++++++++---------- react-native/src/scenes/Users/users.tsx | 1 + react-native/src/services/httpService.ts | 5 +- react-native/src/utils/utils.ts | 14 +- 5 files changed, 82 insertions(+), 93 deletions(-) diff --git a/react-native/src/components/routing/routingConfig.tsx b/react-native/src/components/routing/routingConfig.tsx index c6a9bfba6..ab7aa9703 100644 --- a/react-native/src/components/routing/routingConfig.tsx +++ b/react-native/src/components/routing/routingConfig.tsx @@ -67,12 +67,12 @@ const AuthStack = createDrawerNavigator( }, { initialRouteName: 'Dashboard', - contentOptions: { - activeTintColor: 'red', - }, edgeWidth: 50, - drawerBackgroundColor: 'rgba(255,255,255,0)', contentComponent: props => , + // contentOptions: { + // activeTintColor: '#00CBFF', + // activeBackgroundColor: '#F6F6F6', + // }, }, ); diff --git a/react-native/src/components/sidebar/sidebar.tsx b/react-native/src/components/sidebar/sidebar.tsx index f890fee1b..7f04c09bf 100644 --- a/react-native/src/components/sidebar/sidebar.tsx +++ b/react-native/src/components/sidebar/sidebar.tsx @@ -1,87 +1,74 @@ -import React from 'react' -import { Image, TouchableHighlight } from 'react-native' -import { Container, Text, List, ListItem, View, Icon } from 'native-base' -import { DrawerContentComponentProps } from 'react-navigation-drawer' -import { NavigationRoute } from 'react-navigation' +import React from 'react'; +import { Image, TouchableHighlight } from 'react-native'; +import { Container, Text, View, Icon } from 'native-base'; +import { DrawerContentComponentProps, DrawerNavigatorItems } from 'react-navigation-drawer'; +import { NavigationRoute } from 'react-navigation'; interface Props extends DrawerContentComponentProps {} interface State {} export default class SideBar extends React.Component { - _keyExtractor = (item: NavigationRoute) => item.routeName + _keyExtractor = (item: NavigationRoute) => item.routeName; - render() { - return ( - - - {}} underlayColor={'rgba(255,255,255,0)'}> - - - {}} underlayColor={'rgba(255,255,255,0)'}> - @Yasir.Aktunc - - - - { - return ( - this.props.navigation!.navigate(data.routeName)} - > - {data.key} - - ) - }} - /> - - - { - this.props.navigation!.navigate('App') - }} - /> - Log Out - - - ) - } + render() { + return ( + + + {}} underlayColor={'rgba(255,255,255,0)'}> + + + {}} underlayColor={'rgba(255,255,255,0)'}> + @Yasir.Aktunc + + + + + + + { + this.props.navigation!.navigate('App'); + }} + /> + Log Out + + + ); + } } diff --git a/react-native/src/scenes/Users/users.tsx b/react-native/src/scenes/Users/users.tsx index 3ce54ddac..bc5ed36d6 100644 --- a/react-native/src/scenes/Users/users.tsx +++ b/react-native/src/scenes/Users/users.tsx @@ -108,6 +108,7 @@ class Users extends Component { // }; async componentWillMount() { + debugger; await this.props.userStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: '' }); } diff --git a/react-native/src/services/httpService.ts b/react-native/src/services/httpService.ts index db8b2e798..29f6d8356 100644 --- a/react-native/src/services/httpService.ts +++ b/react-native/src/services/httpService.ts @@ -32,12 +32,12 @@ http.interceptors.request.use( // if (!!abp.auth.getToken()) { config.headers.common.Authorization = - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6IjllNWZiNWU5LWNiYjctNGI2Ny04YTBjLTZkYjRhYzJjNWQzMyIsImlhdCI6MTU4MjExNTYzOSwibmJmIjoxNTgyMTE1NjM5LCJleHAiOjE1ODIyMDIwMzksImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.u1Ud53WWlPnf6oi4nIknHpgh1zjLyn35fNYJO2pHp_c '; + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6ImU5ZTJkYTI2LWQ1NGYtNDcyYS1iYjI0LWVmZWZiNGNkMTQ2MSIsImlhdCI6MTU4MjIyMzA0MiwibmJmIjoxNTgyMjIzMDQyLCJleHAiOjE1ODIzMDk0NDIsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.dDrTLJRotbMHC_KYz7wffHhbzaFJZ5V5VoeqtYHOmY0'; // } // config.headers.common['.AspNetCore.Culture'] = abp.utils.getCookieValue('Abp.Localization.CultureName'); // config.headers.common['Abp.TenantId'] = abp.multiTenancy.getTenantIdCookie(); - config.headers.common['Abp.TenantId'] = 1; + //config.headers.common['Abp.TenantId'] = 1; return config; }, function(error) { @@ -52,6 +52,7 @@ http.interceptors.response.use( }, error => { hideFunc(); + debugger; if ( !!error.response && !!error.response.data.error && diff --git a/react-native/src/utils/utils.ts b/react-native/src/utils/utils.ts index bdda87c5d..d9c93a57b 100644 --- a/react-native/src/utils/utils.ts +++ b/react-native/src/utils/utils.ts @@ -1,9 +1,9 @@ -import { Toast } from 'native-base' +import { Toast } from 'native-base'; export const _toast = (message: string, type: any = 'danger') => { - Toast.show({ - text: message, - duration: 2000, - type: type, - }) -} + Toast.show({ + text: message, + duration: 2000, + type: type, + }); +}; From d95771abb20b56250b1baf610c9a1593f5e97675 Mon Sep 17 00:00:00 2001 From: "yasir.aktunc" Date: Wed, 26 Feb 2020 23:39:04 +0300 Subject: [PATCH 2/5] Role list, create and update done --- react-native/src/components/loader/loader.tsx | 72 ++--- .../src/components/routing/routingConfig.tsx | 6 +- .../src/scenes/Roles/createOrEditRole.tsx | 249 +++++++++++++++++ react-native/src/scenes/Roles/roles.tsx | 145 +++++++++- react-native/src/scenes/Setting/setting.tsx | 255 +++++++++++------- .../src/scenes/Tenants/createOrEditTenant.tsx | 1 - react-native/src/scenes/Tenants/tenants.tsx | 10 - react-native/src/services/httpService.ts | 2 +- 8 files changed, 576 insertions(+), 164 deletions(-) create mode 100644 react-native/src/scenes/Roles/createOrEditRole.tsx diff --git a/react-native/src/components/loader/loader.tsx b/react-native/src/components/loader/loader.tsx index 8eb05f5cd..4aa91e314 100644 --- a/react-native/src/components/loader/loader.tsx +++ b/react-native/src/components/loader/loader.tsx @@ -1,46 +1,46 @@ -import React from 'react'; +import React from 'react'; import { StyleSheet, View, Modal, ActivityIndicator } from 'react-native'; interface Props { - loading: boolean + loading: boolean; } const Loader = (props: Props) => { - const { loading } = props; - return ( - { - console.log('close modal'); - }} - > - - - - - - - ) -} + const { loading } = props; + return ( + { + console.log('close modal'); + }} + > + + + + + + + ); +}; const styles = StyleSheet.create({ - modalBackground: { - flex: 1, - alignItems: 'center', - flexDirection: 'column', - justifyContent: 'space-around', - backgroundColor: 'rgba(191, 191, 191, 0.5)', - }, - activityIndicatorWrapper: { - backgroundColor: '#000000', - height: 100, - width: 100, - borderRadius: 10, - display: 'flex', - alignItems: 'center', - justifyContent: 'space-around', - }, + modalBackground: { + flex: 1, + alignItems: 'center', + flexDirection: 'column', + justifyContent: 'space-around', + backgroundColor: 'rgba(191, 191, 191, 0.5)', + }, + activityIndicatorWrapper: { + backgroundColor: '#000000', + height: 100, + width: 100, + borderRadius: 10, + display: 'flex', + alignItems: 'center', + justifyContent: 'space-around', + }, }); export default Loader; diff --git a/react-native/src/components/routing/routingConfig.tsx b/react-native/src/components/routing/routingConfig.tsx index 5f88cf578..15215745c 100644 --- a/react-native/src/components/routing/routingConfig.tsx +++ b/react-native/src/components/routing/routingConfig.tsx @@ -13,6 +13,7 @@ import Setting from '../../scenes/Setting/setting'; import { httpServiceFunc } from '../../services/httpService'; import { Root, Button, Icon } from 'native-base'; import { CreateOrEditTenant } from '../../scenes/Tenants/createOrEditTenant'; +import { CreateOrEditRole } from '../../scenes/Roles/createOrEditRole'; const AuthStack2 = createStackNavigator( { @@ -34,9 +35,12 @@ const AuthStack2 = createStackNavigator( CreateOrEditTenant: { screen: CreateOrEditTenant, }, + CreateOrEditRoles: { + screen: CreateOrEditRole, + }, }, { - initialRouteName: 'Tenants', + initialRouteName: 'Roles', defaultNavigationOptions: ({ navigation }) => ({ headerLeft: ( + ), + }; + }; + + isEdit = (): boolean => { + return this.props.navigation.getParam('id') !== ''; + }; + + async componentWillMount() { + if (this.isEdit()) { + await this.props.roleStore.getRoleForEdit({ + id: parseInt(this.props.navigation.getParam("id")), + }); + await this.props.roleStore.getAllPermissions(); + } else { + this.props.roleStore.createRole(); + await this.props.roleStore.getAllPermissions(); + } + } + createOrUpdateRole = value => { + debugger; + this.props.roleStore!.update(); + // if (this.isEdit()) { + // this.propss + // .tenantStore!.update({ + // id: parseInt(this.props.navigation.getParam('id')), + // tenancyName: value.tenancyName, + // isActive: value.isActive, + // name: value.name, + // }) + // .then(() => _toast('Update başarılı', 'success')); + // } else { + // this.props + // .tenantStore!.create({ + // tenancyName: value.tenancyName, + // isActive: value.isActive, + // name: value.name, + // connectionString: value.databaseConnectionString, + // adminEmailAddress: value.emailAdress, + // }) + // .then(() => _toast('Tenant Oluşturuldu', 'success')); + // } + }; + + render() { + const { roleEdit, allPermissions } = this.props.roleStore!; + const grantedPermissions = allPermissions.map((x: GetAllPermissionsOutput) => { + return roleEdit.grantedPermissionNames.indexOf(x.name) != -1; + }); + return ( + + + + + + this.createOrUpdateRole(value)} + > + {({ handleChange, values, handleSubmit, errors, handleBlur, setFieldValue }) => ( + <> + + + this.name._root.focus()} + value={values.displayName} + onChangeText={handleChange('displayName')} + /> + {errors.displayName ? ( + + ) : ( + + )} + + + + + this.description._root.focus()} + onBlur={handleBlur} + getRef={(ref: any) => { + this.name = ref; + }} + returnKeyType="next" + value={values.name} + onChangeText={handleChange('name')} + /> + {errors.name ? ( + + ) : ( + + )} + + + + { + this.description = ref; + }} + returnKeyType="done" + onSubmitEditing={() => handleSubmit()} + onBlur={handleBlur} + value={values.description} + onChangeText={handleChange('description')} + /> + {errors.description ? ( + + ) : ( + + )} + + + {allPermissions.map((x: GetAllPermissionsOutput, index) => { + return ( + + + setFieldValue(`grantedPermissions[${index}]`, value) + } + /> + + + ); + })} + + + + )} + + + + + + + ); + } +} + +const styles = StyleSheet.create({ + marginVrtcl: { + marginVertical: 5, + }, +}); +export default CreateOrEditRole; diff --git a/react-native/src/scenes/Roles/roles.tsx b/react-native/src/scenes/Roles/roles.tsx index cdb5063a4..7f5b2ef55 100644 --- a/react-native/src/scenes/Roles/roles.tsx +++ b/react-native/src/scenes/Roles/roles.tsx @@ -1,33 +1,154 @@ -import React from 'react'; -import {Text} from 'react-native'; -import { Button } from 'native-base'; -import { NavigationStackProp } from 'react-navigation-stack'; - +import React from "react"; +import { View, Fab, Icon, Container, Button, Text, ActionSheet } from "native-base"; +import { NavigationStackProp } from "react-navigation-stack"; +import RoleStore from "../../stores/roleStore"; +import { StyleSheet, RefreshControl } from "react-native"; +import { observer, inject } from "mobx-react"; +import Stores from "../../stores/storeIdentifier"; +import { SwipeListView } from "react-native-swipe-list-view"; export interface Props { navigation: NavigationStackProp; + roleStore: RoleStore; } export interface State { - + reflesing: boolean; } - +@inject(Stores.RoleStore) +@observer export class Roles extends React.Component { - constructor(props) { super(props); + this.state = { reflesing: false }; + } + async componentWillMount() { + await this.props.roleStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: "" }); + } + async handleReflesh() { + this.setState( + { reflesing: true }, + async () => + await this.props + .roleStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: "" }) + .then(() => this.setState({ reflesing: false })), + ); } render() { + const { roles } = this.props.roleStore!; return ( - - Roles + + this.handleReflesh()} + /> + } + closeOnRowPress + closeOnRowOpen + closeOnRowBeginSwipe + closeOnScroll + data={roles === undefined ? [] : roles.items} + renderItem={data => ( + + {data.item.displayName} + + )} + renderHiddenItem={data => ( + + + + + )} + leftOpenValue={75} + rightOpenValue={-75} + /> + + + this.props.navigation.navigate("CreateOrEditRoles", { + id: '', + }) + } + > + + + + ); } } +const styles = StyleSheet.create({ + rowFront: { + alignItems: "center", + backgroundColor: "#F5F5F5", + borderBottomColor: "#BDBDBD", + borderBottomWidth: 1, + justifyContent: "center", + height: 50, + }, + rowBack: { + alignItems: "center", + flex: 1, + flexDirection: "row", + justifyContent: "space-between", + }, + rowBackLeft: { + width: 75, + backgroundColor: '#303F9F', + margin: 0, + borderRadius: 0, + justifyContent: 'center', + }, + rowBackRight: { + width: 75, + backgroundColor: '#d32f2f', + margin: 0, + borderRadius: 0, + justifyContent: 'center', + }, + editIcon: { + color: '#fff', + }, + trashIcon: { + color: '#fff', + }, +}); - -export default Roles; \ No newline at end of file +export default Roles; diff --git a/react-native/src/scenes/Setting/setting.tsx b/react-native/src/scenes/Setting/setting.tsx index a9f4bde82..4a6fc3d86 100644 --- a/react-native/src/scenes/Setting/setting.tsx +++ b/react-native/src/scenes/Setting/setting.tsx @@ -12,6 +12,12 @@ import { Icon, Label, Text, + Tabs, + Tab, + ListItem, + Left, + Right, + Radio, } from 'native-base'; import { StyleSheet } from 'react-native'; import Stores from '../../stores/storeIdentifier'; @@ -34,113 +40,156 @@ export class Setting extends React.Component { super(props); } + getRandomColor = () => { + var letters = '0123456789ABCDEF'; + var color = '#'; + for (var i = 0; i < 6; i++) { + color += letters[Math.floor(Math.random() * 16)]; + } + return color; + }; + render() { return ( - - - Change Password - - - - console.log(value.currentPassword)} - > - {({ handleChange, values, handleSubmit, errors, handleBlur }) => ( - <> - - - this.newpassword.focus()} - onBlur={handleBlur} - returnKeyType="next" - secureTextEntry={true} - value={values.currentPassword} - onChangeText={handleChange('currentPassword')} - /> - {errors.currentPassword ? ( - - ) : ( - - )} - - - - this.newpasswordConfirm.focus()} - onBlur={handleBlur} - ref={(ref: any) => { - this.newpassword = ref; - }} - returnKeyType="next" - secureTextEntry={true} - value={values.newPassword} - onChangeText={handleChange('newPassword')} - /> - {errors.newPassword ? ( - - ) : ( - - )} - - - - { - this.newpasswordConfirm = ref; - }} - returnKeyType="done" - onSubmitEditing={() => handleSubmit()} - onBlur={handleBlur} - secureTextEntry={true} - value={values.newPasswordConfirm} - onChangeText={handleChange('newPasswordConfirm')} - /> - {errors.newPasswordConfirm ? ( - - ) : ( - - )} - - - - )} - - - - + + + + + Change Password + + + + console.log(value.currentPassword)} + > + {({ handleChange, values, handleSubmit, errors, handleBlur }) => ( + <> + + + this.newpassword.focus()} + onBlur={handleBlur} + returnKeyType="next" + secureTextEntry={true} + value={values.currentPassword} + onChangeText={handleChange('currentPassword')} + /> + {errors.currentPassword ? ( + + ) : ( + + )} + + + + this.newpasswordConfirm.focus()} + onBlur={handleBlur} + ref={(ref: any) => { + this.newpassword = ref; + }} + returnKeyType="next" + secureTextEntry={true} + value={values.newPassword} + onChangeText={handleChange('newPassword')} + /> + {errors.newPassword ? ( + + ) : ( + + )} + + + + { + this.newpasswordConfirm = ref; + }} + returnKeyType="done" + onSubmitEditing={() => handleSubmit()} + onBlur={handleBlur} + secureTextEntry={true} + value={values.newPasswordConfirm} + onChangeText={handleChange('newPasswordConfirm')} + /> + {errors.newPasswordConfirm ? ( + + ) : ( + + )} + + + + )} + + + + + + + + + Lunch Break + + + + + + + + Discussion with Client + + + + + + + ); diff --git a/react-native/src/scenes/Tenants/createOrEditTenant.tsx b/react-native/src/scenes/Tenants/createOrEditTenant.tsx index 7215e5277..27dd390e0 100644 --- a/react-native/src/scenes/Tenants/createOrEditTenant.tsx +++ b/react-native/src/scenes/Tenants/createOrEditTenant.tsx @@ -21,7 +21,6 @@ import * as yup from "yup"; import { observer, inject } from "mobx-react"; import TenantStore from "../../stores/tenantStore"; import { _toast } from "../../utils/utils"; -import { values } from "mobx"; export interface Params { id: string; diff --git a/react-native/src/scenes/Tenants/tenants.tsx b/react-native/src/scenes/Tenants/tenants.tsx index b1170242d..db3fe2964 100644 --- a/react-native/src/scenes/Tenants/tenants.tsx +++ b/react-native/src/scenes/Tenants/tenants.tsx @@ -41,15 +41,6 @@ export class Tenants extends React.Component { const { tenants } = this.props.tenantStore!; return ( - {/* */} { closeOnRowOpen closeOnRowBeginSwipe closeOnScroll - keys={Math.random()} data={tenants === undefined ? [] : tenants.items} renderItem={data => ( diff --git a/react-native/src/services/httpService.ts b/react-native/src/services/httpService.ts index a0e63c6e2..df5e3eb43 100644 --- a/react-native/src/services/httpService.ts +++ b/react-native/src/services/httpService.ts @@ -32,7 +32,7 @@ http.interceptors.request.use( // if (!!abp.auth.getToken()) { config.headers.common.Authorization = - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6ImIwZWY5ZjAwLTBkNGYtNDUyNC1iZmMwLTU3NmViNGRlY2JiMSIsImlhdCI6MTU4MjU2NTE2NSwibmJmIjoxNTgyNTY1MTY1LCJleHAiOjE1ODI2NTE1NjUsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.ggpPvsAq9yPH9cwKZVLZwFB6nOkV3c2eNTzVIL0nNH8'; + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6ImIwNjI4OTU2LWJmZTQtNDU4OS05MjY0LWY5OGM1MTQ2ZDc3NSIsImlhdCI6MTU4MjY5NjY4NCwibmJmIjoxNTgyNjk2Njg0LCJleHAiOjE1ODI3ODMwODQsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.2_KN0VYJqmmFjNr8aqnL6_T4SraEQsTnh2Mdp57n5cg'; // } // config.headers.common['.AspNetCore.Culture'] = abp.utils.getCookieValue('Abp.Localization.CultureName'); From 38ab5d95fa26e4d22ad7d8e45d4cd697afd18223 Mon Sep 17 00:00:00 2001 From: "yasir.aktunc" Date: Wed, 26 Feb 2020 23:46:43 +0300 Subject: [PATCH 3/5] Role update added --- react-native/src/scenes/Roles/createOrEditRole.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/react-native/src/scenes/Roles/createOrEditRole.tsx b/react-native/src/scenes/Roles/createOrEditRole.tsx index dedaac96c..45d0867f3 100644 --- a/react-native/src/scenes/Roles/createOrEditRole.tsx +++ b/react-native/src/scenes/Roles/createOrEditRole.tsx @@ -76,9 +76,16 @@ export class CreateOrEditRole extends React.Component { await this.props.roleStore.getAllPermissions(); } } - createOrUpdateRole = value => { - debugger; - this.props.roleStore!.update(); + createOrUpdateRole = async value => { + if (this.isEdit()) { + await this.props.roleStore.update({ + id: parseInt(this.props.navigation.getParam('id')), + ...value, + }); + } else { + await this.props.roleStore.create(value); + } + // if (this.isEdit()) { // this.propss // .tenantStore!.update({ From 0a5ec1a2550aab151e99d9de01838ef89e4219e1 Mon Sep 17 00:00:00 2001 From: "yasir.aktunc" Date: Wed, 4 Mar 2020 15:33:30 +0300 Subject: [PATCH 4/5] User and Role is done --- .../src/components/routing/routingConfig.tsx | 10 +- react-native/src/models/Users/UserModel.ts | 10 + .../src/scenes/Roles/createOrEditRole.tsx | 64 +-- react-native/src/scenes/Setting/setting.tsx | 60 +-- .../src/scenes/Tenants/createOrEditTenant.tsx | 3 + .../src/scenes/Users/createOrEditUser.tsx | 369 ++++++++++++++++++ react-native/src/scenes/Users/users.tsx | 2 +- react-native/src/services/httpService.ts | 2 +- .../services/user/dto/changePasswordInput.ts | 4 + react-native/src/services/user/userService.ts | 17 +- react-native/src/stores/accountStore.ts | 10 +- react-native/src/stores/userStore.ts | 12 +- 12 files changed, 494 insertions(+), 69 deletions(-) create mode 100644 react-native/src/models/Users/UserModel.ts create mode 100644 react-native/src/scenes/Users/createOrEditUser.tsx create mode 100644 react-native/src/services/user/dto/changePasswordInput.ts diff --git a/react-native/src/components/routing/routingConfig.tsx b/react-native/src/components/routing/routingConfig.tsx index 15215745c..48e42d57f 100644 --- a/react-native/src/components/routing/routingConfig.tsx +++ b/react-native/src/components/routing/routingConfig.tsx @@ -14,6 +14,7 @@ import { httpServiceFunc } from '../../services/httpService'; import { Root, Button, Icon } from 'native-base'; import { CreateOrEditTenant } from '../../scenes/Tenants/createOrEditTenant'; import { CreateOrEditRole } from '../../scenes/Roles/createOrEditRole'; +import CreateOrEdituser from '../../scenes/Users/createOrEditUser'; const AuthStack2 = createStackNavigator( { @@ -38,9 +39,12 @@ const AuthStack2 = createStackNavigator( CreateOrEditRoles: { screen: CreateOrEditRole, }, + CreateOrEditUser: { + screen: CreateOrEdituser, + }, }, { - initialRouteName: 'Roles', + initialRouteName: 'Users', defaultNavigationOptions: ({ navigation }) => ({ headerLeft: ( diff --git a/react-native/src/scenes/Users/createOrEditUser.tsx b/react-native/src/scenes/Users/createOrEditUser.tsx new file mode 100644 index 000000000..9dbeb41ee --- /dev/null +++ b/react-native/src/scenes/Users/createOrEditUser.tsx @@ -0,0 +1,369 @@ +import React from "react"; +import { NavigationScreenProp, NavigationRoute } from "react-navigation"; +import { + Container, + Card, + CardItem, + Body, + Content, + Button, + Item, + Input, + Icon, + Label, + Text, + View, +} from "native-base"; +import { StyleSheet, Switch, Dimensions, Keyboard } from "react-native"; +import Stores from "../../stores/storeIdentifier"; +import { Formik } from "formik"; +import * as yup from "yup"; +import { observer, inject } from "mobx-react"; +import { _toast } from "../../utils/utils"; +import UserStore from "../../stores/userStore"; +import { GetRoles } from "../../services/user/dto/getRolesOuput"; + +export interface Params { + id: string; +} + +export interface Props { + userStore?: UserStore; + navigation: NavigationScreenProp, Params>; +} + +interface RoleSwitch { + name: string; + displayName: string; + value: boolean; +} + +export interface State {} + +@inject(Stores.UserStore) +@observer +export class CreateOrEdituser extends React.Component { + name: any; + surname: any; + emailAdress: any; + password: any; + confirmPassword: any; + constructor(props) { + super(props); + } + + static navigationOptions = ({ + navigation, + }: { + navigation: NavigationScreenProp, Params>; + }) => { + return { + title: ( + {navigation.getParam("id") == "" ? "Create" : "Edit"} + ), + headerLeft: ( + + ), + // headerRight: {navigation.getParam('id')}, + }; + }; + + isEdit = (): boolean => { + return this.props.navigation.getParam("id") !== ""; + }; + + async componentWillMount() { + if (this.isEdit()) { + await this.props.userStore.get({ id: parseInt(this.props.navigation.getParam('id')) }); + await this.props.userStore.getRoles(); + } else { + await this.props.userStore.createUser(); + await this.props.userStore.getRoles(); + } + } + + createOrUpdateTenant = async values => { + values.roleNames = values.roleNames + .filter((x: RoleSwitch) => x.value === true) + .map((x: RoleSwitch) => x.name); + if (this.isEdit()) { + await this.props.userStore + .update({ id: this.props.navigation.getParam("id"), ...values }) + .then(() => _toast('Tenant Oluşturuldu', 'success')); + } + }; + + render() { + const { editUser, roles } = this.props.userStore!; + const grantedPermissions = roles.map((x: GetRoles) => { + if (editUser.roleNames.indexOf(x.normalizedName) !== -1) { + return { value: true, name: x.name, displayName: x.displayName }; + } else { + return { value: false, name: x.name, displayName: x.displayName }; + } + }); + return ( + + + + + + this.createOrUpdateTenant(value)} + > + {({ handleChange, values, handleSubmit, errors, handleBlur, setFieldValue }) => ( + <> + + + this.name._root.focus()} + value={values.userName} + onChangeText={handleChange("userName")} + /> + {errors.name ? ( + + ) : ( + + )} + + + + { + this.name = ref; + }} + onSubmitEditing={() => this.surname._root.focus()} + value={values.name} + onChangeText={handleChange("name")} + /> + {errors.name ? ( + + ) : ( + + )} + + + + { + this.emailAdress._root.focus(); + }} + onBlur={handleBlur} + getRef={(ref: any) => { + this.surname = ref; + }} + returnKeyType="next" + value={values.surname} + onChangeText={handleChange("surname")} + /> + {errors.surname ? ( + + ) : ( + + )} + + + + { + if (this.isEdit()) { + Keyboard.dismiss(); + } else { + this.password._root.focus(); + } + }} + keyboardType="email-address" + onBlur={handleBlur} + getRef={(ref: any) => { + this.emailAdress = ref; + }} + returnKeyType={this.isEdit() ? 'done' : 'next'} + value={values.emailAdress} + onChangeText={handleChange("emailAdress")} + /> + {errors.emailAdress ? ( + + ) : ( + + )} + + {!this.isEdit() && ( + + + { + this.password = ref; + }} + returnKeyType="next" + onSubmitEditing={() => this.confirmPassword._root.focus()} + onBlur={handleBlur} + value={values.password} + onChangeText={handleChange("password")} + /> + {errors.password ? ( + + ) : ( + + )} + + )} + {!this.isEdit() && ( + + + { + this.confirmPassword = ref; + }} + returnKeyType="done" + onSubmitEditing={() => Keyboard.dismiss()} + onBlur={handleBlur} + value={values.confirmPassword} + onChangeText={handleChange("confirmPassword")} + /> + {errors.confirmPassword ? ( + + ) : ( + + )} + + )} + + setFieldValue("isActive", value)} + /> + + + + + + + {values.roleNames.map((x: RoleSwitch, index) => { + return ( + + + setFieldValue(`roleNames[${index}]`, { + ...x, + value: value, + }) + } + /> + + + ); + })} + + + + )} + + + + + + + ); + } +} + +const styles = StyleSheet.create({ + marginVrtcl: { + marginVertical: 5, + }, +}); +export default CreateOrEdituser; diff --git a/react-native/src/scenes/Users/users.tsx b/react-native/src/scenes/Users/users.tsx index c573dda98..44bb77ff0 100644 --- a/react-native/src/scenes/Users/users.tsx +++ b/react-native/src/scenes/Users/users.tsx @@ -90,7 +90,7 @@ class Users extends Component { position="bottomRight" onPress={() => this.props.navigation.navigate('CreateOrEditUser', { - id: "1", + id: "", }) } > diff --git a/react-native/src/services/httpService.ts b/react-native/src/services/httpService.ts index df5e3eb43..9a90a8d90 100644 --- a/react-native/src/services/httpService.ts +++ b/react-native/src/services/httpService.ts @@ -32,7 +32,7 @@ http.interceptors.request.use( // if (!!abp.auth.getToken()) { config.headers.common.Authorization = - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluIiwic3ViIjoiMSIsImp0aSI6ImIwNjI4OTU2LWJmZTQtNDU4OS05MjY0LWY5OGM1MTQ2ZDc3NSIsImlhdCI6MTU4MjY5NjY4NCwibmJmIjoxNTgyNjk2Njg0LCJleHAiOjE1ODI3ODMwODQsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.2_KN0VYJqmmFjNr8aqnL6_T4SraEQsTnh2Mdp57n5cg'; + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6WyJBZG1pbiIsInN0cmluZyIsImFzZGEiXSwic3ViIjoiMSIsImp0aSI6IjFhZDE0Yjc0LTcxNTgtNGY1Mi04YzdkLWRlNmIwNmMxMTczYyIsImlhdCI6MTU4MzMwMTgxMywibmJmIjoxNTgzMzAxODEzLCJleHAiOjE1ODMzODgyMTMsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.S0uFe-G6iXNrwRWUseabalJ4yZCBxroM5RpwXU-jFxM'; // } // config.headers.common['.AspNetCore.Culture'] = abp.utils.getCookieValue('Abp.Localization.CultureName'); diff --git a/react-native/src/services/user/dto/changePasswordInput.ts b/react-native/src/services/user/dto/changePasswordInput.ts new file mode 100644 index 000000000..3abc2c53d --- /dev/null +++ b/react-native/src/services/user/dto/changePasswordInput.ts @@ -0,0 +1,4 @@ +export interface ChangePasswordInput { + currentPassword: string; + newPassword: string; +} diff --git a/react-native/src/services/user/userService.ts b/react-native/src/services/user/userService.ts index 89838a1d3..e2007006d 100644 --- a/react-native/src/services/user/userService.ts +++ b/react-native/src/services/user/userService.ts @@ -6,6 +6,7 @@ import { PagedResultDto } from '../../services/dto/pagedResultDto'; import { PagedUserResultRequestDto } from "./dto/PagedUserResultRequestDto"; import { UpdateUserInput } from './dto/updateUserInput'; import http from '../httpService'; +import { ChangePasswordInput } from './dto/changePasswordInput'; class UserService { public async create(createUserInput: CreateOrUpdateUserInput) { @@ -33,13 +34,25 @@ class UserService { return result.data; } + public async changePassword(changePassword: ChangePasswordInput) { + let result = await http.post( + 'api/services/app/User/ChangeLanguage/ChangePassword', + changePassword, + ); + return result.data; + } + public async get(entityDto: EntityDto): Promise { let result = await http.get('api/services/app/User/Get', { params: entityDto }); return result.data.result; } - public async getAll(pagedFilterAndSortedRequest: PagedUserResultRequestDto): Promise> { - let result = await http.get('api/services/app/User/GetAll', { params: pagedFilterAndSortedRequest }); + public async getAll( + pagedFilterAndSortedRequest: PagedUserResultRequestDto, + ): Promise> { + let result = await http.get('api/services/app/User/GetAll', { + params: pagedFilterAndSortedRequest, + }); return result.data.result; } } diff --git a/react-native/src/stores/accountStore.ts b/react-native/src/stores/accountStore.ts index 3e62f9a3e..5efe8f7ab 100644 --- a/react-native/src/stores/accountStore.ts +++ b/react-native/src/stores/accountStore.ts @@ -4,12 +4,12 @@ import IsTenantAvaibleOutput from '../services/account/dto/isTenantAvailableOutp import accountService from '../services/account/accountService'; class AccountStore { - @observable tenant: IsTenantAvaibleOutput = new IsTenantAvaibleOutput() + @observable tenant: IsTenantAvaibleOutput = new IsTenantAvaibleOutput(); - @action - public isTenantAvailable = async (tenancyName: string) => { - this.tenant = await accountService.isTenantAvailable({ tenancyName: tenancyName }); - } + @action + public isTenantAvailable = async (tenancyName: string) => { + this.tenant = await accountService.isTenantAvailable({ tenancyName: tenancyName }); + }; } export default AccountStore; diff --git a/react-native/src/stores/userStore.ts b/react-native/src/stores/userStore.ts index 51261a9e7..353842e35 100644 --- a/react-native/src/stores/userStore.ts +++ b/react-native/src/stores/userStore.ts @@ -8,10 +8,13 @@ import { PagedResultDto } from '../services/dto/pagedResultDto'; import { PagedUserResultRequestDto } from '../services/user/dto/PagedUserResultRequestDto'; import { UpdateUserInput } from '../services/user/dto/updateUserInput'; import userService from '../services/user/userService'; +import { UserModel } from '../models/Users/UserModel'; +import { ChangePassword } from '../services/user/dto/changePassword'; +import { ChangePasswordInput } from '../services/user/dto/changePasswordInput'; class UserStore { @observable users: PagedResultDto; - @observable editUser!: CreateOrUpdateUserInput; + @observable editUser: UserModel = new UserModel(); @observable roles: GetRoles[] = []; @action @@ -22,6 +25,7 @@ class UserStore { @action async update(updateUserInput: UpdateUserInput) { + debugger; let result = await userService.update(updateUserInput); this.users.items = this.users.items.map((x: GetUserOutput) => { if (x.id === updateUserInput.id) { @@ -56,7 +60,7 @@ class UserStore { name: '', surname: '', emailAddress: '', - isActive: false, + isActive: true, roleNames: [], password: '', id: 0, @@ -73,6 +77,10 @@ class UserStore { async changeLanguage(languageName: string) { await userService.changeLanguage({ languageName: languageName }); } + + async changePassword(changePassword: ChangePasswordInput) { + await userService.changePassword(changePassword); + } } export default UserStore; From af19f7a069435ad17cfa4350298296a2792999a0 Mon Sep 17 00:00:00 2001 From: "yasir.aktunc" Date: Sun, 22 Mar 2020 19:55:27 +0300 Subject: [PATCH 5/5] Pages is done,Added pagination --- react-native/src/App.tsx | 24 +- .../src/components/routing/routingConfig.tsx | 2 +- react-native/src/lib/abp.d.ts | 423 ++++++++ react-native/src/lib/abp.js | 935 ++++++++++++++++++ react-native/src/lib/abpUtility.ts | 12 + react-native/src/lib/appconst.ts | 14 + .../src/lib/signalRAspNetCoreHelper.ts | 22 + react-native/src/scenes/Login/login.tsx | 129 ++- .../src/scenes/Roles/createOrEditRole.tsx | 91 +- react-native/src/scenes/Roles/roles.tsx | 102 +- react-native/src/scenes/Setting/setting.tsx | 1 - .../src/scenes/Tenants/createOrEditTenant.tsx | 28 +- react-native/src/scenes/Tenants/tenants.tsx | 110 ++- .../src/scenes/Users/createOrEditUser.tsx | 62 +- react-native/src/scenes/Users/users.tsx | 113 ++- react-native/src/services/httpService.ts | 2 +- react-native/src/stores/roleStore.ts | 9 +- react-native/src/stores/tenantStore.ts | 17 +- react-native/src/stores/userStore.ts | 8 +- 19 files changed, 1885 insertions(+), 219 deletions(-) create mode 100644 react-native/src/lib/abp.d.ts create mode 100644 react-native/src/lib/abp.js create mode 100644 react-native/src/lib/abpUtility.ts create mode 100644 react-native/src/lib/appconst.ts create mode 100644 react-native/src/lib/signalRAspNetCoreHelper.ts diff --git a/react-native/src/App.tsx b/react-native/src/App.tsx index 169e7c12b..2f06f5525 100644 --- a/react-native/src/App.tsx +++ b/react-native/src/App.tsx @@ -13,39 +13,23 @@ import { Provider } from 'mobx-react'; import initializeStores from './stores/storeInitializer'; import RoutingContainer from './components/routing/routingConfig'; - - - const stores = initializeStores(); console.disableYellowBox = true; -interface Props { - -} +interface Props {} interface State { - appState:any + appState: any; } -export default class App extends React.Component { +export default class App extends React.Component { constructor(props) { super(props); } - render() { - return ( - + ); } } - - - - - - - - - diff --git a/react-native/src/components/routing/routingConfig.tsx b/react-native/src/components/routing/routingConfig.tsx index 48e42d57f..5eb89b6d2 100644 --- a/react-native/src/components/routing/routingConfig.tsx +++ b/react-native/src/components/routing/routingConfig.tsx @@ -44,7 +44,7 @@ const AuthStack2 = createStackNavigator( }, }, { - initialRouteName: 'Users', + initialRouteName: 'Roles', defaultNavigationOptions: ({ navigation }) => ({ headerLeft: ( - - )} - - {}} style={styles.textButton}> - Forget Password + + + + + + + Geçerli müşteri: + {this.state.tenancyName} + this.toggleTenantModal()}> + (Değiştir) - + + this.login({ + userNameOrEmailAddress: value.email, + password: value.password, + rememberMe: true, + }) + } + > + {({ handleChange, values, handleSubmit, errors, handleBlur }) => ( + <> + this.password.focus()} + onBlur={handleBlur} + returnKeyType="next" + keyboardType="email-address" + value={values.email} + onChangeText={handleChange('email')} + /> + {errors.email && {errors.email}} + { + this.password = ref; + }} + placeholder="Password" + onSubmitEditing={() => handleSubmit()} + secureTextEntry={true} + keyboardType="default" + value={values.password} + onChangeText={handleChange('password')} + /> + {errors.password && {errors.password}} + + + )} + + {}} style={styles.textButton}> + Forget Password + + this.isTenanAvaible(tenantName)} toggleModal={() => this.toggleTenantModal()} /> - + ); } } diff --git a/react-native/src/scenes/Roles/createOrEditRole.tsx b/react-native/src/scenes/Roles/createOrEditRole.tsx index 457013eab..96a4043af 100644 --- a/react-native/src/scenes/Roles/createOrEditRole.tsx +++ b/react-native/src/scenes/Roles/createOrEditRole.tsx @@ -83,20 +83,22 @@ export class CreateOrEditRole extends React.Component { } } createOrUpdateRole = async values => { - values.roleNames = values.roleNames + const roleName = values.grantedPermissions .filter((x: RoleSwitch) => x.value === true) .map((x: RoleSwitch) => x.name); - debugger; - // if (this.isEdit()) { - // await this.props.roleStore - // .update({ - // id: parseInt(this.props.navigation.getParam('id')), - // ...value, - // }) - // .then(() => _toast('Update başarılı', 'success')); - // } else { - // await this.props.roleStore.create(value).then(() => _toast('Role Oluşturuldu', 'success')); - // } + if (this.isEdit()) { + await this.props.roleStore + .update({ + id: parseInt(this.props.navigation.getParam('id')), + ...values, + grantedPermissions: roleName, + }) + .then(() => _toast('Update başarılı', 'success')); + } else { + await this.props.roleStore + .create({ ...values, grantedPermissions: roleName }) + .then(() => _toast('Role Oluşturuldu', 'success')); + } }; render() { @@ -109,7 +111,6 @@ export class CreateOrEditRole extends React.Component { return { value: false, name: x.name, displayName: x.displayName }; } }); - return ( @@ -136,10 +137,19 @@ export class CreateOrEditRole extends React.Component { }), ), })} + validateOnBlur={true} validateOnChange={true} onSubmit={value => this.createOrUpdateRole(value)} > - {({ handleChange, values, handleSubmit, errors, handleBlur, setFieldValue }) => ( + {({ + handleChange, + values, + handleSubmit, + errors, + handleBlur, + setFieldValue, + isValid, + }) => ( <> { )} - { flex: 1, }} > - {grantedPermissions.map((x: RoleSwitch, index) => { - return ( - - - setFieldValue(`grantedPermissions[${index}]`, { - ...x, - value: value, - }) - } - /> - - - ); - })} + {values.grantedPermissions.map((x: RoleSwitch, index) => ( + + + setFieldValue(`grantedPermissions[${index}]`, { + ...x, + value: value, + }) + } + /> + + + ))} - )} diff --git a/react-native/src/scenes/Roles/roles.tsx b/react-native/src/scenes/Roles/roles.tsx index 7f5b2ef55..82e344a16 100644 --- a/react-native/src/scenes/Roles/roles.tsx +++ b/react-native/src/scenes/Roles/roles.tsx @@ -1,5 +1,17 @@ import React from "react"; -import { View, Fab, Icon, Container, Button, Text, ActionSheet } from "native-base"; +import { + View, + Fab, + Icon, + Container, + Button, + Text, + ActionSheet, + Header, + Item, + Input, + Right, +} from "native-base"; import { NavigationStackProp } from "react-navigation-stack"; import RoleStore from "../../stores/roleStore"; import { StyleSheet, RefreshControl } from "react-native"; @@ -11,9 +23,16 @@ export interface Props { navigation: NavigationStackProp; roleStore: RoleStore; } +import { NavigationScreenProp, NavigationRoute } from "react-navigation"; export interface State { reflesing: boolean; + maxResultCount: number; + skipCount: number; + keyword: string; +} +export interface Params { + count: string; } @inject(Stores.RoleStore) @@ -21,10 +40,34 @@ export interface State { export class Roles extends React.Component { constructor(props) { super(props); - this.state = { reflesing: false }; + this.state = { reflesing: false, maxResultCount: 10, skipCount: 0, keyword: '' }; } + static navigationOptions = ({ + navigation, + }: { + navigation: NavigationScreenProp, Params>; + }) => { + return { + headerRight: ( + {navigation.getParam('count')} + ), + }; + }; async componentWillMount() { - await this.props.roleStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: "" }); + await this.getAll(); + const { roles } = this.props.roleStore!; + this.props.navigation.setParams({ + count: roles === undefined ? 0 : roles.totalCount, + }); + } + + async getAll() { + const { maxResultCount, keyword, skipCount } = this.state; + await this.props.roleStore!.getAll({ + maxResultCount: maxResultCount, + skipCount: skipCount * maxResultCount, + keyword: keyword, + }); } async handleReflesh() { @@ -39,31 +82,58 @@ export class Roles extends React.Component { render() { const { roles } = this.props.roleStore!; + const { maxResultCount, skipCount } = this.state; return ( +
+ + + this.getAll()} + onChange={e => this.setState({ keyword: e.nativeEvent.text, skipCount: 0 })} + /> + + + + +
+ maxResultCount + skipCount * maxResultCount < + (roles === undefined ? 0 : roles.totalCount) && ( + + ) + } + keyExtractor={(x, i) => i.toString()} + onEndReachedThreshold={0} + showsVerticalScrollIndicator={false} refreshControl={ this.handleReflesh()} /> } - closeOnRowPress - closeOnRowOpen - closeOnRowBeginSwipe - closeOnScroll data={roles === undefined ? [] : roles.items} renderItem={data => ( - {data.item.displayName} + {data.item.name} )} renderHiddenItem={data => ( ), - // headerRight: {navigation.getParam('id')}, }; }; @@ -91,7 +90,7 @@ export class CreateOrEditTenant extends React.Component { connectionString: value.databaseConnectionString, adminEmailAddress: value.emailAdress, }) - .then(() => _toast('Tenant Oluşturuldu', 'success')); + .then(() => _toast('Tenant Oluşturuldu', "success")); } }; @@ -125,10 +124,19 @@ export class CreateOrEditTenant extends React.Component { .required(), }), })} + validateOnBlur={true} validateOnChange={true} onSubmit={value => this.createOrUpdateTenant(value)} > - {({ handleChange, values, handleSubmit, errors, handleBlur, setFieldValue }) => ( + {({ + handleChange, + values, + handleSubmit, + errors, + handleBlur, + setFieldValue, + isValid, + }) => ( <> { { if (this.isEdit()) { - this.databaseConnectionString._root.focus(); - } else { handleSubmit(); + } else { + this.databaseConnectionString._root.focus(); } }} onBlur={handleBlur} getRef={(ref: any) => { this.name = ref; }} - returnKeyType={this.isEdit() ? "next" : "done"} + returnKeyType={this.isEdit() ? "done" : "next"} value={values.name} onChangeText={handleChange("name")} /> @@ -241,7 +249,13 @@ export class CreateOrEditTenant extends React.Component { {!this.isEdit() && } - diff --git a/react-native/src/scenes/Tenants/tenants.tsx b/react-native/src/scenes/Tenants/tenants.tsx index db3fe2964..e3cf9d026 100644 --- a/react-native/src/scenes/Tenants/tenants.tsx +++ b/react-native/src/scenes/Tenants/tenants.tsx @@ -1,12 +1,24 @@ import React from "react"; -import { View, Fab, Icon, Container, Button, Text, ActionSheet } from "native-base"; +import { + View, + Fab, + Icon, + Container, + Button, + Text, + ActionSheet, + Header, + Item, + Input, + Right, +} from "native-base"; import { NavigationStackProp } from "react-navigation-stack"; import TenantStore from "../../stores/tenantStore"; import { StyleSheet, RefreshControl } from "react-native"; import { observer, inject } from "mobx-react"; import Stores from "../../stores/storeIdentifier"; import { SwipeListView } from "react-native-swipe-list-view"; - +import { NavigationScreenProp, NavigationRoute } from "react-navigation"; export interface Props { navigation: NavigationStackProp; tenantStore: TenantStore; @@ -14,6 +26,12 @@ export interface Props { export interface State { reflesing: boolean; + maxResultCount: number; + skipCount: number; + keyword: string; +} +export interface Params { + count: string; } @inject(Stores.TenantStore) @@ -21,38 +39,86 @@ export interface State { export class Tenants extends React.Component { constructor(props) { super(props); - this.state = { reflesing: false }; + this.state = { reflesing: false, maxResultCount: 10, skipCount: 0, keyword: '' }; } + static navigationOptions = ({ + navigation, + }: { + navigation: NavigationScreenProp, Params>; + }) => { + return { + headerRight: ( + {navigation.getParam('count')} + ), + }; + }; async componentWillMount() { - await this.props.tenantStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: "" }); + await this.getAll(); + const { tenants } = this.props.tenantStore!; + this.props.navigation.setParams({ + count: tenants === undefined ? 0 : tenants.totalCount, + }); + } + + async getAll() { + const { maxResultCount, keyword, skipCount } = this.state; + await this.props.tenantStore!.getAll({ + maxResultCount: maxResultCount, + skipCount: skipCount * maxResultCount, + keyword: keyword, + }); } async handleReflesh() { - this.setState( - { reflesing: true }, - async () => - await this.props - .tenantStore!.getAll({ maxResultCount: 10, skipCount: 0, keyword: "" }) - .then(() => this.setState({ reflesing: false })), + this.setState({ reflesing: true, skipCount: 0 }, async () => + this.getAll().then(() => this.setState({ reflesing: false })), ); } render() { const { tenants } = this.props.tenantStore!; + const { maxResultCount, skipCount } = this.state; + return ( +
+ + + this.getAll()} + onChange={e => this.setState({ keyword: e.nativeEvent.text, skipCount: 0 })} + /> + + + + +
+ maxResultCount + skipCount * maxResultCount < + (tenants === undefined ? 0 : tenants.totalCount) && ( + + ) + } + keyExtractor={(x, i) => i.toString()} + onEndReachedThreshold={0} + showsVerticalScrollIndicator={false} refreshControl={ this.handleReflesh()} /> } - closeOnRowPress - closeOnRowOpen - closeOnRowBeginSwipe - closeOnScroll data={tenants === undefined ? [] : tenants.items} renderItem={data => ( @@ -63,7 +129,7 @@ export class Tenants extends React.Component { ), - // headerRight: {navigation.getParam('id')}, }; }; @@ -85,13 +84,18 @@ export class CreateOrEdituser extends React.Component { } createOrUpdateTenant = async values => { - values.roleNames = values.roleNames + const roleName = values.roleNames .filter((x: RoleSwitch) => x.value === true) - .map((x: RoleSwitch) => x.name); + .map((x: RoleSwitch) => x.normalizedName); + if (this.isEdit()) { await this.props.userStore - .update({ id: this.props.navigation.getParam("id"), ...values }) - .then(() => _toast('Tenant Oluşturuldu', 'success')); + .update({ id: this.props.navigation.getParam("id"), ...values, roleNames: roleName }) + .then(() => _toast('User Update Edildi', 'success')); + } else { + await this.props + .userStore!.create({ ...values, roleNames: roleName }) + .then(() => _toast('User Oluşturuldu', 'success')); } }; @@ -99,14 +103,14 @@ export class CreateOrEdituser extends React.Component { const { editUser, roles } = this.props.userStore!; const grantedPermissions = roles.map((x: GetRoles) => { if (editUser.roleNames.indexOf(x.normalizedName) !== -1) { - return { value: true, name: x.name, displayName: x.displayName }; + return { value: true, name: x.name, normalizedName: x.normalizedName }; } else { - return { value: false, name: x.name, displayName: x.displayName }; + return { value: false, name: x.name, normalizedName: x.normalizedName }; } }); return ( - + @@ -115,7 +119,7 @@ export class CreateOrEdituser extends React.Component { name: editUser.name, surname: editUser.surname, userName: editUser.userName, - emailAdress: editUser.emailAddress, + emailAddress: editUser.emailAddress, password: editUser.password, confirmPassword: editUser.password, isEdit: this.isEdit(), @@ -127,7 +131,7 @@ export class CreateOrEdituser extends React.Component { name: yup.string().required(), surname: yup.string().required(), userName: yup.string().required(), - emailAdress: yup + emailAddress: yup .string() .email() .required(), @@ -153,9 +157,17 @@ export class CreateOrEdituser extends React.Component { ), })} validateOnChange={true} - onSubmit={value => this.createOrUpdateTenant(value)} + onSubmit={this.createOrUpdateTenant} > - {({ handleChange, values, handleSubmit, errors, handleBlur, setFieldValue }) => ( + {({ + handleChange, + values, + handleSubmit, + errors, + handleBlur, + setFieldValue, + isValid, + }) => ( <> { value={values.userName} onChangeText={handleChange("userName")} /> - {errors.name ? ( + {errors.userName ? ( ) : ( @@ -227,8 +239,8 @@ export class CreateOrEdituser extends React.Component { @@ -246,10 +258,10 @@ export class CreateOrEdituser extends React.Component { this.emailAdress = ref; }} returnKeyType={this.isEdit() ? 'done' : 'next'} - value={values.emailAdress} - onChangeText={handleChange("emailAdress")} + value={values.emailAddress} + onChangeText={handleChange("emailAddress")} /> - {errors.emailAdress ? ( + {errors.emailAddress ? ( ) : ( @@ -268,6 +280,7 @@ export class CreateOrEdituser extends React.Component { this.password = ref; }} returnKeyType="next" + secureTextEntry={true} onSubmitEditing={() => this.confirmPassword._root.focus()} onBlur={handleBlur} value={values.password} @@ -293,6 +306,7 @@ export class CreateOrEdituser extends React.Component { this.confirmPassword = ref; }} returnKeyType="done" + secureTextEntry={true} onSubmitEditing={() => Keyboard.dismiss()} onBlur={handleBlur} value={values.confirmPassword} @@ -341,12 +355,18 @@ export class CreateOrEdituser extends React.Component { }) } /> - + ); })} - diff --git a/react-native/src/scenes/Users/users.tsx b/react-native/src/scenes/Users/users.tsx index 44bb77ff0..15ef1b103 100644 --- a/react-native/src/scenes/Users/users.tsx +++ b/react-native/src/scenes/Users/users.tsx @@ -1,46 +1,123 @@ import React, { Component } from 'react'; import { SwipeListView } from 'react-native-swipe-list-view'; -import { View, Text, Icon, Button, Container, Fab, ActionSheet } from 'native-base'; -import { StyleSheet } from 'react-native'; +import { + View, + Text, + Icon, + Button, + Container, + Fab, + ActionSheet, + Header, + Item, + Input, + Right, +} from 'native-base'; +import { StyleSheet, RefreshControl, Alert, ActivityIndicator } from 'react-native'; import UserStore from '../../stores/userStore'; import { observer, inject } from 'mobx-react'; import Stores from '../../stores/storeIdentifier'; import { NavigationStackProp } from 'react-navigation-stack'; - +import { NavigationScreenProp, NavigationRoute } from "react-navigation"; interface UsersProps { userStore: UserStore; navigation: NavigationStackProp; } -interface UsersState {} + +export interface UsersState { + reflesing: boolean; + maxResultCount: number; + skipCount: number; + keyword: string; +} +export interface Params { + count: string; +} @inject(Stores.UserStore) @observer class Users extends Component { constructor(props) { super(props); + this.state = { reflesing: false, maxResultCount: 10, skipCount: 0, keyword: '' }; } - // static navigationOptions = ({ navigation, navigationOptions }) => { - // return { - // headerRight: () => ( - // + + + maxResultCount + skipCount * maxResultCount < + (users === undefined ? 0 : users.totalCount) && ( + + ) + } + keyExtractor={(x, i) => i.toString()} + onEndReachedThreshold={0} + showsVerticalScrollIndicator={false} + refreshControl={ + this.handleReflesh()} + /> + } data={users === undefined ? [] : users.items} renderItem={data => ( diff --git a/react-native/src/services/httpService.ts b/react-native/src/services/httpService.ts index 9a90a8d90..bf897d2e7 100644 --- a/react-native/src/services/httpService.ts +++ b/react-native/src/services/httpService.ts @@ -32,7 +32,7 @@ http.interceptors.request.use( // if (!!abp.auth.getToken()) { config.headers.common.Authorization = - 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6ImM1ZTFkMjViLWU1MmItNWQ5Zi1kMDYwLTM5ZjJkZjE2ZmNmZSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6WyJBZG1pbiIsInN0cmluZyIsImFzZGEiXSwic3ViIjoiMSIsImp0aSI6IjFhZDE0Yjc0LTcxNTgtNGY1Mi04YzdkLWRlNmIwNmMxMTczYyIsImlhdCI6MTU4MzMwMTgxMywibmJmIjoxNTgzMzAxODEzLCJleHAiOjE1ODMzODgyMTMsImlzcyI6IlRlbXBsYXRlRGVtbyIsImF1ZCI6IlRlbXBsYXRlRGVtbyJ9.S0uFe-G6iXNrwRWUseabalJ4yZCBxroM5RpwXU-jFxM'; + 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjUiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoic2FtZXQiLCJBc3BOZXQuSWRlbnRpdHkuU2VjdXJpdHlTdGFtcCI6IkZXQzI1Wkc0MlhFUlozSTZZQzcySTNFNjJJUzNIV0pNIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjpbIkFkbWluIiwidGVzYWQiLCJhc2RhcyJdLCJzdWIiOiI1IiwianRpIjoiNGFjNzZkNjEtZTdhZi00YmU4LTlhZjgtMGE1MzEyZjQ1ODk0IiwiaWF0IjoxNTg0ODExNTIyLCJuYmYiOjE1ODQ4MTE1MjIsImV4cCI6MTU4NDg5NzkyMiwiaXNzIjoiVGVtcGxhdGVEZW1vIiwiYXVkIjoiVGVtcGxhdGVEZW1vIn0.gREMGk-ddlo0y0idDnsiYdkn5E2DAMIUPdusv8KrxMI'; // } // config.headers.common['.AspNetCore.Culture'] = abp.utils.getCookieValue('Abp.Localization.CultureName'); diff --git a/react-native/src/stores/roleStore.ts b/react-native/src/stores/roleStore.ts index 3c1940669..f966091e0 100644 --- a/react-native/src/stores/roleStore.ts +++ b/react-native/src/stores/roleStore.ts @@ -79,7 +79,14 @@ class RoleStore { @action async getAll(pagedFilterAndSortedRequest: PagedRoleResultRequestDto) { let result = await roleService.getAll(pagedFilterAndSortedRequest); - this.roles = result; + if (pagedFilterAndSortedRequest.skipCount === 0) { + this.roles = result; + } else { + this.roles = { + items: this.roles.items.concat(result.items), + totalCount: result.totalCount, + }; + } } } diff --git a/react-native/src/stores/tenantStore.ts b/react-native/src/stores/tenantStore.ts index 5361428e9..9663d6a25 100644 --- a/react-native/src/stores/tenantStore.ts +++ b/react-native/src/stores/tenantStore.ts @@ -33,7 +33,9 @@ class TenantStore { let result = await tenantService.update(updateTenantInput); this.tenants.items = this.tenants.items.map((x: GetAllTenantOutput) => { - if (x.id === updateTenantInput.id) x = result; + if (x.id === updateTenantInput.id) { + x = result; + } return x; }); } @@ -41,7 +43,9 @@ class TenantStore { @action async delete(entityDto: EntityDto) { await tenantService.delete(entityDto); - this.tenants.items = this.tenants.items.filter((x: GetAllTenantOutput) => x.id !== entityDto.id); + this.tenants.items = this.tenants.items.filter( + (x: GetAllTenantOutput) => x.id !== entityDto.id, + ); } @action @@ -53,7 +57,14 @@ class TenantStore { @action async getAll(pagedFilterAndSortedRequest: PagedTenantResultRequestDto) { let result = await tenantService.getAll(pagedFilterAndSortedRequest); - this.tenants = result; + if (pagedFilterAndSortedRequest.skipCount === 0) { + this.tenants = result; + } else { + this.tenants = { + items: this.tenants.items.concat(result.items), + totalCount: result.totalCount, + }; + } } } diff --git a/react-native/src/stores/userStore.ts b/react-native/src/stores/userStore.ts index 353842e35..945814859 100644 --- a/react-native/src/stores/userStore.ts +++ b/react-native/src/stores/userStore.ts @@ -9,7 +9,6 @@ import { PagedUserResultRequestDto } from '../services/user/dto/PagedUserResultR import { UpdateUserInput } from '../services/user/dto/updateUserInput'; import userService from '../services/user/userService'; import { UserModel } from '../models/Users/UserModel'; -import { ChangePassword } from '../services/user/dto/changePassword'; import { ChangePasswordInput } from '../services/user/dto/changePasswordInput'; class UserStore { @@ -25,7 +24,6 @@ class UserStore { @action async update(updateUserInput: UpdateUserInput) { - debugger; let result = await userService.update(updateUserInput); this.users.items = this.users.items.map((x: GetUserOutput) => { if (x.id === updateUserInput.id) { @@ -71,7 +69,11 @@ class UserStore { @action async getAll(pagedFilterAndSortedRequest: PagedUserResultRequestDto) { let result = await userService.getAll(pagedFilterAndSortedRequest); - this.users = result; + if (pagedFilterAndSortedRequest.skipCount === 0) { + this.users = result; + } else { + this.users = { items: this.users.items.concat(result.items), totalCount: result.totalCount }; + } } async changeLanguage(languageName: string) {