@sparkle-learning/core 0.0.53 → 0.0.55
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.
- package/dist/cjs/{PrivateRoute-074c584e.js → PrivateRoute-f97245ce.js} +18 -30
- package/dist/cjs/{feed.service-b4f09441.js → appdata.service-c8d71e05.js} +4 -56
- package/dist/cjs/{assets.service-0c759d51.js → assets.service-bfa75092.js} +1 -1
- package/dist/cjs/assignment.service-690fb59c.js +19 -0
- package/dist/cjs/{environment-config.service-0e02b049.js → environment-config.service-c8ff1f3d.js} +0 -1
- package/dist/cjs/{facilitator.service-9e990274.js → facilitator.service-ff0e1659.js} +1 -1
- package/dist/cjs/feed.service-8eca4de6.js +57 -0
- package/dist/cjs/header-mobile-collapse_61.cjs.entry.js +76 -87
- package/dist/cjs/{httpService-7211d93b.js → httpService-d2e7bf8f.js} +13 -11
- package/dist/cjs/index.cjs.js +5 -4
- package/dist/cjs/{ion-action-sheet_4.cjs.entry.js → ion-action-sheet_7.cjs.entry.js} +728 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/media.service-8a1b9bc5.js +40 -0
- package/dist/cjs/{signalR.service-5672eebc.js → signalR.service-bd6b42f9.js} +18 -20
- package/dist/cjs/sparkle-animation-player.cjs.entry.js +1 -1
- package/dist/cjs/sparkle-assignment.cjs.entry.js +110 -0
- package/dist/cjs/sparkle-character-intro.cjs.entry.js +2 -2
- package/dist/cjs/sparkle-core.cjs.js +1 -1
- package/dist/cjs/sparkle-discussion-questions_2.cjs.entry.js +20 -11
- package/dist/cjs/sparkle-discussion.cjs.entry.js +6 -4
- package/dist/cjs/sparkle-facilitator-notes-form.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-feed-post.cjs.entry.js +116 -0
- package/dist/cjs/sparkle-feedback.cjs.entry.js +5 -3
- package/dist/cjs/sparkle-file-upload.cjs.entry.js +53 -0
- package/dist/cjs/sparkle-goal-form.cjs.entry.js +11 -8
- package/dist/cjs/sparkle-input.cjs.entry.js +56 -0
- package/dist/cjs/sparkle-quiz-container.cjs.entry.js +1 -1
- package/dist/cjs/sparkle-quiz-old.cjs.entry.js +120 -0
- package/dist/cjs/sparkle-quiz.cjs.entry.js +31 -48
- package/dist/cjs/{student.service-2e58f237.js → student.service-7e5385be.js} +1 -1
- package/dist/cjs/token.service-7a41953d.js +97 -0
- package/dist/cjs/{util-d383acb8.js → util-47e320b2.js} +2 -2
- package/dist/collection/PrivateRoute.js +2 -2
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/layout/facilitator/facilitator-page.js +2 -3
- package/dist/collection/components/layout/page/page.css +4 -0
- package/dist/collection/components/layout/page/page.js +39 -26
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.css +30 -0
- package/dist/collection/components/sparkle-assignment/sparkle-assignment.js +159 -0
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.css +8 -1
- package/dist/collection/components/sparkle-character-intro/sparkle-character-intro.js +10 -6
- package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +13 -2
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-questions/sparkle-discussion-questions.js +4 -2
- package/dist/collection/components/sparkle-discussion/sparkle-discussion-results/sparkle-discussion-results.js +15 -9
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.css +5 -0
- package/dist/collection/components/sparkle-discussion/sparkle-discussion.js +5 -3
- package/dist/collection/components/sparkle-feed-post/sparkle-feed-post.js +54 -75
- package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.css +0 -0
- package/dist/collection/components/sparkle-file-upload/sparkle-file-upload.js +105 -0
- package/dist/collection/components/sparkle-input/sparkle-input.css +0 -0
- package/dist/collection/components/sparkle-input/sparkle-input.js +212 -0
- package/dist/collection/components/sparkle-login/sparkle-login.js +2 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.css → sparkle-quiz-old/sparkle-quiz-old.css} +1 -1
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.js → sparkle-quiz-old/sparkle-quiz-old.js} +4 -4
- package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.js → sparkle-quiz.js} +23 -25
- package/dist/collection/components/sparkle-quiz-container/sparkle-quiz-container.js +1 -1
- package/dist/collection/components/sparkle-root/sparkle-root.js +12 -10
- package/dist/collection/services/assignment.service.js +14 -0
- package/dist/collection/services/auth/auth.service.js +15 -14
- package/dist/collection/services/environment/environment-config.js +1 -1
- package/dist/collection/services/environment/environment-config.service.js +0 -1
- package/dist/collection/services/httpService.js +12 -10
- package/dist/collection/services/signalR.service.js +17 -19
- package/dist/collection/services/token.service.js +79 -0
- package/dist/collection/util.js +5 -2
- package/dist/esm/{PrivateRoute-c5441f35.js → PrivateRoute-90ac95b8.js} +17 -29
- package/dist/esm/{feed.service-8fbe4ce3.js → appdata.service-2e84e167.js} +5 -55
- package/dist/esm/{assets.service-66e848b8.js → assets.service-def1d63c.js} +1 -1
- package/dist/esm/assignment.service-8d31f141.js +17 -0
- package/dist/esm/{environment-config.service-2b5d692b.js → environment-config.service-b191f276.js} +0 -1
- package/dist/esm/{facilitator.service-b0292f7f.js → facilitator.service-18c47bdf.js} +1 -1
- package/dist/esm/feed.service-b4f3cae4.js +54 -0
- package/dist/esm/header-mobile-collapse_61.entry.js +71 -82
- package/dist/esm/{httpService-7b75b095.js → httpService-7986aeed.js} +14 -12
- package/dist/esm/index.js +6 -5
- package/dist/esm/{ion-action-sheet_4.entry.js → ion-action-sheet_7.entry.js} +729 -4
- package/dist/esm/ion-loading.entry.js +1 -1
- package/dist/esm/ion-menu.entry.js +1 -1
- package/dist/esm/ion-modal.entry.js +1 -1
- package/dist/esm/ion-picker.entry.js +1 -1
- package/dist/esm/ion-toast.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/media.service-6e90bc41.js +37 -0
- package/dist/esm/{overlays-3b4dca92.js → overlays-4233a39d.js} +1 -1
- package/dist/esm/{signalR.service-9d5b9f36.js → signalR.service-c33fba50.js} +18 -20
- package/dist/esm/sparkle-animation-player.entry.js +1 -1
- package/dist/esm/sparkle-assignment.entry.js +106 -0
- package/dist/esm/sparkle-character-intro.entry.js +3 -3
- package/dist/esm/sparkle-core.js +1 -1
- package/dist/esm/sparkle-discussion-questions_2.entry.js +20 -11
- package/dist/esm/sparkle-discussion.entry.js +6 -4
- package/dist/esm/sparkle-facilitator-notes-form.entry.js +6 -4
- package/dist/esm/sparkle-feed-post.entry.js +112 -0
- package/dist/esm/sparkle-feedback.entry.js +6 -4
- package/dist/esm/sparkle-file-upload.entry.js +49 -0
- package/dist/esm/sparkle-goal-form.entry.js +9 -6
- package/dist/esm/sparkle-input.entry.js +52 -0
- package/dist/esm/sparkle-quiz-container.entry.js +1 -1
- package/dist/esm/sparkle-quiz-old.entry.js +116 -0
- package/dist/esm/sparkle-quiz.entry.js +31 -48
- package/dist/esm/{student.service-0746418b.js → student.service-08af124f.js} +1 -1
- package/dist/esm/token.service-71a5d33f.js +94 -0
- package/dist/esm/{util-6ef753e9.js → util-57cc8006.js} +2 -2
- package/dist/sparkle-core/index.esm.js +1 -1
- package/dist/sparkle-core/p-08420531.entry.js +1 -0
- package/dist/sparkle-core/p-08cca80d.entry.js +1 -0
- package/dist/sparkle-core/p-0e8e539f.entry.js +1 -0
- package/dist/sparkle-core/p-13ec39db.entry.js +1 -0
- package/dist/sparkle-core/p-1adc98f6.js +1 -0
- package/dist/sparkle-core/p-38c842d5.entry.js +1 -0
- package/dist/sparkle-core/{p-fbccd30c.js → p-39a31e43.js} +1 -1
- package/dist/sparkle-core/{p-0a5d7c4f.entry.js → p-3daf2915.entry.js} +26 -26
- package/dist/sparkle-core/{p-9a443f51.js → p-408176ba.js} +1 -1
- package/dist/sparkle-core/p-42ed7d5f.entry.js +1 -0
- package/dist/sparkle-core/p-4b4a8703.js +1 -0
- package/dist/sparkle-core/p-4d1cfcbe.entry.js +1 -0
- package/dist/sparkle-core/p-4fba3e4c.js +1 -0
- package/dist/sparkle-core/{p-54dd894f.entry.js → p-6bde0192.entry.js} +1 -1
- package/dist/sparkle-core/{p-6faa194c.entry.js → p-6d2f4093.entry.js} +1 -1
- package/dist/sparkle-core/{p-162bff1a.entry.js → p-72053ae0.entry.js} +1 -1
- package/dist/sparkle-core/p-7dae0f0e.js +1 -0
- package/dist/sparkle-core/{p-18cdd458.entry.js → p-85d4cd5c.entry.js} +1 -1
- package/dist/sparkle-core/p-973fe404.entry.js +22 -0
- package/dist/sparkle-core/{p-ff0e0d4e.entry.js → p-98daeddb.entry.js} +1 -1
- package/dist/sparkle-core/p-b06e2bef.js +1 -0
- package/dist/sparkle-core/{p-e863bf1d.entry.js → p-b6fec622.entry.js} +1 -1
- package/dist/sparkle-core/p-b8d71ff4.js +1 -0
- package/dist/sparkle-core/p-bd90903e.js +1 -0
- package/dist/sparkle-core/{p-a49ab4e8.entry.js → p-c64a34cd.entry.js} +1 -1
- package/dist/sparkle-core/{p-5efc6566.js → p-c9f753a4.js} +1 -1
- package/dist/sparkle-core/p-da391f3f.js +1 -0
- package/dist/sparkle-core/p-e0cad1bb.js +1 -0
- package/dist/sparkle-core/{p-ce4b22f7.entry.js → p-f196c124.entry.js} +1 -1
- package/dist/sparkle-core/p-f47fe1fe.entry.js +1 -0
- package/dist/sparkle-core/p-f714f77a.entry.js +1 -0
- package/dist/sparkle-core/p-f891c79a.entry.js +1 -0
- package/dist/sparkle-core/{p-377b04c2.entry.js → p-ff080f82.entry.js} +1 -1
- package/dist/sparkle-core/{p-2ff67662.js → p-ff7a8a71.js} +1 -1
- package/dist/sparkle-core/sparkle-core.esm.js +1 -1
- package/dist/types/components/layout/page/page.d.ts +2 -0
- package/dist/types/components/sparkle-assignment/sparkle-assignment.d.ts +16 -0
- package/dist/types/components/sparkle-course-root/sparkle-course-root.d.ts +1 -0
- package/dist/types/components/sparkle-feed-post/sparkle-feed-post.d.ts +4 -3
- package/dist/types/components/sparkle-file-upload/sparkle-file-upload.d.ts +15 -0
- package/dist/types/components/sparkle-input/sparkle-input.d.ts +23 -0
- package/dist/types/components/sparkle-quiz/{sparkle-quiz/sparkle-quiz.d.ts → sparkle-quiz-old/sparkle-quiz-old.d.ts} +1 -1
- package/dist/types/components/sparkle-quiz/{sparkle-quiz-v1.d.ts → sparkle-quiz.d.ts} +1 -1
- package/dist/types/components.d.ts +111 -36
- package/dist/types/models/class.model.d.ts +4 -0
- package/dist/types/services/assignment.service.d.ts +8 -0
- package/dist/types/services/auth/auth.service.d.ts +1 -1
- package/dist/types/services/environment/environment-config.d.ts +3 -0
- package/dist/types/services/token.service.d.ts +13 -0
- package/dist/types/util.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/ion-select_3.cjs.entry.js +0 -618
- package/dist/cjs/ion-textarea.cjs.entry.js +0 -248
- package/dist/cjs/sparkle-quiz-v1.cjs.entry.js +0 -105
- package/dist/esm/ion-select_3.entry.js +0 -612
- package/dist/esm/ion-textarea.entry.js +0 -244
- package/dist/esm/sparkle-quiz-v1.entry.js +0 -101
- package/dist/sparkle-core/p-0f1c5899.entry.js +0 -18
- package/dist/sparkle-core/p-1d4c7c11.js +0 -1
- package/dist/sparkle-core/p-30767c1c.entry.js +0 -1
- package/dist/sparkle-core/p-3265ed87.entry.js +0 -1
- package/dist/sparkle-core/p-370609ba.entry.js +0 -1
- package/dist/sparkle-core/p-44334ef3.entry.js +0 -4
- package/dist/sparkle-core/p-462bffba.js +0 -1
- package/dist/sparkle-core/p-4c9f994f.js +0 -1
- package/dist/sparkle-core/p-58e4bbe5.entry.js +0 -1
- package/dist/sparkle-core/p-600cf6a3.js +0 -1
- package/dist/sparkle-core/p-641bfc92.entry.js +0 -1
- package/dist/sparkle-core/p-80d6b0e6.entry.js +0 -1
- package/dist/sparkle-core/p-af3cc111.entry.js +0 -1
- package/dist/sparkle-core/p-b226f54d.js +0 -1
- /package/dist/collection/components/sparkle-quiz/{sparkle-quiz-v1.css → sparkle-quiz.css} +0 -0
- /package/dist/sparkle-core/{p-935e7cfc.js → p-8b56f734.js} +0 -0
@@ -32,7 +32,7 @@ export class SparkleQuizContainer {
|
|
32
32
|
}
|
33
33
|
render() {
|
34
34
|
return (h(Host, null,
|
35
|
-
this.questionIds && this.questionIds.split(",").map((id => h("sparkle-quiz", { questionId: +id, submitted: this.submitted, showInstantResult: this.showInstantResult }))),
|
35
|
+
this.questionIds && this.questionIds.split(",").map((id => h("sparkle-quiz-v1", { questionId: +id, submitted: this.submitted, showInstantResult: this.showInstantResult }))),
|
36
36
|
h("ion-button", { slot: "end", onClick: () => this.submitQuiz() }, "Submit")));
|
37
37
|
}
|
38
38
|
static get is() { return "sparkle-quiz-container"; }
|
@@ -2,30 +2,32 @@ import { Component, Host, h, Prop } from '@stencil/core';
|
|
2
2
|
import { setupConfig as setupSparkleConfig } from '../../services/environment/environment-config';
|
3
3
|
import { HttpService } from '../../services/httpService';
|
4
4
|
import { StudentService } from '../../services/student.service';
|
5
|
-
import {
|
6
|
-
import { AuthStore } from "../../stores/auth.store";
|
5
|
+
import { AuthStore } from '../../stores/auth.store';
|
7
6
|
import { SignalRService } from '../../services/signalR.service';
|
8
7
|
import { injectHistory } from '@stencil/router';
|
8
|
+
import { get } from '../../services/core/localstorage.service';
|
9
|
+
import AppConsts from '../../appconst';
|
9
10
|
export class SparkleRoot {
|
10
11
|
constructor() {
|
11
12
|
this.history = null;
|
12
|
-
this.handleStudentNavigationChange =
|
13
|
+
this.handleStudentNavigationChange = url => {
|
13
14
|
this.history.replace(url, {});
|
14
15
|
};
|
15
16
|
}
|
16
17
|
async componentWillLoad() {
|
17
18
|
setupSparkleConfig({
|
18
|
-
sparkle: Object.assign(Object.assign({}, this.config), { prod: true })
|
19
|
+
sparkle: Object.assign(Object.assign({}, this.config), { prod: true }),
|
19
20
|
});
|
20
21
|
//return Promise.reject();
|
21
22
|
await HttpService.getInstance();
|
22
23
|
await HttpService.init();
|
23
|
-
|
24
|
-
|
24
|
+
let auth = await get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
25
|
+
console.log(auth);
|
26
|
+
//TODO: check expiry as well
|
27
|
+
if (auth && auth.JWToken) {
|
25
28
|
AuthStore.state.isAuthenticated = true;
|
26
29
|
}
|
27
|
-
|
28
|
-
AuthStore.onChange("isAuthenticated", async (isAuthenticated) => {
|
30
|
+
AuthStore.onChange('isAuthenticated', async (isAuthenticated) => {
|
29
31
|
if (isAuthenticated) {
|
30
32
|
console.log('authenticated');
|
31
33
|
await StudentService.getInstance().fetchUserConfiguration();
|
@@ -37,8 +39,8 @@ export class SparkleRoot {
|
|
37
39
|
//SignalRAspNetCoreHelper.initSignalR();
|
38
40
|
}
|
39
41
|
componentDidLoad() {
|
40
|
-
SignalRService.getInstance().connection.on(
|
41
|
-
AuthStore.onChange(
|
42
|
+
SignalRService.getInstance().connection.on('NavigateStudentTo', this.handleStudentNavigationChange);
|
43
|
+
AuthStore.onChange('isAuthenticated', async (isAuthenticated) => {
|
42
44
|
if (isAuthenticated) {
|
43
45
|
SignalRService.getInstance().start();
|
44
46
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { HttpService } from './httpService';
|
2
|
+
export class AssignmentService {
|
3
|
+
constructor() { }
|
4
|
+
static getInstance() {
|
5
|
+
if (!AssignmentService.instance) {
|
6
|
+
AssignmentService.instance = new AssignmentService();
|
7
|
+
}
|
8
|
+
return AssignmentService.instance;
|
9
|
+
}
|
10
|
+
async createAssignment(payload) {
|
11
|
+
let result = await HttpService.http.post(`api/v1/Assignment/Create`, payload);
|
12
|
+
return result;
|
13
|
+
}
|
14
|
+
}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import { get,
|
1
|
+
import { get, remove } from '../core/localstorage.service';
|
2
2
|
import { HttpService } from '../httpService';
|
3
3
|
import AppConsts from '../../appconst';
|
4
|
-
import { AuthStore } from
|
4
|
+
import { AuthStore } from '../../stores/auth.store';
|
5
|
+
import { TokenService } from '../token.service';
|
5
6
|
export class AuthService {
|
6
7
|
constructor() { }
|
7
8
|
static getInstance() {
|
@@ -18,7 +19,7 @@ export class AuthService {
|
|
18
19
|
let result;
|
19
20
|
try {
|
20
21
|
result = await HttpService.http.post('api/Account/Authenticate', authenticationInput, {
|
21
|
-
headers: headers
|
22
|
+
headers: headers,
|
22
23
|
});
|
23
24
|
if (result) {
|
24
25
|
const authData = result.Data;
|
@@ -32,15 +33,17 @@ export class AuthService {
|
|
32
33
|
IssuedOn: authData.IssuedOn,
|
33
34
|
ExpiresOn: authData.ExpiresOn,
|
34
35
|
RefreshToken: authData.RefreshToken,
|
35
|
-
PhotoUrl:
|
36
|
-
IsFacilitator: authData.Roles.indexOf(
|
36
|
+
PhotoUrl: '',
|
37
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
37
38
|
};
|
38
|
-
const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
39
|
-
|
40
|
-
//
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
//const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
40
|
+
// let authObj: EnvironmentAuthConfig = {
|
41
|
+
// token: authUser.JWToken,
|
42
|
+
// expiryDate: expireDate,
|
43
|
+
// };
|
44
|
+
// EnvironmentConfigService.getInstance().setupAuth(authObj);
|
45
|
+
//sparkle.utils.setCookieValue(AppConsts.authorization.encrptedAuthTokenName, authUser.JWToken, expireDate, sparkle.appPath);
|
46
|
+
await TokenService.getInstance().saveAuthUser(authUser);
|
44
47
|
AuthStore.state.loading = false;
|
45
48
|
return authUser;
|
46
49
|
}
|
@@ -52,10 +55,8 @@ export class AuthService {
|
|
52
55
|
}
|
53
56
|
async signOut() {
|
54
57
|
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
58
|
+
await TokenService.getInstance().removeAuthUser();
|
55
59
|
sessionStorage.clear();
|
56
|
-
sparkle.auth.clearToken();
|
57
|
-
AuthStore.state.authUser = null;
|
58
|
-
AuthStore.state.isAuthenticated = false;
|
59
60
|
}
|
60
61
|
async getLocalAuthUser() {
|
61
62
|
return get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
@@ -3,6 +3,7 @@ import qs from 'qs';
|
|
3
3
|
import { toastController } from '@ionic/core';
|
4
4
|
import { TocStore } from '../stores/toc.store';
|
5
5
|
import { EnvironmentConfigService } from '.';
|
6
|
+
import { TokenService } from './token.service';
|
6
7
|
export class HttpService {
|
7
8
|
constructor() { }
|
8
9
|
static getInstance() {
|
@@ -16,7 +17,7 @@ export class HttpService {
|
|
16
17
|
this.http = axios.create({
|
17
18
|
baseURL: sparkleConfig.apiUrl,
|
18
19
|
headers: {
|
19
|
-
'Content-Type': 'application/json'
|
20
|
+
'Content-Type': 'application/json',
|
20
21
|
},
|
21
22
|
timeout: 30000,
|
22
23
|
paramsSerializer: function (params) {
|
@@ -25,9 +26,10 @@ export class HttpService {
|
|
25
26
|
});
|
26
27
|
},
|
27
28
|
});
|
28
|
-
this.http.interceptors.request.use(function (config) {
|
29
|
-
|
30
|
-
|
29
|
+
this.http.interceptors.request.use(async function (config) {
|
30
|
+
let token = await TokenService.getInstance().getToken();
|
31
|
+
if (token) {
|
32
|
+
config.headers.common['Authorization'] = 'Bearer ' + token;
|
31
33
|
}
|
32
34
|
// //config.headers.common['.AspNetCore.Culture'] = sparkle.utils.getCookieValue('Sparkle.Localization.CultureName');
|
33
35
|
config.headers.common['Sparkle.CourseId'] = sparkleConfig.courseId;
|
@@ -45,7 +47,7 @@ export class HttpService {
|
|
45
47
|
if (response.data.Message) {
|
46
48
|
const toast = await toastController.create({
|
47
49
|
message: response.data.Message,
|
48
|
-
duration: 3000
|
50
|
+
duration: 3000,
|
49
51
|
});
|
50
52
|
toast.present();
|
51
53
|
}
|
@@ -56,7 +58,7 @@ export class HttpService {
|
|
56
58
|
// that falls out of the range of 2xx
|
57
59
|
const toast = await toastController.create({
|
58
60
|
message: error.response.data.ErrorMessage,
|
59
|
-
duration: 3000
|
61
|
+
duration: 3000,
|
60
62
|
});
|
61
63
|
toast.present();
|
62
64
|
return Promise.reject(error);
|
@@ -66,7 +68,7 @@ export class HttpService {
|
|
66
68
|
// that falls out of the range of 2xx
|
67
69
|
const toast = await toastController.create({
|
68
70
|
message: error.response.data.Message,
|
69
|
-
duration: 3000
|
71
|
+
duration: 3000,
|
70
72
|
});
|
71
73
|
toast.present();
|
72
74
|
return Promise.reject(error.response.data);
|
@@ -76,7 +78,7 @@ export class HttpService {
|
|
76
78
|
// that falls out of the range of 2xx
|
77
79
|
const toast = await toastController.create({
|
78
80
|
message: error.response.data.Message,
|
79
|
-
duration: 3000
|
81
|
+
duration: 3000,
|
80
82
|
});
|
81
83
|
toast.present();
|
82
84
|
return Promise.reject(error);
|
@@ -89,8 +91,8 @@ export class HttpService {
|
|
89
91
|
}
|
90
92
|
else {
|
91
93
|
const toast = await toastController.create({
|
92
|
-
message:
|
93
|
-
duration: 3000
|
94
|
+
message: 'Unknown Error',
|
95
|
+
duration: 3000,
|
94
96
|
});
|
95
97
|
toast.present();
|
96
98
|
}
|
@@ -1,17 +1,18 @@
|
|
1
1
|
import * as signalR from '@microsoft/signalr';
|
2
2
|
import { EnvironmentConfigService } from '.';
|
3
3
|
import signalRStore from '../stores/signalR.store';
|
4
|
+
import { TokenService } from './token.service';
|
4
5
|
export class SignalRService {
|
5
6
|
constructor() {
|
6
|
-
console.log(
|
7
|
+
console.log('Starting signalR');
|
7
8
|
//TODO: update courseClassId
|
8
9
|
var defaultCourseClassId = 1;
|
9
10
|
var sparkleConfig = EnvironmentConfigService.getInstance().get('sparkle');
|
10
11
|
this.connection = new signalR.HubConnectionBuilder()
|
11
|
-
.withUrl(`${sparkleConfig.apiUrl}hubs/sparkle?url=${window.location.href}${defaultCourseClassId > 0 ?
|
12
|
+
.withUrl(`${sparkleConfig.apiUrl}hubs/sparkle?url=${window.location.href}${defaultCourseClassId > 0 ? '&courseClassId=' + defaultCourseClassId : ''}`, {
|
12
13
|
accessTokenFactory: () => this.getToken(),
|
13
14
|
skipNegotiation: true,
|
14
|
-
transport: signalR.HttpTransportType.WebSockets
|
15
|
+
transport: signalR.HttpTransportType.WebSockets,
|
15
16
|
})
|
16
17
|
.configureLogging(signalR.LogLevel.Debug)
|
17
18
|
//.withAutomaticReconnect()
|
@@ -26,15 +27,14 @@ export class SignalRService {
|
|
26
27
|
// If we've been reconnecting for more than 60 seconds so far, stop reconnecting.
|
27
28
|
return null;
|
28
29
|
}
|
29
|
-
}
|
30
|
+
},
|
30
31
|
})
|
31
32
|
.build();
|
32
|
-
this.connection.on(
|
33
|
+
this.connection.on('SendMessage', (user, data) => {
|
33
34
|
let payload = JSON.parse(data);
|
34
|
-
console.log(
|
35
|
-
});
|
36
|
-
this.connection.onclose(error => {
|
35
|
+
console.log('Server said ', user, payload);
|
37
36
|
});
|
37
|
+
this.connection.onclose(error => { });
|
38
38
|
this.connection.onreconnecting(error => {
|
39
39
|
console.assert(this.connection.state === signalR.HubConnectionState.Reconnecting);
|
40
40
|
});
|
@@ -49,36 +49,34 @@ export class SignalRService {
|
|
49
49
|
return SignalRService.instance;
|
50
50
|
}
|
51
51
|
async start() {
|
52
|
-
console.log(
|
52
|
+
console.log('start');
|
53
53
|
try {
|
54
54
|
signalRStore.state.connecting = true;
|
55
55
|
signalRStore.state.connected = !signalRStore.state.connecting;
|
56
56
|
await this.connection.start();
|
57
57
|
console.log(this.connection);
|
58
58
|
signalRStore.state.connecting = false;
|
59
|
-
signalRStore.state.connected =
|
59
|
+
signalRStore.state.connected = this.connection.state === signalR.HubConnectionState.Connected;
|
60
60
|
console.assert(this.connection.state === signalR.HubConnectionState.Connected);
|
61
|
-
console.log(
|
61
|
+
console.log('SignalR Connected.');
|
62
62
|
}
|
63
63
|
catch (err) {
|
64
64
|
console.assert(this.connection.state === signalR.HubConnectionState.Disconnected);
|
65
65
|
console.log(err);
|
66
66
|
}
|
67
67
|
}
|
68
|
-
;
|
69
68
|
async callSignalR(hub, data) {
|
70
|
-
|
71
|
-
if (!
|
72
|
-
console.log(
|
69
|
+
let token = await this.getToken();
|
70
|
+
if (!token) {
|
71
|
+
console.log('Cannot connect to signalR. Not logged in');
|
73
72
|
return;
|
74
73
|
}
|
75
74
|
this.connection.invoke(hub, JSON.stringify(data));
|
76
|
-
console.log('After signalR invoke', hub, this.connection.connectionState);
|
77
75
|
}
|
78
76
|
getToken() {
|
79
|
-
var
|
80
|
-
if (
|
81
|
-
return
|
77
|
+
var token = TokenService.getInstance().getTokenSync();
|
78
|
+
if (token) {
|
79
|
+
return token;
|
82
80
|
}
|
83
81
|
return null;
|
84
82
|
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import AppConsts from '../appconst';
|
2
|
+
import { AuthStore } from '../stores';
|
3
|
+
import { get, remove, set } from './core/localstorage.service';
|
4
|
+
export class TokenService {
|
5
|
+
static getInstance() {
|
6
|
+
if (!TokenService.instance) {
|
7
|
+
TokenService.instance = new TokenService();
|
8
|
+
}
|
9
|
+
return TokenService.instance;
|
10
|
+
}
|
11
|
+
async getToken() {
|
12
|
+
let authUser = await get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
13
|
+
if (authUser && authUser.JWToken) {
|
14
|
+
if (new Date(authUser.ExpiresOn).getTime() > new Date().getTime()) {
|
15
|
+
return authUser.JWToken;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
return null;
|
19
|
+
}
|
20
|
+
async getAuthUser() {
|
21
|
+
let authUser = await get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
22
|
+
if (authUser && authUser.JWToken) {
|
23
|
+
if (new Date(authUser.ExpiresOn).getTime() > new Date().getTime()) {
|
24
|
+
return authUser;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
return null;
|
28
|
+
}
|
29
|
+
getAuthUserSync() {
|
30
|
+
let authUser = JSON.parse(localStorage.getItem(AppConsts.AUTH_USER_LOCALSTORAGE));
|
31
|
+
if (authUser && authUser.JWToken) {
|
32
|
+
if (new Date(authUser.ExpiresOn).getTime() > new Date().getTime()) {
|
33
|
+
return authUser;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return null;
|
37
|
+
}
|
38
|
+
getTokenSync() {
|
39
|
+
let authUser = JSON.parse(localStorage.getItem(AppConsts.AUTH_USER_LOCALSTORAGE));
|
40
|
+
if (authUser && authUser.JWToken) {
|
41
|
+
if (new Date(authUser.ExpiresOn).getTime() > new Date().getTime()) {
|
42
|
+
return authUser.JWToken;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
isAuthenticated() {
|
48
|
+
try {
|
49
|
+
let token = this.getTokenSync();
|
50
|
+
if (!!token) {
|
51
|
+
return true;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
catch (_a) {
|
55
|
+
return false;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
async getTokenExpiry() {
|
59
|
+
let authUser = await get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
60
|
+
if (!authUser) {
|
61
|
+
return 0;
|
62
|
+
}
|
63
|
+
let timeDiff = 0;
|
64
|
+
if (authUser.ExpiresOn) {
|
65
|
+
timeDiff = new Date(authUser.ExpiresOn).getTime() - new Date().getTime();
|
66
|
+
}
|
67
|
+
return Math.max(0, timeDiff);
|
68
|
+
}
|
69
|
+
async saveAuthUser(authUser) {
|
70
|
+
AuthStore.state.authUser = Object.assign({}, authUser);
|
71
|
+
AuthStore.state.isAuthenticated = true;
|
72
|
+
await set(AppConsts.AUTH_USER_LOCALSTORAGE, authUser);
|
73
|
+
}
|
74
|
+
async removeAuthUser() {
|
75
|
+
AuthStore.state.authUser = null;
|
76
|
+
AuthStore.state.isAuthenticated = false;
|
77
|
+
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
78
|
+
}
|
79
|
+
}
|
package/dist/collection/util.js
CHANGED
@@ -20,7 +20,7 @@ export function GetGoalAppData(title, description, category, percentage, goalTex
|
|
20
20
|
Description: description,
|
21
21
|
Category: category,
|
22
22
|
Percentage: percentage,
|
23
|
-
GoalText: goalText
|
23
|
+
GoalText: goalText,
|
24
24
|
};
|
25
25
|
}
|
26
26
|
export function MyMoodTemplate(feeling, intensity, location) {
|
@@ -41,12 +41,15 @@ export function MyGoalTemplate(goalName, text, progress) {
|
|
41
41
|
export function MyGoalTemplateJSON(goalName, goalUpdateText, progress) {
|
42
42
|
return JSON.stringify({ GoalTitle: goalName, GoalText: goalUpdateText, GoalProgress: progress });
|
43
43
|
}
|
44
|
+
export function FeedPostJSON(postText) {
|
45
|
+
return JSON.stringify({ PostText: postText });
|
46
|
+
}
|
44
47
|
export class SparkleGlobal {
|
45
48
|
}
|
46
49
|
SparkleGlobal.MY_GOALS_APP_ID = 1;
|
47
50
|
SparkleGlobal.MY_HEALTH_APP_ID = 2;
|
48
51
|
SparkleGlobal.MY_MOOD_APP_ID = 3;
|
49
|
-
SparkleGlobal.LOCALSTORAGE_CLASSROOM_MODE =
|
52
|
+
SparkleGlobal.LOCALSTORAGE_CLASSROOM_MODE = 'SPARKLE_CLASSROOM_MODE';
|
50
53
|
export function date(date) {
|
51
54
|
return format(new Date(date), 'DD MMM YYYY');
|
52
55
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { c as getAssetPath, h } from './index-c04b9ed5.js';
|
2
|
-
import {
|
3
|
-
import { H as HttpService } from './httpService-
|
2
|
+
import { r as remove, g as get } from './localstorage.service-4bf408c8.js';
|
3
|
+
import { H as HttpService } from './httpService-7986aeed.js';
|
4
|
+
import { T as TokenService, A as AppConsts } from './token.service-71a5d33f.js';
|
4
5
|
import { A as AuthStore } from './auth.store-dba2c2da.js';
|
5
6
|
|
6
7
|
//import * as abpTypings from '../lib/abp';
|
@@ -119,19 +120,6 @@ async function initSetupConfig(config) {
|
|
119
120
|
await setupConfig(config);
|
120
121
|
}
|
121
122
|
|
122
|
-
const AppConsts = {
|
123
|
-
AUTH_USER_LOCALSTORAGE: "CurrentUser",
|
124
|
-
userManagement: {
|
125
|
-
defaultAdminUserName: 'admin',
|
126
|
-
},
|
127
|
-
localization: {
|
128
|
-
defaultLocalizationSourceName: 'Test',
|
129
|
-
},
|
130
|
-
authorization: {
|
131
|
-
encrptedAuthTokenName: 'enc_auth_token',
|
132
|
-
}
|
133
|
-
};
|
134
|
-
|
135
123
|
class AuthService {
|
136
124
|
constructor() { }
|
137
125
|
static getInstance() {
|
@@ -148,7 +136,7 @@ class AuthService {
|
|
148
136
|
let result;
|
149
137
|
try {
|
150
138
|
result = await HttpService.http.post('api/Account/Authenticate', authenticationInput, {
|
151
|
-
headers: headers
|
139
|
+
headers: headers,
|
152
140
|
});
|
153
141
|
if (result) {
|
154
142
|
const authData = result.Data;
|
@@ -162,15 +150,17 @@ class AuthService {
|
|
162
150
|
IssuedOn: authData.IssuedOn,
|
163
151
|
ExpiresOn: authData.ExpiresOn,
|
164
152
|
RefreshToken: authData.RefreshToken,
|
165
|
-
PhotoUrl:
|
166
|
-
IsFacilitator: authData.Roles.indexOf(
|
153
|
+
PhotoUrl: '',
|
154
|
+
IsFacilitator: authData.Roles.indexOf('Facilitator') > 0,
|
167
155
|
};
|
168
|
-
const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
169
|
-
|
170
|
-
//
|
171
|
-
|
172
|
-
|
173
|
-
|
156
|
+
//const expireDate = authenticationInput.RememberClient ? new Date(authUser.ExpiresOn) : undefined;
|
157
|
+
// let authObj: EnvironmentAuthConfig = {
|
158
|
+
// token: authUser.JWToken,
|
159
|
+
// expiryDate: expireDate,
|
160
|
+
// };
|
161
|
+
// EnvironmentConfigService.getInstance().setupAuth(authObj);
|
162
|
+
//sparkle.utils.setCookieValue(AppConsts.authorization.encrptedAuthTokenName, authUser.JWToken, expireDate, sparkle.appPath);
|
163
|
+
await TokenService.getInstance().saveAuthUser(authUser);
|
174
164
|
AuthStore.state.loading = false;
|
175
165
|
return authUser;
|
176
166
|
}
|
@@ -182,10 +172,8 @@ class AuthService {
|
|
182
172
|
}
|
183
173
|
async signOut() {
|
184
174
|
await remove(AppConsts.AUTH_USER_LOCALSTORAGE);
|
175
|
+
await TokenService.getInstance().removeAuthUser();
|
185
176
|
sessionStorage.clear();
|
186
|
-
sparkle.auth.clearToken();
|
187
|
-
AuthStore.state.authUser = null;
|
188
|
-
AuthStore.state.isAuthenticated = false;
|
189
177
|
}
|
190
178
|
async getLocalAuthUser() {
|
191
179
|
return get(AppConsts.AUTH_USER_LOCALSTORAGE);
|
@@ -212,9 +200,9 @@ const Route = (_a) => {
|
|
212
200
|
const Component = component;
|
213
201
|
return (h("stencil-route", Object.assign({}, props, { routeRender: (props) => {
|
214
202
|
if (!AuthStore.state.isAuthenticated)
|
215
|
-
return
|
203
|
+
return h("stencil-router-redirect", { url: "/login" });
|
216
204
|
if (permission && !isGranted(permission)) {
|
217
|
-
return
|
205
|
+
return h("stencil-router-redirect", { url: "/unauthorized" });
|
218
206
|
}
|
219
207
|
return Component ? h(Component, Object.assign({}, props, props.componentProps)) : render(props);
|
220
208
|
} })));
|
@@ -1,13 +1,13 @@
|
|
1
|
-
import { H as HttpService } from './httpService-
|
1
|
+
import { H as HttpService } from './httpService-7986aeed.js';
|
2
2
|
import { d as createStore } from './auth.store-dba2c2da.js';
|
3
|
-
import { S as SparkleGlobal } from './util-
|
3
|
+
import { S as SparkleGlobal } from './util-57cc8006.js';
|
4
4
|
|
5
|
-
const { state
|
5
|
+
const { state, onChange } = createStore({
|
6
6
|
goals: [],
|
7
7
|
goalsLoading: false,
|
8
8
|
goalLoading: false
|
9
9
|
});
|
10
|
-
const goalStore = { state
|
10
|
+
const goalStore = { state, onChange };
|
11
11
|
|
12
12
|
class AppDataService {
|
13
13
|
constructor() { }
|
@@ -67,54 +67,4 @@ class AppDataService {
|
|
67
67
|
}
|
68
68
|
}
|
69
69
|
|
70
|
-
|
71
|
-
posts: [],
|
72
|
-
postsLoading: false,
|
73
|
-
createPostLoading: false,
|
74
|
-
postIdLoading: null
|
75
|
-
});
|
76
|
-
const feedStore = { state, reset };
|
77
|
-
|
78
|
-
class FeedService {
|
79
|
-
constructor() { }
|
80
|
-
static getInstance() {
|
81
|
-
if (!FeedService.instance) {
|
82
|
-
FeedService.instance = new FeedService();
|
83
|
-
}
|
84
|
-
return FeedService.instance;
|
85
|
-
}
|
86
|
-
async getAllPosts() {
|
87
|
-
feedStore.state.postsLoading = true;
|
88
|
-
let result = await HttpService.http.get(`api/v1/Feed/GetAll`);
|
89
|
-
if (result) {
|
90
|
-
feedStore.state.posts = result.Data;
|
91
|
-
feedStore.state.postsLoading = false;
|
92
|
-
}
|
93
|
-
return result;
|
94
|
-
}
|
95
|
-
async createPost(payload) {
|
96
|
-
feedStore.state.createPostLoading = true;
|
97
|
-
let result = await HttpService.http.post(`api/v1/Feed/PostFeed`, payload);
|
98
|
-
if (result) {
|
99
|
-
feedStore.state.posts = [result.Data, ...feedStore.state.posts];
|
100
|
-
feedStore.state.createPostLoading = false;
|
101
|
-
}
|
102
|
-
return result;
|
103
|
-
}
|
104
|
-
async createPostComment(payload) {
|
105
|
-
feedStore.state.postIdLoading = payload.PostId;
|
106
|
-
let result = await HttpService.http.post(`api/v1/Feed/Comment`, payload);
|
107
|
-
if (result) {
|
108
|
-
feedStore.state.posts = feedStore.state.posts.map((item) => {
|
109
|
-
if (item.Id == result.Data.ClassFeedPostId) {
|
110
|
-
return Object.assign(Object.assign({}, item), { Comments: [...item.Comments, result.Data] });
|
111
|
-
}
|
112
|
-
return item;
|
113
|
-
});
|
114
|
-
feedStore.state.postIdLoading = null;
|
115
|
-
}
|
116
|
-
return result;
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
export { AppDataService as A, FeedService as F, feedStore as f, goalStore as g };
|
70
|
+
export { AppDataService as A, goalStore as g };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { H as HttpService } from './httpService-7986aeed.js';
|
2
|
+
|
3
|
+
class AssignmentService {
|
4
|
+
constructor() { }
|
5
|
+
static getInstance() {
|
6
|
+
if (!AssignmentService.instance) {
|
7
|
+
AssignmentService.instance = new AssignmentService();
|
8
|
+
}
|
9
|
+
return AssignmentService.instance;
|
10
|
+
}
|
11
|
+
async createAssignment(payload) {
|
12
|
+
let result = await HttpService.http.post(`api/v1/Assignment/Create`, payload);
|
13
|
+
return result;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
export { AssignmentService as A };
|