Commit 13b34980 authored by Khalid Ali's avatar Khalid Ali
Browse files

Add base axios configuration

parent 79d672e5
......@@ -839,9 +839,9 @@
"dev": true
},
"@types/node": {
"version": "8.10.39",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.39.tgz",
"integrity": "sha1-5+h60ANk3XvEhclAkmNFuOwaJso=",
"version": "11.9.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.0.tgz",
"integrity": "sha512-ry4DOrC+xenhQbzk1iIPzCZGhhPGEFv7ia7Iu6XXSLVluiJIe9FfG7Iu3mObH9mpxEXCWLCMU4JWbCCR9Oy1Zg==",
"dev": true
},
"@types/q": {
......@@ -4143,6 +4143,14 @@
"dev": true,
"requires": {
"@types/node": "^8.0.7"
},
"dependencies": {
"@types/node": {
"version": "8.10.40",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.40.tgz",
"integrity": "sha512-RRSjdwz63kS4u7edIwJUn8NqKLLQ6LyqF/X4+4jp38MBT3Vwetewi2N4dgJEshLbDwNgOJXNYoOwzVZUSSLhkQ==",
"dev": true
}
}
},
"data-urls": {
......@@ -6831,6 +6839,11 @@
"sshpk": "^1.7.0"
}
},
"https": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https/-/https-1.0.0.tgz",
"integrity": "sha1-PDfHrhqO65ZpBKKtHpdaGUt+06Q="
},
"https-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
......
......@@ -31,7 +31,7 @@ export default class App extends Vue {}
color: #2c3e50;
}
#contents {
margin-bottom: 80px;
margin-bottom: 90px;
}
@import '~bootstrap/dist/css/bootstrap.css';
......
import axios from 'axios';
const https = require('https');
export default axios.create({
baseURL: `https://localhost:9090/bs/api/`,
httpsAgent: new https.Agent({
rejectUnauthorized: false
}),
headers: {
'Access-Control-Allow-Origin': 'login.gmu.edu',
},
});
\ No newline at end of file
......@@ -23,7 +23,6 @@
This is a required field and must be have between 9 and 13 numbers.
</b-form-invalid-feedback>
<b-form-text id="inputLiveHelp">
<!-- this is a form text block (formerly known as help block) -->
The ISBN is usually located on the back of the textbook.
</b-form-text>
</b-form-group>
......@@ -35,9 +34,17 @@
type="text"
v-model="form.course"
required
:state="!$v.form.course.$invalid"
aria-describedby="inputLiveHelp2 inputLiveFeedback2"
placeholder="Enter Course Name (MATH 125)"
>
</b-form-input>
<b-form-invalid-feedback id="inputLiveFeedback2">
This is a required field and must be have between 7 and 8 characters.
</b-form-invalid-feedback>
<b-form-text id="inputLiveHelp2">
The course number can be found Patriotweb.
</b-form-text>
</b-form-group>
<b-form-group id="fieldset3" label="Condition:" label-for="condition">
<b-form-select id="condition" :options="condition" required v-model="form.condition">
......@@ -57,9 +64,16 @@
type="number"
v-model="form.price"
required
placeholder="00"
>
</b-form-input>
:state="!$v.form.price.$invalid"
aria-describedby="inputLiveHelp3 inputLiveFeedback3"
placeholder="0"
/>
<b-form-invalid-feedback id="inputLiveFeedback3">
This is a required field and must be greater than 0.
</b-form-invalid-feedback>
<b-form-text id="inputLiveHelp3">
The price should be the amount you intend to sell for.
</b-form-text>
</b-form-group>
<b-form-group id="fieldset6" label="Images:" label-for="photo">
<b-form-file
......@@ -89,42 +103,78 @@
</template>
<script lang="ts">
import axios from 'axios';
import API from '../api';
import { Component, Vue } from 'vue-property-decorator';
import { Validation } from 'vuelidate';
import { required, minLength, maxLength, sameAs, helpers } from 'vuelidate/lib/validators';
import { required, minLength, maxLength, between, numeric, helpers } from 'vuelidate/lib/validators';
@Component({
validations: {
form: {
isbn: {
required,
numeric,
minLength: minLength(9),
maxLength: maxLength(13),
},
course: {
required,
minLength: minLength(7),
maxLength: maxLength(8),
},
price: {
required,
numeric,
between: between(1, 1000),
},
},
},
})
export default class CreateListing extends Vue {
// Private Form Variables
private form: {isbn: string, course: string, condition: object, photo: File[],
accessCode: object, price: number, description: string} = {
isbn: '', course: '', condition: {}, photo: [], accessCode: {}, price: 0, description: '',
private form: {isbn: string, course: string, condition: number, photo: File[],
accessCode: number, price: number, description: string} = {
isbn: '', course: '', condition: 0, photo: [], accessCode: 2, price: 0, description: '',
};
private show: boolean = true;
// List of options
private condition: string[] = ['New', 'Like New',
'Very Good', 'Good', 'Acceptable', 'Unacceptable'];
private accessCode: string[] = ['Not Applicable', 'Access Code Included',
'Access Code NOT Included'];
private condition: {value: number, text: string}[] = [
{value: 5, text: 'New'}, {value: 4, text: 'Like New'},
{value: 3, text: 'Very Good'}, {value: 2, text: 'Good'},
{value: 1, text: 'Acceptable'}, {value: 0, text: 'Unacceptable'}];
private accessCode: {value: number, text: string}[] = [
{value: 2, text: 'Not Applicable'},
{value: 1, text: 'Access Code Included'},
{value: 0, text: 'Access Code NOT Included'},
];
private onSubmit(evt: Event) {
evt.preventDefault();
alert(JSON.stringify(this.form));
const data = new FormData();
data.append('isbn', this.form.isbn);
data.append('course', this.form.course);
data.append('condition', this.form.condition.toString());
data.append('accessCode', this.form.accessCode.toString());
data.append('price', this.form.price.toString());
data.append('description', this.form.description);
for (let i: number = 0; i < this.form.photo.length; i++) {
data.append('photo' + i.toString(), this.form.photo[i]);
}
API.post('listing', {
data: data,
config: {
headers: {
'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': 'login.gmu.edu',
},
}
}).catch(function (response) {
//handle error
console.log(response);
});
}
private onReset(evt: Event) {
......@@ -132,9 +182,9 @@ export default class CreateListing extends Vue {
/* Reset our form values */
this.form.isbn = '';
this.form.course = '';
this.form.condition = {};
this.form.condition = 0;
this.form.photo = [];
this.form.accessCode = {};
this.form.accessCode = 2;
this.form.price = 0;
this.form.description = '';
/* Trick to reset/clear native browser form validation state */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment