ソースを参照

تغییر نام

hgh 1 年間 前
親
コミット
0443407b4c

+ 2 - 2
src/api/APIGateway.js

@@ -57,13 +57,13 @@ import ContentTopicCategoryAPI from 'src/api/models/ContentTopicCategory.js'
 import ClassroomRegistrationAPI from 'src/api/models/ClassroomRegistration.js'
 import ProjectAttendanceSheetsAPI from 'src/api/models/ProjectAttendanceSheets.js'
 import SessionAttendanceSheetsAPI from 'src/api/models/SessionAttendanceSheets.js'
-import AlertAPI from 'src/api/models/Alert'
+import SubscriptionAPI from 'src/api/models/Subscription'
 
 /* Exporting the APIGateway object. */
 export const APIGateway = {
   seo: new SeoAPI(),
   auth: new AuthAPI(),
-  alert: new AlertAPI(),
+  subscription: new SubscriptionAPI(),
   user: new UserAPI(),
   unit: new UnitAPI(),
   post: new PostAPI(),

+ 15 - 15
src/api/models/Alert.js → src/api/models/Subscription.js

@@ -1,21 +1,21 @@
 import { appApi } from 'src/boot/axios.js'
 import APIRepository from '../classes/APIRepository.js'
-import { Alert, AlertList } from 'src/models/Alert.js'
+import { Subscription, SubscriptionList } from 'src/models/Subscription.js'
 
-export default class AlertAPI extends APIRepository {
+export default class SubscriptionAPI extends APIRepository {
   constructor() {
-    super('alert', appApi)
+    super('subscription', appApi)
     this.APIAdresses = {
-      base: '/mma/alerts',
-      byId: (id) => '/mma/alerts/' + id,
-      myCorrespondingAlert: '/mma/alerts/my_corresponding_alert'
+      base: '/mma/subscriptions',
+      byId: (id) => '/mma/subscriptions/' + id,
+      myCorrespondingSubscription: '/mma/subscriptions/my_corresponding_subscription'
     }
     this.restUrl = (id) => this.url + '/' + id
     /* Setting the callback functions for the CRUD operations. */
     this.setCrudCallbacks({
-      get: (response) => { return new Alert(response.data) },
-      post: (response) => { return new Alert(response.data) },
-      put: (response) => { return new Alert(response.data) },
+      get: (response) => { return new Subscription(response.data) },
+      post: (response) => { return new Subscription(response.data) },
+      put: (response) => { return new Subscription(response.data) },
       delete: (response) => { return response.data }
     })
   }
@@ -33,7 +33,7 @@ export default class AlertAPI extends APIRepository {
         const results = response.data.results
         delete paginate.results
         return {
-          list: new AlertList(results),
+          list: new SubscriptionList(results),
           paginate
           // {
           //   "count": 1,
@@ -51,16 +51,16 @@ export default class AlertAPI extends APIRepository {
     })
   }
 
-  getMyCorrespondingAlert(data) {
+  getMyCorrespondingSubscription(data) {
     return this.sendRequest({
       apiMethod: 'get',
       api: this.api,
-      request: this.APIAdresses.myCorrespondingAlert,
+      request: this.APIAdresses.myCorrespondingSubscription,
       data: this.getNormalizedSendData({
         source_type: 'UNIT' //
       }, data),
       resolveCallback: (response) => {
-        return new Alert(response.data)
+        return new Subscription(response.data)
       },
       rejectCallback: (error) => {
         return error
@@ -77,7 +77,7 @@ export default class AlertAPI extends APIRepository {
         source_type: 'UNIT'
       }, data),
       resolveCallback: (response) => {
-        return new Alert(response.data)
+        return new Subscription(response.data)
       },
       rejectCallback: (error) => {
         return error
@@ -94,7 +94,7 @@ export default class AlertAPI extends APIRepository {
         state: 'READ'
       },
       resolveCallback: (response) => {
-        return new Alert(response.data)
+        return new Subscription(response.data)
       },
       rejectCallback: (error) => {
         return error

+ 4 - 4
src/components/Widgets/AlertMe/AlertMe.vue

@@ -82,12 +82,12 @@ export default {
   methods: {
     fetchNotificationStatus () {
       this.loading = true
-      APIGateway.alert.getMyCorrespondingAlert(
+      APIGateway.subscription.getMyCorrespondingSubscription(
         {
           source_id: this.sourceId,
           source_type: this.sourceType
-        }).then((alert) => {
-        this.is_enabled = alert?.is_enabled
+        }).then((subscription) => {
+        this.is_enabled = subscription?.is_enabled
       }).catch(() => {
         this.is_enabled = false
       }).finally(() => {
@@ -106,7 +106,7 @@ export default {
 
     toggleNotification (val) {
       this.loading = true
-      APIGateway.alert.submit({
+      APIGateway.subscription.submit({
         source_id: this.sourceId,
         source_type: this.sourceType,
         is_enabled: val,

+ 4 - 4
src/models/Alert.js → src/models/Subscription.js

@@ -1,7 +1,7 @@
 import { User } from 'src/models/User.js'
 import { Collection, Model } from 'js-abstract-model'
 
-class Alert extends Model {
+class Subscription extends Model {
   constructor (data) {
     super(data, [
       { key: 'id' },
@@ -29,10 +29,10 @@ class Alert extends Model {
   }
 }
 
-class AlertList extends Collection {
+class SubscriptionList extends Collection {
   model () {
-    return Alert
+    return Subscription
   }
 }
 
-export { Alert, AlertList }
+export { Subscription, SubscriptionList }