Skip to content

Commit

Permalink
Solo cert page updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcoombs2000 committed Jan 27, 2024
1 parent 58937a1 commit dd9f969
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/helpers/uriHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const vatsimAuthRedirectUrl = `${getAuthEndpoint()}/oauth/authorize?clien
export const discordRedirectUrl = `https://discord.com/api/oauth2/authorize?client_id=546531280842653696&redirect_uri=https%3A%2F%2Fzmaartcc.net%2Fconnect%2Fdiscord&response_type=code&scope=identify`;

function getClientId() {
// const ClientId = 1246;
const ClientId = 1188;
const ClientId = 1246;
// const ClientId = 1188;

return ClientId;

Expand Down
4 changes: 2 additions & 2 deletions src/views/dashboard/training/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="card-content">
<div class="row row_no_margin">
<div class="card-title col s8"><span class="card-title">Training Requests</span></div>
<div class="col s8"><span class="btn button-warning right"><a
<div class="col s8"><span><a
href="https://docs.google.com/document/d/1U717_AoxZC4Z2-la4DcCge7cnuHrrlK_X2Lnsar8msc/edit?pli=1"
target="_blank"
rel="noopener noreferrer">Training Information</a></span></div>
rel="noopener noreferrer" class="btn right">Training Information</a></span></div>
<div class="col s4"><router-link to="/dash/training/new"><span class="btn new_event_button right">Request</span></router-link></div>
</div>
</div>
Expand Down
106 changes: 85 additions & 21 deletions src/views/instructor/solocerts/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="card">
<div class="card-content">
<div class="row row_no_margin">
<div class="card-title col s8"><span class="card-title">Solo Certificates</span></div>
<div class="card-title col s8"><span class="card-title">VATUSA Solo Certificates</span></div>
<div class="col s4"><router-link to="/ins/solo/new"><span class="btn waves-effect waves-light right">New</span></router-link></div>
</div>
<div>
Expand Down Expand Up @@ -46,6 +46,51 @@
</tbody>
</table>
</div>
</div><div class="card">
<div class="card-content">
<div class="row row_no_margin">
<div class="card-title col s8"><span class="card-title">Tower Solo Certificates</span></div>
</div>
<div>
<p class="no_certs" v-if="loading===false && certs.length === 0">There are no solo certificates on record for ZMA</p>
</div>
</div>

<div class="loading_container" v-if="loading">
<Spinner />
</div>

<div class="certs_wrapper">
<table class="certs_list striped compact" >
<thead class="certs_list_head">
<tr>
<th>Controller</th>
<th>Position</th>
<th>Expires</th>
<th class="options">Options</th>
</tr>
</thead>
<tbody class="certs_list_row">
<tr v-for="(user, i) in towercerts">
<td><router-link :to="`/controllers/${user.cid}`" class="controller_link">{{user.fname}} {{user.lname}}</router-link></td>
<td>TWR</td><td>{{user.towersoloExpiration.slice(0,10)}}</td>
<td class="options">
<a :href="`#modal_deletes_${user.cid}`" data-position="top" data-tooltip="Delete Solo Certificate" class="tooltipped modal-trigger"><i class="material-icons red-text text-darken-2">delete</i></a>
</td>
<div :id="`modal_deletes_${user.cid}`" class="modal modal_delete">
<div class="modal-content">
<h4>Delete Solo Certificate?</h4>
<p>This will remove the Solo Certification from ZMA.</p>
</div>
<div class="modal-footer">
<a href="#!" @click="deleteCert(user.id, user.cid, 'TWR')" class="btn waves-effect">Delete</a>
<a href="#!" class="btn-flat waves-effect modal-close">Cancel</a>
</div>
</div>
</tr>
</tbody>
</table>
</div>
</div>
</template>

Expand All @@ -61,13 +106,16 @@ export default {
positions: ['MIA', 'FLL', 'TPA', 'PBI', 'RSW', 'NQX', 'ZMO'],
certs: [],
controllers: null,
loading: true
};
loading: true,
towercerts: []
}
},
async mounted() {
await this.getControllers();
await this.getSoloCerts();
await this.getLocalCerts();
this.loading = false;
M.Tooltip.init(document.querySelectorAll('.tooltipped'), {
Expand All @@ -86,12 +134,11 @@ export default {
// Fetch and decode API data.
// The API returns back base 64 encoded data with authentication blocks. The payload needs to be base64 decoded and then parsd for json.
const {data} = await vatusaApi.get('/solo');
const payload = atob(data.payload);
var data1 = JSON.parse(payload);
for (const cert of data1.data) {
if(this.positions.includes(cert.position.slice(0, 3)))
this.certs.push(cert);
const {data} = await vatusaApi.get('/solo');
for (const cert of data.data) {
if(this.positions.includes(cert.position.slice(0, 3)))
this.certs.push(cert);
}
} catch(e) {
Expand All @@ -106,27 +153,44 @@ export default {
console.log(e);
}
},
async deleteCert(id, cid, position) {
async getLocalCerts() {
try {
const formData = new FormData();
formData.append('id', id);
// form data seems not to be passed when using the DELETE method. This works only when the ID is passed on the URL.
await vatusaApiAuth.delete('/solo?id='+id, {data: formData});
const {data} = await zabApi.get('/training/solo');
for (const user of data.data.users) {
this.towercerts.push(user);
}
this.toastSuccess('Solo Certification deleted');
} catch(e) {
console.log(e);
}
},
async deleteCert(id, cid, position) {
try {
const {data} = await zabApi.post('/training/solodelete/'+cid, {
position: position
});
if (position.slice(-3)==='APP' || position.slice(-3)==='CTR')
{
await vatusaApiAuth.delete('/solo?id='+id, {
id: id
});
}
this.toastSuccess('Solo Certification deleted');
this.certs = [];
await this.getSoloCerts();
await this.getLocalCerts();
this.$router.push('/ins/solo');
this.$router.go();
this.$nextTick(() => {
M.Modal.getInstance(document.querySelector('.modal_delete')).close();
});
});
} catch(e) {
this.toastError(e);
this.toastError(e);
}
},
},
getName(cid2) {
const controller = this.controllers.filter(i => { return i.cid === cid2; });
return controller[0].fname + ' ' + controller[0].lname;
Expand Down
51 changes: 38 additions & 13 deletions src/views/instructor/solocerts/New.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
Please ensure that the student's training records have been entered onto their ZMA and VATUSA
record <b>prior</b> to issuance of any solo certification.
<br><br>
Tier 2 Solo Certifications should be entered as 'TWR', 'APP', or 'CTR'.
<br><br>
Ensure that you enter solo certifications into the appropriate system in accordance with section
<b>8.4 of the Miami ARTCC SOP</b>. The student <i>cannot</i> take advantage of solo certifications that are
not entered correctly.
Expand All @@ -28,9 +30,17 @@
</select>
<label>Controller</label>
</div>
<div class="col s12 input-field">
<input id="position" type="text" minlength=7 maxlength=7 class="validate" placeholder="PHX_APP" v-model="form.position" required>
<label for="position" class="active">Position</label>
<div class="input-field col s12 m6">
<select required v-model="form.position" class="materialize-select">
<option value="" disabled selected>Select an option</option>
<option value='TWR'>TWR</option>
<option value='APP'>APP</option>
<option value='CTR'>CTR</option>
</select>
<label>Position</label>
<!--<div class="col s12 input-field">
<input id="position" type="text" minlength=3 maxlength=3 class="validate" placeholder="TWR" v-model="form.position" required>
<label for="position" class="active">Position</label>-->
</div>
<div class="col s12 input-field">
<input id="expiration_date" type="text" class="datepicker" ref="expirationDate" required>
Expand Down Expand Up @@ -88,18 +98,33 @@ export default {
});
},
async submitCert() {
try {
const formData = new FormData();
formData.append('cid', this.form.cid);
formData.append('position', this.form.position);
formData.append('expDate', this.$refs.expirationDate.value);
await vatusaApiAuth.post('/solo', formData);
console.log(this.form.position);
if (this.form.position === "TWR" || this.form.position === "APP" || this.form.position === "CTR")
{
try {
await zabApi.post('/training/solo/'+this.form.cid,
{
cid: this.form.cid,
position: this.form.position,
expDate: this.$refs.expirationDate.value
});
if (this.form.position.slice(-3)==='APP' || this.form.position.slice(-3)==='CTR')
await vatusaApiAuth.post('/solo',
{
cid: this.form.cid,
position: this.form.position,
expDate: this.$refs.expirationDate.value
});
this.toastSuccess('Solo Certification issued');
this.toastSuccess('Solo Certification issued');
this.$router.push('/ins/solo');
} catch(e) {
this.toastError(e);
this.$router.push('/ins/solo');
this.$router.go();
} catch(e) {
this.toastError(e);
}
}
}
}
Expand Down

0 comments on commit dd9f969

Please sign in to comment.