activity_notification 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/app/jobs/activity_notification/cascading_notification_job.rb +123 -0
- data/docs/Functions.md +197 -1
- data/lib/activity_notification/apis/cascading_notification_api.rb +208 -0
- data/lib/activity_notification/apis/notification_api.rb +3 -0
- data/lib/activity_notification/config.rb +10 -0
- data/lib/activity_notification/mailers/helpers.rb +27 -1
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- metadata +5 -441
- data/.codeclimate.yml +0 -33
- data/.coveralls.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
- data/.github/pull_request_template.md +0 -13
- data/.github/workflows/build.yml +0 -100
- data/.gitignore +0 -74
- data/.rspec +0 -3
- data/.rubocop.yml +0 -1157
- data/.yardopts +0 -6
- data/CHANGELOG.md +0 -452
- data/Gemfile +0 -31
- data/Procfile +0 -2
- data/Rakefile +0 -28
- data/activity_notification.gemspec +0 -44
- data/ai-curated-specs/issues/172/design.md +0 -220
- data/ai-curated-specs/issues/172/tasks.md +0 -326
- data/ai-curated-specs/issues/188/design.md +0 -227
- data/ai-curated-specs/issues/188/requirements.md +0 -78
- data/ai-curated-specs/issues/188/tasks.md +0 -203
- data/ai-curated-specs/issues/188/upstream-contributions.md +0 -592
- data/ai-curated-specs/issues/50/design.md +0 -235
- data/ai-curated-specs/issues/50/requirements.md +0 -49
- data/ai-curated-specs/issues/50/tasks.md +0 -232
- data/bin/_dynamodblocal +0 -4
- data/bin/bundle_update.sh +0 -7
- data/bin/deploy_on_heroku.sh +0 -16
- data/bin/install_dynamodblocal.sh +0 -5
- data/bin/start_dynamodblocal.sh +0 -47
- data/bin/stop_dynamodblocal.sh +0 -34
- data/gemfiles/Gemfile.rails-5.0 +0 -25
- data/gemfiles/Gemfile.rails-5.1 +0 -25
- data/gemfiles/Gemfile.rails-5.2 +0 -24
- data/gemfiles/Gemfile.rails-6.0 +0 -23
- data/gemfiles/Gemfile.rails-6.1 +0 -22
- data/gemfiles/Gemfile.rails-7.0 +0 -25
- data/gemfiles/Gemfile.rails-7.1 +0 -23
- data/gemfiles/Gemfile.rails-7.2 +0 -23
- data/gemfiles/Gemfile.rails-8.0 +0 -24
- data/package.json +0 -8
- data/spec/channels/notification_api_channel_shared_examples.rb +0 -59
- data/spec/channels/notification_api_channel_spec.rb +0 -49
- data/spec/channels/notification_api_with_devise_channel_spec.rb +0 -76
- data/spec/channels/notification_channel_shared_examples.rb +0 -59
- data/spec/channels/notification_channel_spec.rb +0 -48
- data/spec/channels/notification_with_devise_channel_spec.rb +0 -97
- data/spec/concerns/apis/notification_api_spec.rb +0 -1627
- data/spec/concerns/apis/subscription_api_spec.rb +0 -474
- data/spec/concerns/common_spec.rb +0 -213
- data/spec/concerns/models/group_spec.rb +0 -61
- data/spec/concerns/models/notifiable_spec.rb +0 -782
- data/spec/concerns/models/notifier_spec.rb +0 -71
- data/spec/concerns/models/subscriber_spec.rb +0 -800
- data/spec/concerns/models/target_spec.rb +0 -1285
- data/spec/concerns/renderable_spec.rb +0 -129
- data/spec/config_spec.rb +0 -85
- data/spec/controllers/common_controller_spec.rb +0 -25
- data/spec/controllers/controller_spec_utility.rb +0 -100
- data/spec/controllers/dummy_common_controller.rb +0 -5
- data/spec/controllers/notifications_api_controller_shared_examples.rb +0 -619
- data/spec/controllers/notifications_api_controller_spec.rb +0 -19
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +0 -60
- data/spec/controllers/notifications_controller_shared_examples.rb +0 -743
- data/spec/controllers/notifications_controller_spec.rb +0 -11
- data/spec/controllers/notifications_with_devise_controller_spec.rb +0 -97
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +0 -750
- data/spec/controllers/subscriptions_api_controller_spec.rb +0 -19
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +0 -60
- data/spec/controllers/subscriptions_controller_shared_examples.rb +0 -946
- data/spec/controllers/subscriptions_controller_spec.rb +0 -11
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +0 -97
- data/spec/factories/admins.rb +0 -5
- data/spec/factories/articles.rb +0 -5
- data/spec/factories/comments.rb +0 -6
- data/spec/factories/dummy/dummy_group.rb +0 -4
- data/spec/factories/dummy/dummy_notifiable.rb +0 -4
- data/spec/factories/dummy/dummy_notifier.rb +0 -4
- data/spec/factories/dummy/dummy_subscriber.rb +0 -4
- data/spec/factories/dummy/dummy_target.rb +0 -4
- data/spec/factories/notifications.rb +0 -7
- data/spec/factories/subscriptions.rb +0 -8
- data/spec/factories/users.rb +0 -11
- data/spec/generators/controllers_generator_spec.rb +0 -85
- data/spec/generators/install_generator_spec.rb +0 -43
- data/spec/generators/migration/migration_generator_spec.rb +0 -80
- data/spec/generators/models_generator_spec.rb +0 -96
- data/spec/generators/views_generator_spec.rb +0 -195
- data/spec/helpers/polymorphic_helpers_spec.rb +0 -89
- data/spec/helpers/view_helpers_spec.rb +0 -547
- data/spec/jobs/notification_resilience_job_spec.rb +0 -167
- data/spec/jobs/notify_all_job_spec.rb +0 -23
- data/spec/jobs/notify_job_spec.rb +0 -23
- data/spec/jobs/notify_to_job_spec.rb +0 -23
- data/spec/mailers/mailer_spec.rb +0 -214
- data/spec/mailers/notification_resilience_spec.rb +0 -263
- data/spec/models/dummy/dummy_group_spec.rb +0 -10
- data/spec/models/dummy/dummy_notifiable_spec.rb +0 -10
- data/spec/models/dummy/dummy_notifier_spec.rb +0 -10
- data/spec/models/dummy/dummy_subscriber_spec.rb +0 -8
- data/spec/models/dummy/dummy_target_spec.rb +0 -10
- data/spec/models/notification_spec.rb +0 -472
- data/spec/models/subscription_spec.rb +0 -215
- data/spec/optional_targets/action_cable_api_channel_spec.rb +0 -34
- data/spec/optional_targets/action_cable_channel_spec.rb +0 -41
- data/spec/optional_targets/amazon_sns_spec.rb +0 -47
- data/spec/optional_targets/base_spec.rb +0 -45
- data/spec/optional_targets/slack_spec.rb +0 -44
- data/spec/orm/dynamoid_spec.rb +0 -115
- data/spec/rails_app/Rakefile +0 -15
- data/spec/rails_app/app/assets/config/manifest.js +0 -3
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/assets/javascripts/application.js +0 -3
- data/spec/rails_app/app/assets/javascripts/cable.js +0 -12
- data/spec/rails_app/app/assets/stylesheets/application.css +0 -15
- data/spec/rails_app/app/assets/stylesheets/reset.css +0 -85
- data/spec/rails_app/app/assets/stylesheets/style.css +0 -244
- data/spec/rails_app/app/controllers/admins_controller.rb +0 -21
- data/spec/rails_app/app/controllers/application_controller.rb +0 -5
- data/spec/rails_app/app/controllers/articles_controller.rb +0 -67
- data/spec/rails_app/app/controllers/comments_controller.rb +0 -36
- data/spec/rails_app/app/controllers/concerns/.keep +0 -0
- data/spec/rails_app/app/controllers/spa_controller.rb +0 -7
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users_controller.rb +0 -26
- data/spec/rails_app/app/helpers/application_helper.rb +0 -2
- data/spec/rails_app/app/helpers/devise_helper.rb +0 -2
- data/spec/rails_app/app/javascript/App.vue +0 -40
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +0 -82
- data/spec/rails_app/app/javascript/components/Top.vue +0 -98
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +0 -200
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +0 -133
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +0 -122
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +0 -279
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +0 -112
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +0 -141
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +0 -226
- data/spec/rails_app/app/javascript/config/development.js +0 -5
- data/spec/rails_app/app/javascript/config/environment.js +0 -7
- data/spec/rails_app/app/javascript/config/production.js +0 -5
- data/spec/rails_app/app/javascript/config/test.js +0 -5
- data/spec/rails_app/app/javascript/packs/application.js +0 -18
- data/spec/rails_app/app/javascript/packs/spa.js +0 -14
- data/spec/rails_app/app/javascript/router/index.js +0 -73
- data/spec/rails_app/app/javascript/store/index.js +0 -37
- data/spec/rails_app/app/mailers/.keep +0 -0
- data/spec/rails_app/app/mailers/custom_notification_mailer.rb +0 -5
- data/spec/rails_app/app/models/admin.rb +0 -35
- data/spec/rails_app/app/models/article.rb +0 -54
- data/spec/rails_app/app/models/comment.rb +0 -81
- data/spec/rails_app/app/models/dummy/dummy_base.rb +0 -11
- data/spec/rails_app/app/models/dummy/dummy_group.rb +0 -23
- data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +0 -15
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +0 -27
- data/spec/rails_app/app/models/dummy/dummy_notifier.rb +0 -15
- data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +0 -14
- data/spec/rails_app/app/models/dummy/dummy_target.rb +0 -16
- data/spec/rails_app/app/models/user.rb +0 -73
- data/spec/rails_app/app/views/activity_notification/mailer/dummy_subscribers/test_key.text.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +0 -146
- data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_path_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/_custom_index.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +0 -10
- data/spec/rails_app/app/views/articles/_form.html.erb +0 -24
- data/spec/rails_app/app/views/articles/edit.html.erb +0 -8
- data/spec/rails_app/app/views/articles/index.html.erb +0 -113
- data/spec/rails_app/app/views/articles/new.html.erb +0 -7
- data/spec/rails_app/app/views/articles/show.html.erb +0 -49
- data/spec/rails_app/app/views/layouts/_header.html.erb +0 -46
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -15
- data/spec/rails_app/app/views/spa/index.html.erb +0 -2
- data/spec/rails_app/babel.config.js +0 -72
- data/spec/rails_app/bin/bundle +0 -3
- data/spec/rails_app/bin/rails +0 -4
- data/spec/rails_app/bin/rake +0 -4
- data/spec/rails_app/bin/setup +0 -29
- data/spec/rails_app/bin/webpack +0 -18
- data/spec/rails_app/bin/webpack-dev-server +0 -18
- data/spec/rails_app/config/application.rb +0 -54
- data/spec/rails_app/config/boot.rb +0 -5
- data/spec/rails_app/config/cable.yml +0 -8
- data/spec/rails_app/config/database.yml +0 -36
- data/spec/rails_app/config/dynamoid.rb +0 -13
- data/spec/rails_app/config/environment.rb +0 -26
- data/spec/rails_app/config/environments/development.rb +0 -60
- data/spec/rails_app/config/environments/production.rb +0 -85
- data/spec/rails_app/config/environments/test.rb +0 -53
- data/spec/rails_app/config/initializers/activity_notification.rb +0 -104
- data/spec/rails_app/config/initializers/assets.rb +0 -11
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +0 -6
- data/spec/rails_app/config/initializers/devise.rb +0 -278
- data/spec/rails_app/config/initializers/devise_token_auth.rb +0 -55
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/rails_app/config/initializers/inflections.rb +0 -16
- data/spec/rails_app/config/initializers/mime_types.rb +0 -4
- data/spec/rails_app/config/initializers/mysql.rb +0 -9
- data/spec/rails_app/config/initializers/session_store.rb +0 -3
- data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails_app/config/initializers/zeitwerk.rb +0 -10
- data/spec/rails_app/config/locales/activity_notification.en.yml +0 -26
- data/spec/rails_app/config/locales/devise.en.yml +0 -62
- data/spec/rails_app/config/mongoid.yml +0 -13
- data/spec/rails_app/config/routes.rb +0 -50
- data/spec/rails_app/config/secrets.yml +0 -22
- data/spec/rails_app/config/webpack/development.js +0 -5
- data/spec/rails_app/config/webpack/environment.js +0 -7
- data/spec/rails_app/config/webpack/loaders/vue.js +0 -6
- data/spec/rails_app/config/webpack/production.js +0 -5
- data/spec/rails_app/config/webpack/test.js +0 -5
- data/spec/rails_app/config/webpacker.yml +0 -97
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/db/migrate/20160716000000_create_test_tables.rb +0 -42
- data/spec/rails_app/db/migrate/20181209000000_create_activity_notification_tables.rb +0 -33
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +0 -10
- data/spec/rails_app/db/schema.rb +0 -98
- data/spec/rails_app/db/seeds.rb +0 -95
- data/spec/rails_app/lib/custom_optional_targets/console_output.rb +0 -16
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +0 -14
- data/spec/rails_app/lib/custom_optional_targets/wrong_target.rb +0 -13
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +0 -29
- data/spec/rails_app/package.json +0 -23
- data/spec/rails_app/postcss.config.js +0 -12
- data/spec/rails_app/public/404.html +0 -67
- data/spec/rails_app/public/422.html +0 -67
- data/spec/rails_app/public/500.html +0 -66
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/roles/acts_as_group_spec.rb +0 -30
- data/spec/roles/acts_as_notifiable_spec.rb +0 -432
- data/spec/roles/acts_as_notifier_spec.rb +0 -30
- data/spec/roles/acts_as_target_spec.rb +0 -36
- data/spec/spec_helper.rb +0 -56
- data/spec/version_spec.rb +0 -31
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="notification_wrapper">
|
|
3
|
-
<div class="notification_header">
|
|
4
|
-
<h1>
|
|
5
|
-
Notifications to {{ currentTarget.printable_target_name }}
|
|
6
|
-
<a href="#" v-on:click="openAll()" data-remote="true">
|
|
7
|
-
<span class="notification_count"><span v-bind:class="[unopenedNotificationCount > 0 ? 'unopened' : '']">
|
|
8
|
-
{{ unopenedNotificationCount }}
|
|
9
|
-
</span></span>
|
|
10
|
-
</a>
|
|
11
|
-
</h1>
|
|
12
|
-
<h3>
|
|
13
|
-
<span class="action_cable_status">{{ actionCableStatus }}</span>
|
|
14
|
-
</h3>
|
|
15
|
-
</div>
|
|
16
|
-
<div class="notifications">
|
|
17
|
-
<div v-for="notification in notifications" :key="`${notification.id}_${notification.opened_at}_${notification.group_notification_count}`">
|
|
18
|
-
<notification :targetNotification="notification" :targetApiPath="targetApiPath" @getUnopenedNotificationCount="getUnopenedNotificationCount" />
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script>
|
|
25
|
-
import axios from 'axios'
|
|
26
|
-
import Push from 'push.js'
|
|
27
|
-
import Notification from './Notification.vue'
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
name: 'NotificationsIndex',
|
|
31
|
-
components: {
|
|
32
|
-
Notification
|
|
33
|
-
},
|
|
34
|
-
props: {
|
|
35
|
-
target_type: {
|
|
36
|
-
type: String,
|
|
37
|
-
required: true
|
|
38
|
-
},
|
|
39
|
-
target_id: {
|
|
40
|
-
type: [String, Number]
|
|
41
|
-
},
|
|
42
|
-
targetApiPath: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: function () {
|
|
45
|
-
if (this.target_type && this.target_id) {
|
|
46
|
-
return '/' + this.target_type + '/' + this.target_id;
|
|
47
|
-
} else {
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
target: {
|
|
53
|
-
type: Object
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
data () {
|
|
57
|
-
return {
|
|
58
|
-
currentTarget: { printable_target_name: '' },
|
|
59
|
-
unopenedNotificationCount: 0,
|
|
60
|
-
notifications: [],
|
|
61
|
-
actionCableStatus: "Disabled"
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
mounted () {
|
|
65
|
-
if (this.target) {
|
|
66
|
-
this.currentTarget = this.target;
|
|
67
|
-
this.subscribeActionCable();
|
|
68
|
-
} else {
|
|
69
|
-
this.getCurrentTarget();
|
|
70
|
-
}
|
|
71
|
-
this.getNotifications();
|
|
72
|
-
this.getUnopenedNotificationCount();
|
|
73
|
-
},
|
|
74
|
-
channels: {
|
|
75
|
-
'ActivityNotification::NotificationApiChannel': {
|
|
76
|
-
connected() {
|
|
77
|
-
this.actionCableStatus = "Online";
|
|
78
|
-
},
|
|
79
|
-
disconnected() {
|
|
80
|
-
this.actionCableStatus = "Offline";
|
|
81
|
-
},
|
|
82
|
-
rejected() {
|
|
83
|
-
this.actionCableStatus = "Offline (unauthorized)";
|
|
84
|
-
},
|
|
85
|
-
received(data) {
|
|
86
|
-
this.notify(data);
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
'ActivityNotification::NotificationApiWithDeviseChannel': {
|
|
90
|
-
connected() {
|
|
91
|
-
this.actionCableStatus = "Online (authorized)";
|
|
92
|
-
},
|
|
93
|
-
disconnected() {
|
|
94
|
-
this.actionCableStatus = "Offline";
|
|
95
|
-
},
|
|
96
|
-
rejected() {
|
|
97
|
-
this.actionCableStatus = "Offline (unauthorized)";
|
|
98
|
-
},
|
|
99
|
-
received(data) {
|
|
100
|
-
this.notify(data);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
methods: {
|
|
105
|
-
getCurrentTarget () {
|
|
106
|
-
axios
|
|
107
|
-
.get(this.targetApiPath)
|
|
108
|
-
.then(response => {
|
|
109
|
-
this.currentTarget = response.data;
|
|
110
|
-
this.subscribeActionCable();
|
|
111
|
-
})
|
|
112
|
-
},
|
|
113
|
-
getNotifications () {
|
|
114
|
-
axios
|
|
115
|
-
.get(this.targetApiPath + '/notifications', { params: this.$route.query })
|
|
116
|
-
.then(response => (this.notifications = response.data.notifications))
|
|
117
|
-
.catch (error => {
|
|
118
|
-
if (error.response.status == 401) {
|
|
119
|
-
this.$router.push('/logout');
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
},
|
|
123
|
-
getUnopenedNotificationCount () {
|
|
124
|
-
if (this.$route.query.filter == 'opened') {
|
|
125
|
-
this.unopenedNotificationCount = 0;
|
|
126
|
-
} else {
|
|
127
|
-
axios
|
|
128
|
-
.get(this.targetApiPath + '/notifications', { params: Object.assign({ filter: 'unopened' }, this.$route.query) })
|
|
129
|
-
.then(response => (this.unopenedNotificationCount = response.data.count))
|
|
130
|
-
.catch (error => {
|
|
131
|
-
if (error.response.status == 401) {
|
|
132
|
-
this.$router.push('/logout');
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
openAll () {
|
|
138
|
-
axios
|
|
139
|
-
.post(this.targetApiPath + '/notifications/open_all')
|
|
140
|
-
.then(response => {
|
|
141
|
-
if (response.status == 200) {
|
|
142
|
-
this.getNotifications();
|
|
143
|
-
this.getUnopenedNotificationCount();
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
},
|
|
147
|
-
subscribeActionCable () {
|
|
148
|
-
if (this.currentTarget['notification_action_cable_allowed?']) {
|
|
149
|
-
if (!this.currentTarget['notification_action_cable_with_devise?']) {
|
|
150
|
-
this.$cable.subscribe({
|
|
151
|
-
channel: 'ActivityNotification::NotificationApiChannel',
|
|
152
|
-
target_type: this.target_type, target_id: this.currentTarget.id
|
|
153
|
-
});
|
|
154
|
-
} else {
|
|
155
|
-
this.$cable.subscribe({
|
|
156
|
-
channel: 'ActivityNotification::NotificationApiWithDeviseChannel',
|
|
157
|
-
target_type: this.target_type, target_id: this.currentTarget.id,
|
|
158
|
-
'access-token': axios.defaults.headers.common['access-token'],
|
|
159
|
-
'client': axios.defaults.headers.common['client'],
|
|
160
|
-
'uid': axios.defaults.headers.common['uid']
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
notify (data) {
|
|
166
|
-
// Display notification
|
|
167
|
-
if (data.group_owner == null) {
|
|
168
|
-
this.notifications.unshift(data.notification);
|
|
169
|
-
this.getUnopenedNotificationCount();
|
|
170
|
-
} else {
|
|
171
|
-
this.notifications.splice(this.notifications.findIndex(n => n.id === data.group_owner.id), 1);
|
|
172
|
-
this.notifications.unshift(data.group_owner);
|
|
173
|
-
this.getUnopenedNotificationCount();
|
|
174
|
-
}
|
|
175
|
-
// Push notificaion using Web Notification API by Push.js
|
|
176
|
-
Push.create('ActivityNotification', {
|
|
177
|
-
body: data.notification.text,
|
|
178
|
-
timeout: 5000,
|
|
179
|
-
onClick: function () {
|
|
180
|
-
location.href = data.notification.notifiable_path;
|
|
181
|
-
this.close();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
</script>
|
|
188
|
-
|
|
189
|
-
<style scoped>
|
|
190
|
-
.notification_wrapper .notification_header h1 span span{
|
|
191
|
-
color: #fff;
|
|
192
|
-
background-color: #e5e5e5;
|
|
193
|
-
border-radius: 4px;
|
|
194
|
-
font-size: 12px;
|
|
195
|
-
padding: 4px 8px;
|
|
196
|
-
}
|
|
197
|
-
.notification_wrapper .notification_header h1 span span.unopened{
|
|
198
|
-
background-color: #f87880;
|
|
199
|
-
}
|
|
200
|
-
</style>
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-bind:class="`notification_${notification.id}`">
|
|
3
|
-
<div v-if="!notification.opened_at">
|
|
4
|
-
<a href="#" v-on:click="open(notification)" data-remote="true" class="unopened_wrapper">
|
|
5
|
-
<div class="unopened_circle"></div>
|
|
6
|
-
<div class="unopened_description_wrapper">
|
|
7
|
-
<p class="unopened_description">Open</p>
|
|
8
|
-
</div>
|
|
9
|
-
</a>
|
|
10
|
-
<a href="#" v-on:click="move(notification, '?open=true')" data-remote="true">
|
|
11
|
-
<notification-content :notification="notification" />
|
|
12
|
-
</a>
|
|
13
|
-
<div class="unopened_wrapper"></div>
|
|
14
|
-
</div>
|
|
15
|
-
<div v-else>
|
|
16
|
-
<a href="#" v-on:click="move(notification, '')" data-remote="true">
|
|
17
|
-
<notification-content :notification="notification" />
|
|
18
|
-
</a>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script>
|
|
24
|
-
import axios from 'axios'
|
|
25
|
-
import NotificationContent from './NotificationContent.vue'
|
|
26
|
-
|
|
27
|
-
export default {
|
|
28
|
-
name: 'Notification',
|
|
29
|
-
components: {
|
|
30
|
-
NotificationContent
|
|
31
|
-
},
|
|
32
|
-
props: {
|
|
33
|
-
targetNotification: {
|
|
34
|
-
type: Object,
|
|
35
|
-
required: true
|
|
36
|
-
},
|
|
37
|
-
targetApiPath: {
|
|
38
|
-
type: String,
|
|
39
|
-
required: true
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
data () {
|
|
43
|
-
return {
|
|
44
|
-
notification: this.targetNotification,
|
|
45
|
-
baseURL: axios.defaults.baseURL + this.targetApiPath
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
methods: {
|
|
49
|
-
open (notification) {
|
|
50
|
-
axios
|
|
51
|
-
.put(this.targetApiPath + '/notifications/' + notification.id + '/open')
|
|
52
|
-
.then(response => {
|
|
53
|
-
if (response.status == 200) {
|
|
54
|
-
this.$emit('getUnopenedNotificationCount')
|
|
55
|
-
this.notification = response.data.notification
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
.catch (error => {
|
|
59
|
-
if (error.response.status == 401) {
|
|
60
|
-
this.$router.push('/logout');
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
move (notification, paramsString) {
|
|
65
|
-
axios
|
|
66
|
-
.get(this.targetApiPath + '/notifications/' + notification.id + '/move' + paramsString)
|
|
67
|
-
.then(response => {
|
|
68
|
-
if (response.status == 200) {
|
|
69
|
-
window.location.href = response.request.responseURL;
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
.catch (error => {
|
|
73
|
-
if (error.response.status == 401) {
|
|
74
|
-
this.$router.push('/logout');
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<style scoped>
|
|
83
|
-
/* unopened_circle */
|
|
84
|
-
.unopened_wrapper{
|
|
85
|
-
position: absolute;
|
|
86
|
-
margin-top: 20px;
|
|
87
|
-
margin-left: 56px;
|
|
88
|
-
}
|
|
89
|
-
.unopened_wrapper .unopened_circle {
|
|
90
|
-
display: block;
|
|
91
|
-
width: 10px;
|
|
92
|
-
height: 10px;
|
|
93
|
-
position: absolute;
|
|
94
|
-
border-radius: 50%;
|
|
95
|
-
background-color: #27a5eb;
|
|
96
|
-
z-index: 2;
|
|
97
|
-
}
|
|
98
|
-
.unopened_wrapper:hover > .unopened_description_wrapper{
|
|
99
|
-
display: block;
|
|
100
|
-
}
|
|
101
|
-
.unopened_wrapper .unopened_description_wrapper {
|
|
102
|
-
display: none;
|
|
103
|
-
position: absolute;
|
|
104
|
-
margin-top: 26px;
|
|
105
|
-
margin-left: -24px;
|
|
106
|
-
}
|
|
107
|
-
.unopened_wrapper .unopened_description_wrapper .unopened_description {
|
|
108
|
-
position: absolute;
|
|
109
|
-
color: #fff;
|
|
110
|
-
font-size: 12px;
|
|
111
|
-
text-align: center;
|
|
112
|
-
|
|
113
|
-
border-radius: 4px;
|
|
114
|
-
background: rgba(0, 0, 0, 0.8);
|
|
115
|
-
padding: 4px 12px;
|
|
116
|
-
z-index: 999;
|
|
117
|
-
}
|
|
118
|
-
.unopened_wrapper .unopened_description_wrapper .unopened_description:before {
|
|
119
|
-
border: solid transparent;
|
|
120
|
-
border-top-width: 0;
|
|
121
|
-
content: "";
|
|
122
|
-
display: block;
|
|
123
|
-
position: absolute;
|
|
124
|
-
width: 0;
|
|
125
|
-
left: 50%;
|
|
126
|
-
top: -5px;
|
|
127
|
-
margin-left: -5px;
|
|
128
|
-
height: 0;
|
|
129
|
-
border-width: 0 5px 5px 5px;
|
|
130
|
-
border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
|
|
131
|
-
z-index: 0;
|
|
132
|
-
}
|
|
133
|
-
</style>
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-bind:class="[notification.opened_at ? 'opened' : 'unopened', 'notification_list']">
|
|
3
|
-
<div class="notification_list_cover"></div>
|
|
4
|
-
<div class="list_image"></div>
|
|
5
|
-
<div class="list_text_wrapper">
|
|
6
|
-
<!-- Custom view -->
|
|
7
|
-
<p v-if="notification.key == 'article.update'" class="list_text">
|
|
8
|
-
<strong>{{ notification.notifier.name }}</strong> updated his or her article "{{ notification.notifiable.title }}".
|
|
9
|
-
<br>
|
|
10
|
-
<span class="created_at">{{ new Date(notification.created_at) | moment('timezone', 'UTC', "MMM DD HH:mm") }}</span>
|
|
11
|
-
</p>
|
|
12
|
-
<!-- Default view -->
|
|
13
|
-
<p v-else class="list_text">
|
|
14
|
-
<strong v-if="notification.notifier">{{ notification.notifier.printable_notifier_name }}</strong>
|
|
15
|
-
<strong v-else>Someone</strong>
|
|
16
|
-
<span v-if="notification.group_member_notifier_count > 0">
|
|
17
|
-
and {{ notification.group_member_notifier_count }} other
|
|
18
|
-
<span v-if="notification.notifier">{{ notification.notifier.printable_type.toLowerCase() | pluralize(notification.group_member_notifier_count) }}</span>
|
|
19
|
-
<span v-else>people</span>
|
|
20
|
-
</span>
|
|
21
|
-
notified you of
|
|
22
|
-
<span v-if="notification.notifiable" key="notification-group">
|
|
23
|
-
<span v-if="notification.group_members.length">
|
|
24
|
-
{{ notification.group_notification_count }} {{notification.notifiable_type.toLowerCase() | pluralize(notification.group_notification_count) }} including
|
|
25
|
-
</span>
|
|
26
|
-
{{ notification.printable_notifiable_name }}
|
|
27
|
-
<span v-if="notification.group"> in {{ notification.group.printable_group_name }}</span>
|
|
28
|
-
</span>
|
|
29
|
-
<span v-else key="notification-group">
|
|
30
|
-
<span v-if="notification.group_members.length" key="group-members">
|
|
31
|
-
{{ notification.group_notification_count }} {{notification.notifiable_type.toLowerCase() | pluralize(notification.group_notification_count) }}
|
|
32
|
-
</span>
|
|
33
|
-
<span v-else key="group-members">
|
|
34
|
-
a {{ notification.notifiable_typetoLowerCase() | pluralize(0) }}
|
|
35
|
-
</span>
|
|
36
|
-
<span v-if="notification.group"> in {{ notification.group.printable_group_name }}</span>
|
|
37
|
-
but the notifiable is not found. It may have been deleted.
|
|
38
|
-
</span>
|
|
39
|
-
<br>
|
|
40
|
-
<span class="created_at">{{ new Date(notification.created_at) | moment('timezone', 'UTC', "MMM DD hh:mm") }}</span>
|
|
41
|
-
</p>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
</template>
|
|
45
|
-
|
|
46
|
-
<script>
|
|
47
|
-
export default {
|
|
48
|
-
name: 'NotificationContent',
|
|
49
|
-
props: {
|
|
50
|
-
notification: {
|
|
51
|
-
type: Object,
|
|
52
|
-
required: true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
</script>
|
|
57
|
-
|
|
58
|
-
<style scoped>
|
|
59
|
-
/* list */
|
|
60
|
-
.notification_list {
|
|
61
|
-
padding: 15px 10px;
|
|
62
|
-
position: relative;
|
|
63
|
-
border-bottom: 1px solid #e5e5e5;
|
|
64
|
-
}
|
|
65
|
-
.notification_list.unopened {
|
|
66
|
-
background-color: #eeeff4;
|
|
67
|
-
}
|
|
68
|
-
.notification_list:hover {
|
|
69
|
-
background-color: #f8f9fb;
|
|
70
|
-
}
|
|
71
|
-
.notification_list:last-child {
|
|
72
|
-
border-bottom: none;
|
|
73
|
-
}
|
|
74
|
-
.notification_list:after{
|
|
75
|
-
content: "";
|
|
76
|
-
clear: both;
|
|
77
|
-
display: block;
|
|
78
|
-
}
|
|
79
|
-
.notification_list .notification_list_cover{
|
|
80
|
-
position: absolute;
|
|
81
|
-
opacity: 0;
|
|
82
|
-
top: 0;
|
|
83
|
-
left: 0;
|
|
84
|
-
width: 100%;
|
|
85
|
-
height: 100%;
|
|
86
|
-
z-index: 1;
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
.notification_list .list_image {
|
|
90
|
-
float: left;
|
|
91
|
-
width: 40px;
|
|
92
|
-
height: 40px;
|
|
93
|
-
background-position: center;
|
|
94
|
-
background-repeat: no-repeat;
|
|
95
|
-
background-size: cover;
|
|
96
|
-
background-color: #979797;
|
|
97
|
-
}
|
|
98
|
-
.notification_list .list_text_wrapper {
|
|
99
|
-
float: left;
|
|
100
|
-
width: calc(100% - 60px);
|
|
101
|
-
margin-left: 20px;
|
|
102
|
-
}
|
|
103
|
-
.notification_list .list_text_wrapper .list_text {
|
|
104
|
-
color: #4f4f4f;
|
|
105
|
-
font-size: 14px;
|
|
106
|
-
line-height: 1.4;
|
|
107
|
-
margin-top: 0;
|
|
108
|
-
height: auto;
|
|
109
|
-
font-weight: normal;
|
|
110
|
-
}
|
|
111
|
-
.notification_list .list_text_wrapper .list_text span {
|
|
112
|
-
color: #4f4f4f;
|
|
113
|
-
font-size: 14px;
|
|
114
|
-
}
|
|
115
|
-
.notification_list .list_text_wrapper .list_text strong{
|
|
116
|
-
font-weight: bold;
|
|
117
|
-
}
|
|
118
|
-
.notification_list .list_text_wrapper .list_text span.created_at {
|
|
119
|
-
color: #979797;
|
|
120
|
-
font-size: 13px;
|
|
121
|
-
}
|
|
122
|
-
</style>
|