diff --git a/Dockerfile b/Dockerfile index 6d48919c4..80348fb4e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ RUN npm install -g @ionic/cli@6.0.0 RUN rm -rf node_modules +RUN rm -rf www + COPY package*.json ./ RUN npm install --force diff --git a/forms.json b/forms.json index ca6169097..df038770f 100644 --- a/forms.json +++ b/forms.json @@ -2,7 +2,7 @@ { "type": "editProfile", "sub_type": "editProfileForm", - "action": "skip", + "action": "update", "data": { "templateName": "defaultTemplate", "fields": { @@ -459,40 +459,39 @@ "name": "competencies", "label": "Competencies", "class": "ion-no-margin", - "value": "", + "value": [], "type": "search", "position": "", "disabled": false, "errorMessage": { - "required": "Enter competencies" + "required": "Enter competencies" }, "validators": { - "required": true + "required": true }, - "options": [ - ], + "options": [], "meta": { - "entityType": "competencies", - "addNewPopupHeader": "Competencies", - "addNewPopupSubHeader": "Who is this session for?", - "showSelectAll": true, - "multiSelect": true, - "showAddOption": { - "showAddButton": true, - "addChipLabel": "" - }, - "allow_custom_entities": true, - "allow_filtering": true, - "addPopupType": "addCompetency" + "entityType": "competencies", + "addNewPopupHeader": "Competencies", + "addNewPopupSubHeader": "Who is this session for?", + "showSelectAll": true, + "multiSelect": true, + "showAddOption": { + "showAddButton": true, + "addChipLabel": "" + }, + "allow_custom_entities": true, + "allow_filtering": true, + "addPopupType": "addCompetency" }, "multiple": true - }, + }, { "name": "medium", - "label": "Select medium", + "label": "Medium", "alertLabel": "medium", "class": "ion-no-margin", - "value": "", + "value": [], "type": "search", "position": "", "disabled": false, @@ -502,11 +501,19 @@ "validators": { "required": true }, - "options": [], + "options": [ + { + "label": "English", + "value": "en_in" + }, + { + "label": "Hindi", + "value": "hi" + } + ], "meta": { "entityType": "medium", - "addNewPopupHeader": "Add new medium", - "addNewPopupSubHeader": "Medium for the session", + "addNewPopupHeader": "Add new language", "showSelectAll": true, "multiSelect": true, "showAddOption": { @@ -526,7 +533,7 @@ { "type": "managersSession", "sub_type": "managersSessionForm", - "action": "skip", + "action": "update", "data": { "template_name": "defaultTemplate", "fields": { @@ -672,7 +679,7 @@ "searchData": [], "maxCount": "MAX_MENTEE_ENROLLMENT_COUNT", "labelForListButton": "View Mentee List", - "labelForAddButton": "Add New Mentee", + "labelForAddButton": "Add Mentee", "filters": { "entity_types": [ { @@ -742,8 +749,8 @@ "name": "recommended_for", "label": "Recommended for", "class": "ion-no-margin", - "value": "", - "type": "chip", + "value": [], + "type": "search", "position": "", "disabled": false, "errorMessage": { @@ -790,8 +797,8 @@ "name": "categories", "label": "Categories", "class": "ion-no-margin", - "value": "", - "type": "chip", + "value": [], + "type": "search", "position": "", "disabled": false, "errorMessage": { @@ -838,8 +845,8 @@ "label": "Select medium", "alertLabel": "medium", "class": "ion-no-margin", - "value": "", - "type": "chip", + "value": [], + "type": "search", "position": "", "disabled": false, "errorMessage": { @@ -876,7 +883,7 @@ { "type": "helpApp", "sub_type": "helpAppForm", - "action": "skip", + "action": "update", "data": { "fields": { "forms": [ @@ -941,7 +948,7 @@ { "type": "mentorQuestionnaire", "sub_type": "mentorQuestionnaireForm", - "action": "skip", + "action": "update", "data": { "templateName": "defaultTemplate", "fields": { @@ -1040,5 +1047,102 @@ ] } } + }, + { + "type": "dashboard", + "sub_type": "dashboardForm", + "action": "create", + "data": { + "template_name": "defaultTemplate", + "fields": { + "mentor": [ + { + "type": "bar", + "data": { + "labels": [ + "Total sessions created", + "Total sessions conducted" + ], + "datasets": [ + { + "label": "", + "data": [ + "total_session_created", + "total_session_hosted" + ], + "backgroundColor": [ + "#4e81bd", + "#fdc107", + "#5ab251" + ], + "borderWidth": 1, + "barThickness": 50 + } + ] + }, + "options": { + "responsive": true, + "maintainAspectRatio": false, + "plugins": { + "legend": { + "display": false + } + }, + "scales": { + "y": { + "ticks": { + "stepSize": 0 + }, + "grid": { + "display": false + } + }, + "x": { + "grid": { + "display": false + } + } + } + } + } + ], + "mentee": [ + { + "type": "pie", + "data": { + "labels": [ + "Total sessions enrolled", + "Total sessions attended" + ], + "datasets": [ + { + "label": "", + "data": [ + "total_session_enrolled", + "total_session_attended" + ], + "backgroundColor": [ + "#ffdf00", + "#7b7b7b" + ], + "borderWidth": 1, + "barThickness": 50 + } + ] + }, + "options": { + "responsive": true, + "maintainAspectRatio": false, + "plugins": { + "legend": { + "display": false + } + }, + "scales": {} + } + } + ] + } + } } ] diff --git a/formsManager.js b/formsManager.js index e0790225a..d1617ee9b 100644 --- a/formsManager.js +++ b/formsManager.js @@ -5,6 +5,10 @@ const path = require("path"); const authToken = process.env.AUTH_TOKEN; const apiUrl = process.env.API_URL; +const authorization = process.env.AUTHORIZATION; +const adminAuthToken = process.env.ADMIN_AUTH_TOKEN; +const organizationId = process.env.ORGANIZATION_ID; + const args = process.argv.slice(2); const actionsApplicable = ["skip", "update","create"] @@ -17,7 +21,7 @@ const createForm = async (form) => { const response = await axios.post( `${apiUrl}/mentoring/v1/form/create`, form, - { headers: { 'X-auth-token': `bearer ${authToken}` } } + { headers: { 'x-authenticated-user-token': `${authToken}`, 'Authorization': `bearer ${authorization}`, 'admin-auth-token': `${adminAuthToken}`, 'organization-id': `${organizationId}` } } ); if(response){ console.log("Form created successfully:", response.data); @@ -33,7 +37,7 @@ const updateForm = async (form) => { const response = await axios.put( `${apiUrl}/mentoring/v1/form/update`, form, - { headers: { 'X-auth-token': `bearer ${authToken}` } } + { headers: { 'x-authenticated-user-token': `${authToken}`, 'Authorization': `bearer ${authorization}`, 'admin-auth-token': `${adminAuthToken}`, 'organization-id': `${organizationId}` } } ); if(response){ console.log("Form updated successfully:", response.data); @@ -82,4 +86,4 @@ const createOrUpdateForms = async () => { saveFormsToFile(); }; -createOrUpdateForms(); \ No newline at end of file +createOrUpdateForms(); diff --git a/src/app/core/constants/formConstant.ts b/src/app/core/constants/formConstant.ts index 874d57d6c..e8aa650dc 100644 --- a/src/app/core/constants/formConstant.ts +++ b/src/app/core/constants/formConstant.ts @@ -48,4 +48,9 @@ export const SAMPLE_CSV_DOWNLOAD_URL = { export const MANAGERS_CREATE_SESSION_FORM: IFORM = { "type": "managersSession", "sub_type": "managersSessionForm", +} + +export const DASHBOARD: IFORM = { + "type": "dashboard", + "sub_type": "dashboardForm", } \ No newline at end of file diff --git a/src/app/core/services/auth/auth.service.ts b/src/app/core/services/auth/auth.service.ts index e97fd27ad..dc9583408 100644 --- a/src/app/core/services/auth/auth.service.ts +++ b/src/app/core/services/auth/auth.service.ts @@ -149,9 +149,9 @@ export class AuthService { await this.db.clear() this.userService.token = null; this.userService.userEvent.next(null); - this.router.navigate([environment.unauthorizedRedirectUrl], { + this.router.navigate([window['env']['unauthorizedRedirectUrl']], { replaceUrl: true }); this.translate.use("en") } -} \ No newline at end of file +} diff --git a/src/app/core/services/form/form.service.ts b/src/app/core/services/form/form.service.ts index aaced72fe..e15c4e829 100644 --- a/src/app/core/services/form/form.service.ts +++ b/src/app/core/services/form/form.service.ts @@ -83,7 +83,7 @@ export class FormService { await entityList.map((entityName)=>{ if(Array.isArray(existingData[entityName])){ existingData[entityName] = existingData[entityName].map((data)=>{ - return { label : data.label, value : data.value == 'other' ? data.label : data.value } + return { label : data.label, value : data.value == 'other' ? data.label : data.value, type: data.value } }) } }) diff --git a/src/app/core/services/http/http.service.ts b/src/app/core/services/http/http.service.ts index 7d2ea6b01..0f19fe4da 100644 --- a/src/app/core/services/http/http.service.ts +++ b/src/app/core/services/http/http.service.ts @@ -13,6 +13,7 @@ import { AlertController, ModalController } from '@ionic/angular'; import { FeedbackPage } from 'src/app/pages/feedback/feedback.page'; import { CapacitorHttp } from '@capacitor/core'; import { TranslateService } from '@ngx-translate/core'; +import { Router } from '@angular/router'; @Injectable({ @@ -28,7 +29,6 @@ export class HttpService { private userService: UserService, private network: NetworkService, private toastService: ToastService, - private loaderService: LoaderService, private localStorage: LocalStorageService, private injector: Injector, private modalController: ModalController, @@ -57,7 +57,6 @@ export class HttpService { headers[key] = this.extraHeaders[key]; }); } - console.log(JSON.stringify(headers)) return headers; } @@ -211,6 +210,10 @@ export class HttpService { } public handleError(result) { + console.log(result) + if(result.data.responseCode == 'UNAUTHORIZED') { + this.triggerLogoutConfirmationAlert(result) + } let msg = result.data.message; switch (result.status) { case 400: @@ -220,8 +223,9 @@ export class HttpService { this.toastService.showToast(msg ? msg : 'SOMETHING_WENT_WRONG', 'danger') break case 401: + case 419: + case 302: this.triggerLogoutConfirmationAlert(result) - break default: this.toastService.showToast(msg ? msg : 'SOMETHING_WENT_WRONG', 'danger') @@ -255,7 +259,7 @@ export class HttpService { }); this.isAlertOpen = true; const alert = await this.alert.create({ - message: msg, + message: msg || 'Session expired. Please login again', buttons: [ { text: texts['OK'], @@ -271,8 +275,14 @@ export class HttpService { await alert.present(); let data = await alert.onDidDismiss(); if (data.role == 'cancel') { - let auth = this.injector.get(AuthService); - auth.logoutAccount(true); + if(window['env']['isAuthBypassed']) { + let auth = this.injector.get(AuthService); + auth.clearLocalData(); + location.href = window['env']['unauthorizedRedirectUrl'] + } else { + let auth = this.injector.get(AuthService); + auth.logoutAccount(true); + } } return false; } else { diff --git a/src/app/core/services/profile/profile.service.ts b/src/app/core/services/profile/profile.service.ts index 634ff0f3b..a8a5c2bc6 100644 --- a/src/app/core/services/profile/profile.service.ts +++ b/src/app/core/services/profile/profile.service.ts @@ -232,6 +232,7 @@ export class ProfileService { } catch (error) { showLoader ? await this.loaderService.stopLoader() : ''; + return error } } diff --git a/src/app/modules/admin/components/manage-session/manage-session.component.html b/src/app/modules/admin/components/manage-session/manage-session.component.html index 1c8e6ccfe..380b911b8 100644 --- a/src/app/modules/admin/components/manage-session/manage-session.component.html +++ b/src/app/modules/admin/components/manage-session/manage-session.component.html @@ -42,7 +42,7 @@ -
+
- +