Skip to content

Commit

Permalink
search user initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Resul Avan authored and Resul Avan committed Jun 23, 2020
1 parent b33b647 commit 8cc3ea3
Show file tree
Hide file tree
Showing 15 changed files with 291 additions and 34 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ See the [Features](#features) for more functionalities
- [x] lightbox with buefy/bulma
- [x] hover button on profile photo
- [x] square/round background image
- [x] Make a profile public/private for other authenticated users
- [x] custom error page - simple
- [x] global notification
- [x] toaster notification
Expand Down
4 changes: 2 additions & 2 deletions src/components/form/ProfileUpdateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
v-model="updatedUser.username"
:label="$t('common.field.username')"
:placeholder="$t('common.field.usernamePlaceHolder')"
:rules="`required|min:4|username:${updatedUser.id}`"
:rules="`required|min:2|username:${updatedUser.id}`"
vid="username"
label-position="on-border"
class="has-margin-5"
Expand All @@ -42,7 +42,7 @@
v-model="updatedUser.name"
:label="$t('common.field.name')"
:placeholder="$t('common.field.namePlaceHolder')"
rules="required|min:4"
rules="required|min:2"
vid="name"
label-position="on-border"
class="has-margin-5"
Expand Down
6 changes: 3 additions & 3 deletions src/components/form/SocialLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
return ProviderType
}
isProviderExist(providerType: ProviderType) {
return this.providers.find(value => value.providerType === providerType)
}
// isProviderExist(providerType: ProviderType) {
// return this.providers.find(value => value.providerType === providerType)
// }
getLangProviderOption(providerType: ProviderType) {
return getProviderOption(providerType)
Expand Down
11 changes: 11 additions & 0 deletions src/components/navbar/ProfileNavigator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

<hr class="dropdown-divider">

<b-navbar-item tag="router-link" :to="profileSettingsRoute">
<b-icon icon="account-edit" class="has-margin-right-5"/>
<p>{{$t('common.settings')}}</p>
</b-navbar-item>

<hr class="dropdown-divider">

<b-navbar-item @click="logout">
<b-icon icon="logout" class="has-margin-right-5"/>
<p>{{$t('topNavbar.logout')}}</p>
Expand Down Expand Up @@ -54,5 +61,9 @@
return getUserRoute(Routes.PROFILE_DYNAMIC, this.authUser.username)
}
get profileSettingsRoute() {
return getUserRoute(Routes.PROFILE_SETTINGS, this.authUser.username)
}
}
</script>
140 changes: 140 additions & 0 deletions src/components/navbar/SearchBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<template>
<b-field expanded>
<!-- <p class="control">-->
<!-- <b-dropdown>-->
<!-- <button class="button" slot="trigger">-->
<!-- <span>Search</span>-->
<!-- <b-icon icon="menu-down"></b-icon>-->
<!-- </button>-->

<!-- <b-dropdown-item value="open_issues">Search</b-dropdown-item>-->
<!-- <b-dropdown-item value="your_issues">Detail Search</b-dropdown-item>-->
<!-- </b-dropdown>-->
<!-- </p>-->
<b-autocomplete
:data="data"
placeholder="e.g. rslvn"
field="title"
:loading="isFetching"
:check-infinite-scroll="true"
icon="magnify"
@icon-click="searchIconClick"
icon-right="toy-brick-search-outline"
:icon-right-click="clearIconClick"
@typing="getAsyncData"
@select="option => selected = option"
@infinite-scroll="getMoreAsyncData"
rounded
clearable
expanded>

<template slot-scope="props">
<div class="media">
<div class="media-left">
<img width="32" :src="`${props.option.profilePhoto.src}`">
</div>
<div class="media-content">
{{ props.option.name }}
<br>
<!-- <small>-->
<!-- Released at {{ props.option.release_date }},-->
<!-- rated <b>{{ props.option.vote_average }}</b>-->
<!-- </small>-->
</div>
</div>
</template>
<!-- <template slot="empty">-->
<!-- <span>Search anyway</span>-->
<!-- </template>-->
<template slot="footer">
<span v-show="page > totalPages" class="has-text-grey"> Thats it! No more movies found. </span>
</template>
</b-autocomplete>
</b-field>
</template>

<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import _debounce from 'debounce'
import { getUsersByUsernameAndPage } from '~/service/firebase/firestore';
import { SearchData } from '~/types';
import { loadMoreBySearch } from '~/service/rx-service';
@Component({
components: {}
})
export default class SearchBar extends Vue {
data: SearchData[] = []
selected = null
isFetching = false
query = ''
page = 1
totalPages = 1
getAsyncData = _debounce((query: string) => {
console.log('getAsyncData', query)
this.searchByName(query)
}, 500)
getMoreAsyncData = _debounce(() => {
console.log('getMoreAsyncData')
loadMoreBySearch.next()
}, 250)
created() {
this.$subscribeTo(loadMoreBySearch.asObservable(), () => {
console.log('loadMoreBySearch', this.query)
this.getAsyncData(this.query)
})
}
searchByName(newQuery: string) {
console.log('searchByName', newQuery)
// String update
if (this.query !== newQuery) {
this.query = newQuery
this.data = []
this.page = 1
this.totalPages = 1
}
// String cleared
if (!newQuery.length) {
this.data = []
this.page = 1
this.totalPages = 1
console.log('reset all')
return
}
// Reached last page
if (this.page > this.totalPages) {
return
}
this.isFetching = true
getUsersByUsernameAndPage(newQuery, this.page, 5)
.then((pagingResponse) => {
console.log('pagingResponse:', pagingResponse)
pagingResponse.data.forEach((searchData: SearchData) => this.data.push(searchData))
this.page++
this.totalPages = pagingResponse.totalPage
})
.catch((error: Error) => {
throw error
})
.finally(() => {
console.log('DATA', this.data.length)
this.isFetching = false
})
}
searchIconClick() {
alert('You wanna make a search?')
}
clearIconClick() {
alert('Email cleared!')
}
}
</script>
5 changes: 4 additions & 1 deletion src/components/navbar/TopNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

<template slot="end">

<SearchBar v-if="authUser" class="has-margin-top-10"/>

<LanguageSwitcher/>

<ProfileNavigator v-if="authUser" :auth-user="authUser" :logout="logout"/>
Expand Down Expand Up @@ -66,9 +68,10 @@
import LanguageSwitcher from "~/components/navbar/LanguageSwitcher.vue";
import ProfileNavigator from "~/components/navbar/ProfileNavigator.vue";
import Logo from '~/components/navbar/Logo.vue';
import SearchBar from '~/components/navbar/SearchBar.vue';
@Component({
components: { Logo, ProfileNavigator, LanguageSwitcher }
components: { SearchBar, Logo, ProfileNavigator, LanguageSwitcher }
})
export default class TopNavbar extends Vue {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const messages = {
profilePhoto: 'profile photo',
coverPhoto: 'cover photo',
privacy: 'Privacy',
search: 'Search...',
},
cancel: 'Cancel',
save: 'Save',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/tr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const messages = {
profilePhoto: 'Profil fotografi',
coverPhoto: 'Kapak fotografi',
privacy: 'Gizlilik',
search: 'Ara...',
},
cancel: 'Iptal',
save: 'Kaydet',
Expand Down
38 changes: 21 additions & 17 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@
"hooks": {}
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.13.0",
"@fortawesome/fontawesome-free": "^5.13.1",
"@mdi/font": "^5.3.45",
"@nuxt/typescript-runtime": "^0.4.8",
"@nuxt/typescript-runtime": "^0.4.10",
"@nuxtjs/axios": "^5.11.0",
"@nuxtjs/google-analytics": "^2.3.0",
"@nuxtjs/now-builder": "^0.17.2",
"@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.6",
"@types/cropperjs": "^1.3.0",
"@types/debounce": "^1.2.0",
"@types/jwt-decode": "^2.2.1",
"@types/lodash.debounce": "^4.0.6",
"@types/slug": "^0.9.1",
"@types/uuid": "^8.0.0",
"body-parser": "^1.19.0",
Expand All @@ -39,48 +41,50 @@
"cookie-universal-nuxt": "^2.1.4",
"cors": "^2.8.5",
"cropperjs": "^1.5.7",
"debounce": "^1.2.0",
"dotenv": "^8.2.0",
"firebase": "^7.15.0",
"firebase": "^7.15.4",
"firebase-admin": "^8.12.1",
"http-status-codes": "^1.4.0",
"jwt-decode": "^2.2.0",
"moment": "^2.26.0",
"lodash.debounce": "^4.0.8",
"moment": "^2.27.0",
"node-fetch": "^2.6.0",
"nuxt": "^2.12.2",
"nuxt": "^2.13.0",
"nuxt-i18n": "^6.12.2",
"nuxt-property-decorator": "^2.7.2",
"rxjs": "^6.5.5",
"sitemap": "^6.1.5",
"sitemap": "^6.1.6",
"slug": "^3.3.0",
"vee-validate": "^3.3.2",
"vee-validate": "^3.3.5",
"vue-lazyload": "^1.3.3",
"vue-meta": "^2.3.4",
"vue-meta": "^2.4.0",
"vue-rx": "^6.2.0",
"vuex-class": "^0.3.2"
},
"devDependencies": {
"@nuxt/babel-preset-app": "^2.12.2",
"@nuxt/typescript-build": "^1.0.1",
"@nuxt/babel-preset-app": "^2.13.0",
"@nuxt/typescript-build": "^1.0.3",
"@nuxtjs/eslint-config-typescript": "^2.0.0",
"@nuxtjs/eslint-module": "^2.0.0",
"@nuxtjs/stylelint-module": "^4.0.0",
"@types/vfile-message": "^2.0.0",
"@vue/test-utils": "^1.0.3",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"babel-jest": "^26.1.0",
"core-js": "^3.6.5",
"dts-generator": "^3.0.0",
"eslint": "^7.2.0",
"eslint": "^7.3.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-nuxt": ">=1.0.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-prettier": "^3.1.4",
"firebase-tools": "^8.4.3",
"husky": "^4.2.5",
"jest": "^26.0.1",
"lint-staged": "^10.2.9",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"stylelint": "^13.6.0",
"ts-jest": "^26.1.0",
"stylelint": "^13.6.1",
"ts-jest": "^26.1.1",
"vue-jest": "^4.0.0-0"
}
}
Loading

0 comments on commit 8cc3ea3

Please sign in to comment.