-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3662 from fjordllc/main
Release 2021-12-09 08:39:55
- Loading branch information
Showing
55 changed files
with
662 additions
and
3,033 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class API::SubscriptionsController < API::BaseController | ||
def index | ||
@subscriptions = Subscription.new.all | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class API::Users::RecentReportsController < API::BaseController | ||
def index | ||
@user = User.find(params[:user_id]) | ||
@reports = @user.reports.limit(10).order(reported_on: :DESC) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const statusMap = { | ||
trialing: 'is-primary', | ||
active: 'is-success', | ||
canceled: 'is-danger', | ||
past_due: 'is-warning' | ||
} | ||
const statusLabel = { | ||
trialing: 'お試し中', | ||
active: '有効', | ||
canceled: 'キャンセル', | ||
past_due: '期日経過' | ||
} | ||
const selector = '.subscription-status' | ||
const statuses = document.querySelectorAll(selector) | ||
if (statuses) { | ||
let subs = [] | ||
|
||
fetch('/api/subscriptions.json', { | ||
method: 'GET', | ||
headers: { 'X-Requested-With': 'XMLHttpRequest' }, | ||
credentials: 'same-origin', | ||
redirect: 'manual' | ||
}) | ||
.then((response) => { | ||
return response.json() | ||
}) | ||
.then((json) => { | ||
subs = json.subscriptions | ||
|
||
statuses.forEach((status) => { | ||
const subId = status.getAttribute('data-subscription-id') | ||
subs.forEach((sub) => { | ||
if (sub.id === subId) { | ||
const level = statusMap[sub.status] | ||
const label = statusLabel[sub.status] | ||
status.classList.add('a-button') | ||
status.classList.add('is-sm') | ||
status.classList.add(level) | ||
status.innerHTML = label | ||
} | ||
}) | ||
}) | ||
}) | ||
.catch((error) => { | ||
console.warn('Failed to parsing', error) | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Vue from 'vue' | ||
import UserReports from './user-recent-reports.vue' | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const selector = '#js-user-recent-reports' | ||
const reports = document.querySelector(selector) | ||
if (reports) { | ||
const userID = reports.getAttribute('user-id') | ||
new Vue({ | ||
render: (h) => | ||
h(UserReports, { | ||
props: { | ||
userID: userID | ||
} | ||
}) | ||
}).$mount(selector) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template lang="pug"> | ||
.thread-list.a-card | ||
.card-header.is-sm | ||
h2.card-header__title | ||
| 直近の日報 | ||
.thread-list__items.has-no-author-image | ||
report( | ||
v-for='report in reports', | ||
:key='report.id', | ||
:report='report', | ||
:current-user-id='currentUserId' | ||
) | ||
</template> | ||
|
||
<script> | ||
import Report from './report.vue' | ||
export default { | ||
components: { | ||
report: Report | ||
}, | ||
props: { | ||
userID: { type: String, required: true } | ||
}, | ||
data: function () { | ||
return { | ||
reports: null, | ||
currentUserId: null | ||
} | ||
}, | ||
computed: { | ||
reportsAPI() { | ||
return `/api/users/${this.userID}/recent_reports.json` | ||
} | ||
}, | ||
created() { | ||
window.onpopstate = () => { | ||
this.getReports() | ||
} | ||
this.getReports() | ||
}, | ||
methods: { | ||
getReports() { | ||
fetch(this.reportsAPI, { | ||
method: 'GET', | ||
headers: { 'X-Requested-With': 'XMLHttpRequest' }, | ||
credentials: 'same-origin', | ||
redirect: 'manual' | ||
}) | ||
.then((response) => { | ||
return response.json() | ||
}) | ||
.then((json) => { | ||
this.reports = json.reports | ||
this.currentUserId = json.currentUserId | ||
}) | ||
.catch((error) => { | ||
console.warn('Failed to parsing', error) | ||
}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.