88 </div >
99 <div v-else >
1010 <b-row >
11- <b-col >
12- <br >
13- <br >
14- <br >
15- <br >
16- <h3 > Mount Target Network Information</h3 >
17- <p >{{netinfo}}</p >
18- </b-col >
1911 <b-col align-self =" center" >
2012 <b-form @submit =" onSubmit" >
2113 <h3 > Create file manager lambda</h3 >
22- <p > Select a mount point to attach to:</p >
23- <b-form-select v-model =" selected" :options =" options" ></b-form-select >
24- <br >
25- <br >
26- <b-button type =" submit" >
14+ <b-form-group
15+ label =" User ID:"
16+ description =" The numeric POSIX user ID that lambda will use to make file system requests as"
17+ >
18+ <b-form-input v-model =" uid" :state =" valid" placeholder =" Enter a custom UID or leave default (1000)" ></b-form-input >
19+ </b-form-group >
20+
21+ <b-form-group
22+ label =" Group ID:"
23+ description =" The numeric POSIX group ID that lambda will use to make file system requests as"
24+ >
25+ <b-form-input v-model =" gid" :state =" valid" placeholder =" Enter a custom GID or leave default (1000)" ></b-form-input >
26+ </b-form-group >
27+
28+ <b-form-group
29+ label =" Path:"
30+ description =" The file system directory that lambda will use as the root directory"
31+ >
32+ <b-form-input v-model =" path" :state =" valid" placeholder =" Enter a custom path or leave default (/efs)" ></b-form-input >
33+ </b-form-group >
34+
35+ <b-form-invalid-feedback :state =" valid" >
36+ UID, GID, and Path must not be empty. The path must begin with a forward slash: /
37+ </b-form-invalid-feedback >
38+ <b-button :disabled =' !valid' type =" submit" >
2739 Submit
2840 <b-icon icon =" Hammer" aria-hidden =" true" ></b-icon >
2941 </b-button >
@@ -45,44 +57,59 @@ export default {
4557 data () {
4658 return {
4759 processing: false ,
48- netinfo: null ,
49- form: {
50- mountTarget: null
51- },
52- selected: null
60+ uid: ' 1000' ,
61+ gid: ' 1000' ,
62+ path: ' /efs'
5363 }
5464 },
55- created : function () {
56- this .getFilesystemNetinfo ()
57- },
5865 computed: {
59- options : function () {
60- let mountTargetNames = Object .keys (this .netinfo )
61- return mountTargetNames
66+ valid () {
67+ return this .uid != " " && this .gid != " " && this .path != " " && this .path .charAt (0 ) == ' /'
6268 }
6369 },
6470 methods: {
65- onSubmit (evt ) {
66- evt .preventDefault ()
67- let mountTarget = this .selected
68- let mountTargetNetinfo = this .netinfo [mountTarget]
69- this .createManagerLambda (mountTargetNetinfo)
71+ async onSubmit (evt ) {
72+ evt .preventDefault ();
73+
74+ if (this .valid ) {
75+ let mountTargetNetinfo = await this .getFilesystemNetinfo ()
76+
77+ mountTargetNetinfo[' uid' ] = this .uid
78+ mountTargetNetinfo[' gid' ] = this .gid
79+ mountTargetNetinfo[' path' ] = this .path
80+
81+ console .log (mountTargetNetinfo)
82+
83+ this .createManagerLambda (mountTargetNetinfo)
84+ }
85+ else {
86+ alert (" Form Validation Error. Check the form input and try again." )
87+ }
7088 },
7189 formatNetinfo (netinfo ) {
72- let tmpNetinfo = {}
90+ let subnets = []
91+ let securityGroups = []
92+
7393 for (var i= 0 , n= netinfo .length ; i < n; ++ i ) {
74- let netinfoKeys = Object .keys (netinfo[i])
75- let mountTargetName = netinfoKeys[0 ]
76- tmpNetinfo[mountTargetName] = netinfo[i][mountTargetName]
77-
94+ if (i === 5 ) { break ; }
95+ let mountTarget = Object .keys (netinfo[i])[0 ]
96+
97+ let subnet = netinfo[i][mountTarget][' subnet_id' ]
98+ let securityGroup = netinfo[i][mountTarget][' security_groups' ]
99+
100+ subnets .push (subnet)
101+ securityGroups .push .apply (securityGroups, securityGroup)
78102 }
103+
104+ let tmpNetinfo = {' subnetIds' : subnets, ' securityGroups' : securityGroups}
105+
79106 return tmpNetinfo
80107 },
81108 async getFilesystemNetinfo () {
82109 try {
83110 let response = await API .get (' fileManagerApi' , ' /api/filesystems/' + this .$route .params .id + ' /netinfo' )
84111 let formattedNetinfo = this .formatNetinfo (response)
85- this . netinfo = formattedNetinfo
112+ return formattedNetinfo
86113 }
87114 catch (error) {
88115 alert (' Unable to retrieve filesystem netinfo, check api logs' )
@@ -91,7 +118,7 @@ export default {
91118 },
92119 async createManagerLambda (netinfo ) {
93120 const params = {
94- body: {" subnetId " : netinfo .subnet_id , " securityGroups" : netinfo .security_groups },
121+ body: {" subnetIds " : netinfo .subnetIds , " securityGroups" : netinfo .securityGroups , " uid " : netinfo . uid , " gid " : netinfo . gid , " path " : netinfo . path },
95122 headers: {" Content-Type" : " application/json" }
96123 }
97124 try {
0 commit comments