forked from apache/airavata-django-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AIRAVATA-3319 Simple user profile editor for editing first name, last…
… name
- Loading branch information
1 parent
eafe669
commit e2d5121
Showing
18 changed files
with
9,026 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ package-lock.json | |
# mkdocs | ||
site/ | ||
.tox/ | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
django_airavata/apps/api/static/django_airavata_api/js/models/User.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import BaseModel from "./BaseModel"; | ||
|
||
const FIELDS = ["id", "username", "first_name", "last_name", "email"]; | ||
|
||
export default class User extends BaseModel { | ||
constructor(data = {}) { | ||
super(FIELDS, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: ["@vue/app"] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "django-airavata-auth-views", | ||
"description": "A Vue.js project", | ||
"version": "1.0.0", | ||
"author": "Apache Airavata <[email protected]>", | ||
"private": true, | ||
"scripts": { | ||
"serve": "vue-cli-service serve", | ||
"build": "vue-cli-service build", | ||
"lint": "vue-cli-service lint", | ||
"format": "prettier --write ." | ||
}, | ||
"dependencies": { | ||
"bootstrap": "^4.0.0-beta.2", | ||
"bootstrap-vue": "2.0.0-rc.26", | ||
"django-airavata-api": "link:../api/", | ||
"django-airavata-common-ui": "link:../../static/common/", | ||
"vue": "^2.5.21" | ||
}, | ||
"devDependencies": { | ||
"@vue/cli-plugin-babel": "^3.1.1", | ||
"@vue/cli-plugin-eslint": "^3.1.1", | ||
"@vue/cli-service": "^3.1.1", | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.8.0", | ||
"eslint-plugin-vue": "^5.0.0-0", | ||
"prettier": "^2.1.2", | ||
"vue-template-compiler": "^2.5.21", | ||
"webpack-bundle-tracker": "^0.4.2-beta" | ||
}, | ||
"eslintConfig": { | ||
"root": true, | ||
"env": { | ||
"node": true | ||
}, | ||
"extends": [ | ||
"plugin:vue/essential", | ||
"eslint:recommended" | ||
], | ||
"rules": {}, | ||
"parserOptions": { | ||
"parser": "babel-eslint" | ||
} | ||
}, | ||
"postcss": { | ||
"plugins": { | ||
"autoprefixer": {} | ||
} | ||
}, | ||
"browserslist": [ | ||
"> 1%", | ||
"last 2 versions", | ||
"not ie <= 8" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
django_airavata/apps/auth/static/django_airavata_auth/js/components/UserProfileEditor.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<b-card> | ||
<b-form-group label="Username"> | ||
<b-form-input disabled :value="user.username" /> | ||
</b-form-group> | ||
<b-form-group label="First Name"> | ||
<b-form-input v-model="user.first_name" /> | ||
</b-form-group> | ||
<b-form-group label="Last Name"> | ||
<b-form-input v-model="user.last_name" /> | ||
</b-form-group> | ||
<b-form-group label="Email"> | ||
<b-form-input disabled :value="user.email" /> | ||
</b-form-group> | ||
<b-button variant="primary" @click="$emit('save', user)">Save</b-button> | ||
<b-button>Cancel</b-button> | ||
</b-card> | ||
</template> | ||
|
||
<script> | ||
import { models } from "django-airavata-api"; | ||
export default { | ||
name: "user-profile-editor", | ||
props: { | ||
value: { | ||
type: models.User, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
user: this.cloneValue(), | ||
}; | ||
}, | ||
methods: { | ||
cloneValue() { | ||
return JSON.parse(JSON.stringify(this.value)); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style></style> |
38 changes: 38 additions & 0 deletions
38
django_airavata/apps/auth/static/django_airavata_auth/js/containers/UserProfileContainer.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<div> | ||
<h1 class="h4 mb-4">User Profile Editor</h1> | ||
<user-profile-editor v-if="user" v-model="user" @save="onSave" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { services } from "django-airavata-api"; | ||
import UserProfileEditor from "../components/UserProfileEditor.vue"; | ||
export default { | ||
components: { UserProfileEditor }, | ||
name: "user-profile-container", | ||
created() { | ||
services.UserService.current().then((user) => { | ||
this.user = user; | ||
}); | ||
}, | ||
data() { | ||
return { | ||
user: null, | ||
}; | ||
}, | ||
methods: { | ||
onSave(value) { | ||
services.UserService.update({ | ||
lookup: value.id, | ||
data: value, | ||
}).then((user) => { | ||
this.user = user; | ||
}); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style></style> |
8 changes: 8 additions & 0 deletions
8
django_airavata/apps/auth/static/django_airavata_auth/js/entry-user-profile.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { components, entry } from "django-airavata-common-ui"; | ||
import UserProfileContainer from "./containers/UserProfileContainer.vue"; | ||
|
||
entry(Vue => { | ||
new Vue({ | ||
render: h => h(components.MainLayout, [h(UserProfileContainer)]) | ||
}).$mount("#user-profile"); | ||
}); |
23 changes: 23 additions & 0 deletions
23
django_airavata/apps/auth/templates/django_airavata_auth/base.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% load static %} | ||
{% load render_bundle from webpack_loader %} | ||
|
||
{% block css %} | ||
{% render_bundle 'chunk-vendors' 'css' 'AUTH' %} | ||
{% comment %}BUT NOTE: if you only have one entry point you won't have a 'chunk-common' bundle so you may need to comment out the next line until you have more than one entry point.{% endcomment %} | ||
{% comment %} {% render_bundle 'chunk-common' 'css' 'MYAPP' %} {% endcomment %} | ||
{% render_bundle bundle_name 'css' 'AUTH' %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div id="{{ bundle_name }}"/> | ||
{% endblock %} | ||
|
||
|
||
{% block scripts %} | ||
{% render_bundle 'chunk-vendors' 'js' 'AUTH' %} | ||
{% comment %}BUT NOTE: if you only have one entry point you won't have a 'chunk-common' bundle so you may need to comment out the next line until you have more than one entry point.{% endcomment %} | ||
{% comment %} {% render_bundle 'chunk-common' 'js' 'MYAPP' %} {% endcomment %} | ||
{% render_bundle bundle_name 'js' 'AUTH' %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const BundleTracker = require("webpack-bundle-tracker"); | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
publicPath: | ||
process.env.NODE_ENV === "development" | ||
? "http://localhost:9000/static/django_airavata_auth/dist/" | ||
: "/static/django_airavata_auth/dist/", | ||
outputDir: "./static/django_airavata_auth/dist", | ||
pages: { | ||
"user-profile": "./static/django_airavata_auth/js/entry-user-profile" | ||
// additional entry points go here ... | ||
}, | ||
css: { | ||
loaderOptions: { | ||
postcss: { | ||
config: { | ||
path: __dirname | ||
} | ||
} | ||
} | ||
}, | ||
configureWebpack: { | ||
plugins: [ | ||
new BundleTracker({ | ||
filename: "webpack-stats.json", | ||
path: "./static/django_airavata_auth/dist/" | ||
}) | ||
], | ||
optimization: { | ||
/* | ||
* Force creating a vendor bundle so we can load the 'app' and 'vendor' | ||
* bundles on development as well as production using django-webpack-loader. | ||
* Otherwise there is no vendor bundle on development and we would need | ||
* some template logic to skip trying to load it. | ||
* See also: https://bitbucket.org/calidae/dejavu/src/d63d10b0030a951c3cafa6b574dad25b3bef3fe9/%7B%7Bcookiecutter.project_slug%7D%7D/frontend/vue.config.js?at=master&fileviewer=file-view-default#vue.config.js-27 | ||
*/ | ||
splitChunks: { | ||
cacheGroups: { | ||
vendors: { | ||
name: "chunk-vendors", | ||
test: /[\\/]node_modules[\\/]/, | ||
priority: -10, | ||
chunks: "initial" | ||
}, | ||
common: { | ||
name: "chunk-common", | ||
minChunks: 2, | ||
priority: -20, | ||
chunks: "initial", | ||
reuseExistingChunk: true | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
chainWebpack: config => { | ||
/* | ||
* Specify the eslint config file otherwise it complains of a missing | ||
* config file for the ../api and ../../static/common packages | ||
* | ||
* See: https://github.com/vuejs/vue-cli/issues/2539#issuecomment-422295246 | ||
*/ | ||
config.module | ||
.rule("eslint") | ||
.use("eslint-loader") | ||
.tap(options => { | ||
options.configFile = path.resolve(__dirname, "package.json"); | ||
return options; | ||
}); | ||
}, | ||
devServer: { | ||
port: 9000, | ||
headers: { | ||
"Access-Control-Allow-Origin": "*" | ||
}, | ||
hot: true, | ||
hotOnly: true | ||
} | ||
}; |
Oops, something went wrong.