Cleaned up dumbyt.ts a bit and fixed add channel
This commit is contained in:
@ -13,25 +13,33 @@
|
||||
<form v-cloak v-if="Expanded">
|
||||
<h2>Add new Channel</h2>
|
||||
<div class="grid-x">
|
||||
<div class="input-group medium-6 cell">
|
||||
<span class="input-group-label">Title</span>
|
||||
<input class="input-group-field" type="text" placeholder="Title" v-model="Title">
|
||||
<div class="medium-7 cell">
|
||||
<p class="input-group">
|
||||
<span class="input-group-label">Title</span>
|
||||
<input class="input-group-field" type="text" placeholder="Youtube Channel Title"
|
||||
v-model="Title" readonly>
|
||||
</p>
|
||||
<p class="input-group">
|
||||
<span class="input-group-label">Channel ID</span>
|
||||
<input class="input-group-field" v-bind:class="{ error: !Valid }" type="text"
|
||||
placeholder="https://www.youtube.com/channel/UCJkMlOu7faDgqh4PfzbpLdg"
|
||||
v-model="Channel_Identification_Box">
|
||||
</p>
|
||||
<p class="input-group">
|
||||
<span class="input-group-label">Description</span>
|
||||
<input class="input-group-field" placeholder="Description"
|
||||
v-model="Description" readonly cols="15" rows="5"
|
||||
type="text">
|
||||
</p>
|
||||
<button type="button"
|
||||
class="button input-group" style="max-height:50px; max-width:100px; float: right;"
|
||||
@click="Submit">Submit</button>
|
||||
</div>
|
||||
<div class="input-group medium-1 cell"></div>
|
||||
<div class="input-group medium-5 cell">
|
||||
<span class="input-group-label">Channel</span>
|
||||
<input class="input-group-field" v-bind:class="{ error: !Valid }" type="text"
|
||||
placeholder="URL" v-model="Channel_Identification_Box">
|
||||
<div class="medium-2 cell"></div>
|
||||
<div class="input-group medium-2 cell">
|
||||
<img :src="Thumbnail"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<span class="input-group-label">Description</span>
|
||||
<input class="input-group-field" type="text" placeholder="Description" v-model="Description">
|
||||
</div>
|
||||
<div class="grid-x">
|
||||
<img class="small-4 cell" :src="Thumbnail" />
|
||||
<div class="small-7"></div>
|
||||
<button type="button" style="max-height:50px" class="button input-group small-1 cell" @click="Submit">Submit</button>
|
||||
<div class="medium-1 cell"></div>
|
||||
</div>
|
||||
</form>
|
||||
</transition>
|
||||
@ -40,9 +48,10 @@
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
import * as Dyt from "../dumbyt";
|
||||
import * as DumbYT from "../dumbyt";
|
||||
import Axios from "axios";
|
||||
import SA2 from "sweetalert2";
|
||||
import * as _ from "lodash";
|
||||
|
||||
// Vue class for keeping state of the videos.
|
||||
export default Vue.extend({
|
||||
@ -63,10 +72,9 @@ export default Vue.extend({
|
||||
this.GetChannelFromYT(newcontents);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
Submit() : void {
|
||||
Dyt.channel_modify(this.ID, Dyt.Modification.Add).then((resp) => {
|
||||
DumbYT.API.channel_modify(this.ID, DumbYT.API.Modification.Add).then((resp) => {
|
||||
if (resp == null)
|
||||
SA2(
|
||||
"Channel Add Success!",
|
||||
@ -91,6 +99,11 @@ export default Vue.extend({
|
||||
this.Channel_Identification_Box = "";
|
||||
},
|
||||
|
||||
// Clear the contents of the add video field.
|
||||
clear() : void {
|
||||
|
||||
},
|
||||
|
||||
GetChannelFromYT(Channel: string) : void {
|
||||
// Say it failed first so if we exit early then correctly marked fail.
|
||||
this.Valid = false;
|
||||
@ -113,9 +126,9 @@ export default Vue.extend({
|
||||
const API_Key = '&key=AIzaSyCuIYkMc5SktlnXRXNaDf2ObX-fQvtWCnQ'
|
||||
const API_Search_ID = '&id=' + this.ID;
|
||||
Axios.get(API + API_Parts + API_Search_ID + API_Key).then((resp) => {
|
||||
this.Description = resp.data.items[0].snippet.description;
|
||||
this.Description = _.truncate(resp.data.items[0].snippet.description, {length: 70});
|
||||
this.Title = resp.data.items[0].snippet.title;
|
||||
this.Thumbnail = resp.data.items[0].snippet.thumbnails.medium.url;
|
||||
this.Thumbnail = resp.data.items[0].snippet.thumbnails.high.url;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
@ -124,3 +137,17 @@ export default Vue.extend({
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.fade-enter-active {
|
||||
transition: opacity 0.75s;
|
||||
}
|
||||
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.25s;
|
||||
}
|
||||
|
||||
.fade-enter, .fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user