123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- <template>
- <div>
- <modal
- class="report-modal"
- title="Report"
- :size="existingReports.length > 0 ? 'wide' : null"
- >
- <template #body>
- <div class="report-modal-inner-container">
- <div id="left-part">
- <song-item
- :song="song"
- :duration="false"
- :disabled-actions="['report']"
- header="Selected Song.."
- />
- <div class="columns is-multiline">
- <div
- v-for="category in predefinedCategories"
- class="column is-half"
- :key="category.category"
- >
- <label class="label">{{
- category.category
- }}</label>
- <p
- v-for="issue in category.issues"
- class="control checkbox-control"
- :key="issue.title"
- >
- <span class="align-horizontally">
- <span>
- <label class="switch">
- <input
- type="checkbox"
- :id="issue.title"
- v-model="issue.enabled"
- />
- <span
- class="slider round"
- ></span>
- </label>
- <label :for="issue.title">
- <span></span>
- <p>{{ issue.title }}</p>
- </label>
- </span>
- <i
- class="material-icons"
- content="Provide More info"
- v-tippy
- @click="
- issue.showDescription =
- !issue.showDescription
- "
- >
- info
- </i>
- </span>
- <input
- type="text"
- class="input"
- v-model="issue.description"
- v-if="issue.showDescription"
- placeholder="Provide more information..."
- @keyup="issue.enabled = true"
- />
- </p>
- </div>
- <!-- allow for multiple custom issues with plus/add button and then a input textbox -->
- <!-- do away with textbox -->
- <div class="column is-half">
- <div id="custom-issues">
- <div id="custom-issues-title">
- <label class="label"
- >Issues not listed</label
- >
- <button
- class="button tab-actionable-button"
- content="Add an issue that isn't listed"
- v-tippy
- @click="customIssues.push('')"
- >
- <i
- class="
- material-icons
- icon-with-button
- "
- >add</i
- >
- <span> Add Custom Issue </span>
- </button>
- </div>
- <div
- class="
- custom-issue
- control
- is-grouped
- input-with-button
- "
- v-for="(issue, index) in customIssues"
- :key="index"
- >
- <p class="control is-expanded">
- <input
- type="text"
- class="input"
- v-model="customIssues[index]"
- placeholder="Provide information..."
- />
- </p>
- <p class="control">
- <button
- class="button is-danger"
- content="Remove custom issue"
- v-tippy
- @click="
- customIssues.splice(
- index,
- 1
- )
- "
- >
- <i class="material-icons">
- delete
- </i>
- </button>
- </p>
- </div>
- <p
- id="no-issues-listed"
- v-if="customIssues.length <= 0"
- >
- <em>
- Add any issues that aren't listed
- above.
- </em>
- </p>
- </div>
- </div>
- </div>
- </div>
- <div id="right-part" v-if="existingReports.length > 0">
- <h4 class="section-title">Previous Reports</h4>
- <p class="section-description">
- You have made
- {{
- existingReports.length > 1
- ? "multiple reports"
- : "a report"
- }}
- about this song already
- </p>
- <hr class="section-horizontal-rule" />
- <div class="report-items">
- <div
- class="report-item"
- v-for="report in existingReports"
- :key="report._id"
- >
- <report-info-item
- :created-at="report.createdAt"
- :created-by="report.createdBy"
- >
- <template #actions>
- <i
- class="material-icons"
- content="View Report"
- v-tippy
- @click="view(report._id)"
- >
- open_in_full
- </i>
- </template>
- </report-info-item>
- </div>
- </div>
- </div>
- </div>
- </template>
- <template #footer>
- <button class="button is-success" @click="create()">
- <i class="material-icons save-changes">done</i>
- <span> Create</span>
- </button>
- <a class="button is-danger" @click="closeModal('report')">
- <span> Cancel</span>
- </a>
- </template>
- </modal>
- <view-report v-if="modals.viewReport" />
- </div>
- </template>
- <script>
- import { mapState, mapGetters, mapActions } from "vuex";
- import Toast from "toasters";
- import ws from "@/ws";
- import ViewReport from "@/components/modals/ViewReport.vue";
- import SongItem from "@/components/SongItem.vue";
- import ReportInfoItem from "@/components/ReportInfoItem.vue";
- import Modal from "../Modal.vue";
- export default {
- components: { Modal, ViewReport, SongItem, ReportInfoItem },
- data() {
- return {
- icons: {
- duration: "timer",
- video: "tv",
- thumbnail: "image",
- artists: "record_voice_over",
- title: "title",
- custom: "lightbulb"
- },
- existingReports: [],
- customIssues: [],
- predefinedCategories: [
- {
- category: "video",
- issues: [
- {
- enabled: false,
- title: "Doesn't exist",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "It's private",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "It's not available in my country",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Unofficial",
- description: "",
- showDescription: false
- }
- ]
- },
- {
- category: "title",
- issues: [
- {
- enabled: false,
- title: "Incorrect",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Inappropriate",
- description: "",
- showDescription: false
- }
- ]
- },
- {
- category: "duration",
- issues: [
- {
- enabled: false,
- title: "Skips too soon",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Skips too late",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Starts too soon",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Starts too late",
- description: "",
- showDescription: false
- }
- ]
- },
- {
- category: "artists",
- issues: [
- {
- enabled: false,
- title: "Incorrect",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Inappropriate",
- description: "",
- showDescription: false
- }
- ]
- },
- {
- category: "thumbnail",
- issues: [
- {
- enabled: false,
- title: "Incorrect",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Inappropriate",
- description: "",
- showDescription: false
- },
- {
- enabled: false,
- title: "Doesn't exist",
- description: "",
- showDescription: false
- }
- ]
- }
- ]
- };
- },
- computed: {
- ...mapState({
- song: state => state.modals.report.song
- }),
- ...mapState("modalVisibility", {
- modals: state => state.modals
- }),
- ...mapGetters({
- socket: "websockets/getSocket"
- })
- },
- mounted() {
- ws.onConnect(this.init);
- this.socket.on(
- "event:admin.report.resolved",
- res => {
- this.existingReports = this.existingReports.filter(
- report => report._id !== res.data.reportId
- );
- },
- { modal: "report" }
- );
- },
- methods: {
- init() {
- this.socket.dispatch(
- "reports.myReportsForSong",
- this.song._id,
- res => {
- if (res.status === "success") {
- this.existingReports = res.data.reports;
- this.existingReports.forEach(report =>
- this.socket.dispatch(
- "apis.joinRoom",
- `view-report.${report._id}`
- )
- );
- }
- }
- );
- },
- view(reportId) {
- this.viewReport(reportId);
- this.openModal("viewReport");
- },
- create() {
- const issues = [];
- // any predefined issues that are enabled
- this.predefinedCategories.forEach(category =>
- category.issues.forEach(issue => {
- if (issue.enabled)
- issues.push({
- category: category.category,
- title: issue.title,
- description: issue.description
- });
- })
- );
- // any custom issues
- this.customIssues.forEach(issue =>
- issues.push({ category: "custom", title: issue })
- );
- if (issues.length === 0)
- return new Toast("Reports must have at least one issue");
- return this.socket.dispatch(
- "reports.create",
- {
- issues,
- youtubeId: this.song.youtubeId
- },
- res => {
- new Toast(res.message);
- if (res.status === "success") this.closeModal("report");
- }
- );
- },
- ...mapActions("modalVisibility", ["openModal", "closeModal"]),
- ...mapActions("modals/viewReport", ["viewReport"])
- }
- };
- </script>
- <style lang="less">
- .report-modal .song-item .thumbnail {
- min-width: 130px;
- width: 130px;
- height: 130px;
- }
- </style>
- <style lang="less" scoped>
- .night-mode {
- @media screen and (max-width: 900px) {
- #right-part {
- background-color: var(--dark-grey-3) !important;
- }
- }
- .columns {
- background-color: var(--dark-grey-3) !important;
- border-radius: 5px;
- }
- }
- .report-modal-inner-container {
- display: flex;
- @media screen and (max-width: 900px) {
- flex-wrap: wrap-reverse;
- #left-part {
- width: 100%;
- }
- #right-part {
- border-left: 0 !important;
- margin-left: 0 !important;
- width: 100%;
- min-width: 0 !important;
- margin-bottom: 20px;
- padding: 20px;
- background-color: var(--light-grey);
- border-radius: 5px;
- }
- }
- #right-part {
- border-left: 1px solid var(--light-grey-3);
- padding-left: 20px;
- margin-left: 20px;
- min-width: 325px;
- .report-items {
- max-height: 485px;
- overflow: auto;
- .report-item:not(:first-of-type) {
- margin-top: 10px;
- }
- }
- }
- }
- .label {
- text-transform: capitalize;
- }
- .columns {
- display: flex;
- flex-wrap: wrap;
- margin-left: unset;
- margin-right: unset;
- margin-top: 20px;
- .column {
- flex-basis: 50%;
- @media screen and (max-width: 900px) {
- flex-basis: 100% !important;
- }
- }
- .control {
- display: flex;
- flex-direction: column;
- span.align-horizontally {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: space-between;
- span {
- display: flex;
- }
- }
- i {
- cursor: pointer;
- }
- input[type="text"] {
- height: initial;
- margin: 10px 0;
- }
- }
- }
- #custom-issues {
- height: 100%;
- #custom-issues-title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 15px;
- button {
- padding: 3px 5px;
- height: initial;
- }
- label {
- margin: 0;
- }
- }
- #no-issues-listed {
- display: flex;
- height: calc(100% - 32px - 15px);
- align-items: center;
- justify-content: center;
- }
- .custom-issue {
- flex-direction: row;
- input {
- height: 36px;
- margin: 0;
- }
- }
- }
- </style>
|