2021-10-31 19:47:07 +00:00
|
|
|
import * as signalR from "@microsoft/signalr";
|
2021-11-09 18:17:22 +00:00
|
|
|
import * as Vue from "vue";
|
2021-11-10 01:46:30 +00:00
|
|
|
import { TrackAudioFeatures, CurrentlyPlayingDTO } from "./HubInterfaces";
|
|
|
|
import NowPlayingCard from "./Now/NowPlayingCard";
|
2021-11-11 19:54:28 +00:00
|
|
|
import { AudioFeatureCard, AudioFeatureChartCard, PopularityCard, SpotifyLogoLink } from "./Now/Spotify";
|
2021-11-10 01:46:30 +00:00
|
|
|
import BaseInfoCard from "./Now/BaseInfoCard";
|
2021-10-31 19:47:07 +00:00
|
|
|
|
|
|
|
const connection = new signalR.HubConnectionBuilder()
|
|
|
|
.withUrl("/hub")
|
|
|
|
.build();
|
|
|
|
|
2021-11-09 22:47:49 +00:00
|
|
|
connection.start()
|
|
|
|
.then(val => {
|
|
|
|
connection.invoke("OnConnected");
|
|
|
|
})
|
|
|
|
.catch(err => console.error(err));
|
2021-10-31 19:47:07 +00:00
|
|
|
|
2021-11-10 01:46:30 +00:00
|
|
|
interface InfoCard {
|
|
|
|
html: string
|
|
|
|
}
|
|
|
|
|
2021-11-09 20:58:02 +00:00
|
|
|
interface NowPlaying {
|
2021-11-10 01:46:30 +00:00
|
|
|
currentlyPlaying?: CurrentlyPlayingDTO,
|
|
|
|
trackFeatures?: TrackAudioFeatures,
|
|
|
|
cards: InfoCard[]
|
2021-11-09 20:58:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 18:17:22 +00:00
|
|
|
const app = Vue.createApp({
|
|
|
|
data() {
|
|
|
|
return {
|
2021-11-10 01:46:30 +00:00
|
|
|
currentlyPlaying: undefined,
|
|
|
|
trackFeatures: undefined,
|
|
|
|
cards: []
|
2021-11-09 20:58:02 +00:00
|
|
|
} as NowPlaying
|
2021-11-09 18:17:22 +00:00
|
|
|
},
|
|
|
|
created() {
|
2021-11-09 20:58:02 +00:00
|
|
|
connection.on("OnNewPlaying", (context: CurrentlyPlayingDTO) =>
|
|
|
|
{
|
|
|
|
console.log(context);
|
|
|
|
this.currentlyPlaying = context;
|
2021-11-11 19:54:28 +00:00
|
|
|
this.trackFeatures = null;
|
2021-11-10 01:46:30 +00:00
|
|
|
this.cards = [];
|
|
|
|
|
2021-11-10 23:54:28 +00:00
|
|
|
if(context.track !== null && context.track !== undefined)
|
|
|
|
{
|
|
|
|
connection.invoke("SendAudioFeatures", context.track.id);
|
|
|
|
}
|
2021-11-09 20:58:02 +00:00
|
|
|
});
|
2021-11-10 01:46:30 +00:00
|
|
|
|
2021-11-10 23:54:28 +00:00
|
|
|
connection.on("OnNewAudioFeature", (feature: TrackAudioFeatures) =>
|
|
|
|
{
|
|
|
|
console.log(feature);
|
|
|
|
this.trackFeatures = feature;
|
|
|
|
});
|
2021-11-09 18:17:22 +00:00
|
|
|
}
|
|
|
|
});
|
2021-11-09 20:58:02 +00:00
|
|
|
|
|
|
|
app.component("now-playing-card", NowPlayingCard);
|
2021-11-11 19:54:28 +00:00
|
|
|
app.component("audio-feature-card", AudioFeatureCard);
|
|
|
|
app.component("audio-feature-chart-card", AudioFeatureChartCard);
|
2021-11-10 01:46:30 +00:00
|
|
|
app.component("info-card", BaseInfoCard);
|
|
|
|
app.component("popularity", PopularityCard);
|
|
|
|
app.component("spotify-logo", SpotifyLogoLink);
|
2021-11-09 18:17:22 +00:00
|
|
|
const vm = app.mount('#app');
|