mirror of
https://github.com/dborth/vbagx.git
synced 2024-11-25 20:16:53 +01:00
Updates & fixes
-Remove bak file -Min refactor -Start to use -test- axios -Mock up user login with state management
This commit is contained in:
parent
e4c300bee4
commit
4b727b21bf
190
README.md.bak
190
README.md.bak
@ -1,190 +0,0 @@
|
||||
# Comida Cab
|
||||
|
||||
## Framework7 CLI Options
|
||||
|
||||
Framework7 app created with following options:
|
||||
|
||||
```
|
||||
{
|
||||
"cwd": "C:\\android\\projects\\comida-cab-f7-v6",
|
||||
"type": [
|
||||
"web",
|
||||
"pwa",
|
||||
"cordova"
|
||||
],
|
||||
"name": "Comida Cab",
|
||||
"framework": "core",
|
||||
"template": "single-view",
|
||||
"bundler": "webpack",
|
||||
"cssPreProcessor": "less",
|
||||
"theming": {
|
||||
"customColor": true,
|
||||
"color": "#44c950",
|
||||
"darkTheme": true,
|
||||
"iconFonts": true,
|
||||
"fillBars": false
|
||||
},
|
||||
"customBuild": true,
|
||||
"customBuildConfig": {
|
||||
"rtl": false,
|
||||
"darkTheme": true,
|
||||
"lightTheme": true,
|
||||
"themes": [
|
||||
"ios",
|
||||
"md",
|
||||
"aurora"
|
||||
],
|
||||
"components": [
|
||||
"appbar",
|
||||
"dialog",
|
||||
"popup",
|
||||
"login-screen",
|
||||
"popover",
|
||||
"actions",
|
||||
"sheet",
|
||||
"toast",
|
||||
"preloader",
|
||||
"progressbar",
|
||||
"sortable",
|
||||
"swipeout",
|
||||
"accordion",
|
||||
"contacts-list",
|
||||
"virtual-list",
|
||||
"list-index",
|
||||
"timeline",
|
||||
"tabs",
|
||||
"panel",
|
||||
"card",
|
||||
"chip",
|
||||
"form",
|
||||
"input",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"toggle",
|
||||
"range",
|
||||
"stepper",
|
||||
"smart-select",
|
||||
"grid",
|
||||
"calendar",
|
||||
"picker",
|
||||
"infinite-scroll",
|
||||
"pull-to-refresh",
|
||||
"lazy",
|
||||
"data-table",
|
||||
"fab",
|
||||
"searchbar",
|
||||
"messages",
|
||||
"messagebar",
|
||||
"swiper",
|
||||
"photo-browser",
|
||||
"notification",
|
||||
"autocomplete",
|
||||
"tooltip",
|
||||
"gauge",
|
||||
"skeleton",
|
||||
"menu",
|
||||
"color-picker",
|
||||
"treeview",
|
||||
"text-editor",
|
||||
"area-chart",
|
||||
"pie-chart",
|
||||
"elevation",
|
||||
"typography"
|
||||
]
|
||||
},
|
||||
"webpack": {
|
||||
"developmentSourceMap": true,
|
||||
"productionSourceMap": true,
|
||||
"hashAssets": false,
|
||||
"preserveAssetsPaths": false,
|
||||
"inlineAssets": true
|
||||
},
|
||||
"pkg": "com.comidacab.app",
|
||||
"cordova": {
|
||||
"folder": "cordova",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android",
|
||||
"electron"
|
||||
],
|
||||
"plugins": [
|
||||
"cordova-plugin-statusbar",
|
||||
"cordova-plugin-keyboard",
|
||||
"cordova-plugin-splashscreen"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## NPM Scripts
|
||||
|
||||
* 🔥 `start` - run development server
|
||||
* 🔧 `dev` - run development server
|
||||
* 🔧 `build` - build web app for production
|
||||
* 📱 `build-cordova` - build cordova app
|
||||
* 📱 `build-cordova-ios` - build cordova iOS app
|
||||
* 📱 `cordova-ios` - run dev build cordova iOS app
|
||||
* 📱 `build-cordova-android` - build cordova Android app
|
||||
* 📱 `cordova-android` - run dev build cordova Android app
|
||||
* 🖥 `build-cordova-electron` - build cordova Electron app
|
||||
* 🖥 `cordova-electron` - launch quick preview (without full build process) of Electron app in development mode
|
||||
|
||||
## WebPack
|
||||
|
||||
There is a webpack bundler setup. It compiles and bundles all "front-end" resources. You should work only with files located in `/src` folder. Webpack config located in `build/webpack.config.js`.
|
||||
|
||||
Webpack has specific way of handling static assets (CSS files, images, audios). You can learn more about correct way of doing things on [official webpack documentation](https://webpack.js.org/guides/asset-management/).
|
||||
## Cordova
|
||||
|
||||
## Cordova Android
|
||||
Cordova Android was installed. To test it, use following command:
|
||||
|
||||
```
|
||||
framework7 cordova run android
|
||||
```
|
||||
|
||||
## PWA
|
||||
|
||||
This is a PWA. Don't forget to check what is inside of your `service-worker.js`. It is also recommended that you disable service worker (or enable "Update on reload") in browser dev tools during development.
|
||||
|
||||
## Cordova
|
||||
|
||||
Cordova project located in `cordova` folder. You shouldn't modify content of `cordova/www` folder. Its content will be correctly generated when you call `npm run cordova-build-prod`.
|
||||
## Cordova Electron
|
||||
|
||||
There is also cordova Electron platform installed. To learn more about it and Electron check this guides:
|
||||
|
||||
* [Cordova Electron Platform Guide](https://cordova.apache.org/docs/en/latest/guide/platforms/electron/index.html)
|
||||
* [Official Electron Documentation](https://electronjs.org/docs)
|
||||
|
||||
## Assets
|
||||
|
||||
Assets (icons, splash screens) source images located in `assets-src` folder. To generate your own icons and splash screen images, you will need to replace all assets in this directory with your own images (pay attention to image size and format), and run the following command in the project directory:
|
||||
|
||||
```
|
||||
framework7 assets
|
||||
```
|
||||
|
||||
Or launch UI where you will be able to change icons and splash screens:
|
||||
|
||||
```
|
||||
framework7 assets --ui
|
||||
```
|
||||
|
||||
## To compile after download from github
|
||||
|
||||
After getting project from github
|
||||
|
||||
## Documentation & Resources
|
||||
|
||||
* [Framework7 Core Documentation](https://framework7.io/docs/)
|
||||
|
||||
|
||||
|
||||
* [Framework7 Icons Reference](https://framework7.io/icons/)
|
||||
* [Community Forum](https://forum.framework7.io)
|
||||
|
||||
## Support Framework7
|
||||
|
||||
Love Framework7? Support project by donating or pledging on patreon:
|
||||
https://patreon.com/vladimirkharlampidi
|
@ -1,13 +1,14 @@
|
||||
import url from './key';
|
||||
import axios from 'axios';
|
||||
|
||||
const HTTP = axios.create({
|
||||
const http = axios.create({
|
||||
baseURL: `${url}`,
|
||||
});
|
||||
|
||||
const token = localStorage.getItem('user-token')
|
||||
const token = localStorage.getItem('token')
|
||||
|
||||
if (token) {
|
||||
HTTP.defaults.headers.common['Authorization'] = token
|
||||
http.defaults.headers.common['Authorization'] = token;
|
||||
}
|
||||
|
||||
export default HTTP;
|
||||
export default http;
|
@ -29,9 +29,9 @@ var app = new Framework7({
|
||||
// path: '/service-worker.js',
|
||||
// },
|
||||
|
||||
/*view: {
|
||||
browserHistory: true,
|
||||
},*/
|
||||
// view: {
|
||||
// browserHistory: true,
|
||||
// },
|
||||
|
||||
// Input settings
|
||||
input: {
|
||||
|
@ -1,10 +1,10 @@
|
||||
import User from './users.js';
|
||||
|
||||
let storage = window.localStorage;
|
||||
//import user from './../stores/user.js';
|
||||
|
||||
let Check = {
|
||||
authorization( { to, resolve } ) {
|
||||
const router = this;
|
||||
//if (user.isLogged.value){
|
||||
if (!User.isLogged()){
|
||||
router.navigate('/login/', { reloadCurrent: true });
|
||||
}
|
||||
@ -14,8 +14,9 @@ let Check = {
|
||||
},
|
||||
permission( { to, resolve, reject } ) {
|
||||
const router = this;
|
||||
const userData = JSON.parse(storage.getItem("userData"));
|
||||
const userData = JSON.parse(localStorage.getItem("userData"));
|
||||
const userRoles = userData['userPermissions'];
|
||||
//const userRoles = localStorage.getItem("roles");
|
||||
|
||||
let currentIndex = -1;
|
||||
for (let i = 0; i < router.routes.length; i++) {
|
||||
|
71
src/js/stores/user.js
Normal file
71
src/js/stores/user.js
Normal file
@ -0,0 +1,71 @@
|
||||
import { createStore } from 'framework7';
|
||||
import http from './../api/config.js';
|
||||
|
||||
const user = createStore({
|
||||
state: {
|
||||
status: '',
|
||||
token: localStorage.getItem('token') || '',
|
||||
user: {},
|
||||
roles: [],
|
||||
},
|
||||
actions: {
|
||||
logIn({ state, dispatch }, data){
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch('auth_request');
|
||||
http.post('/user/login', data)
|
||||
.then(response => {
|
||||
const token = response.data.token;
|
||||
const user = response.data.user;
|
||||
const roles = response.data.roles;
|
||||
localStorage.setItem('token', token);
|
||||
localStorage.setItem('roles', roles);
|
||||
http.defaults.headers.common['Authorization'] = token;
|
||||
dispatch('auth_success', token, user);
|
||||
resolve(response);
|
||||
})
|
||||
.catch(err => {
|
||||
dispatch('auth_error');
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('roles');
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
logOut(){
|
||||
return new Promise((resolve, reject) => {
|
||||
dispatch('logout');
|
||||
localStorage.removeItem('token');
|
||||
localStorage.removeItem('roles');
|
||||
http.defaults.headers.common['Authorization'];
|
||||
resolve();
|
||||
});
|
||||
},
|
||||
//Mutations
|
||||
logout({ state }){
|
||||
state.status = '';
|
||||
state.token = '';
|
||||
},
|
||||
auth_request(state){
|
||||
state.status = 'loading'
|
||||
},
|
||||
auth_success(state, token, user){
|
||||
state.status = 'success'
|
||||
state.token = token
|
||||
state.user = user
|
||||
},
|
||||
auth_error(state){
|
||||
state.status = 'error'
|
||||
},
|
||||
//End mutations
|
||||
},
|
||||
getters: {
|
||||
isLogged({ state }) {
|
||||
return !!state.token;
|
||||
},
|
||||
authStatus({ state }) {
|
||||
return state.status;
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export default user;
|
@ -40,7 +40,7 @@
|
||||
import $ from 'dom7';
|
||||
import User from '../js/controllers/users.js';
|
||||
|
||||
export default (props, { $f7, $on, $update }) => {
|
||||
export default (props, { $f7, $on, $update, $f7router }) => {
|
||||
let version = $f7.version;
|
||||
|
||||
const checkLogin = () => {
|
||||
@ -50,7 +50,7 @@ export default (props, { $f7, $on, $update }) => {
|
||||
User.checkLogin(username, password).then(function(result){
|
||||
$f7.preloader.hide();
|
||||
if (result === true){
|
||||
window.location.replace('/');
|
||||
$f7router.navigate('/');
|
||||
}
|
||||
else{
|
||||
$f7.toast.show( { text: result.message });
|
||||
|
Loading…
Reference in New Issue
Block a user