Skip to content

Commit

Permalink
Fixes the delete of a project
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola74 committed Mar 31, 2020
1 parent 75dafa6 commit 3401c07
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 44 deletions.
71 changes: 44 additions & 27 deletions src/app/project-edit-add/project-edit-add.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<a> {{ "ProjectEditPage.Authentication" | translate }}</a>
</li>

<li *ngIf="isVisibleAdvancedTab" (click)="goToProjectSettings_Advanced()" class="btn-with-border-effect"
<li *ngIf="isVisibleAdvancedTab && DISPLAY_ADVANCED_TAB === true" (click)="goToProjectSettings_Advanced()" class="btn-with-border-effect"
[ngClass]="{ 'li-active' : PROJECT_SETTINGS_ADVANCED_ROUTE === true, 'border-from-center': PROJECT_SETTINGS_ADVANCED_ROUTE === false }">

<a> {{ "ProjectEditPage.Advanced" | translate }}</a>
Expand Down Expand Up @@ -858,7 +858,7 @@ <h3 class="card-title onoffswitch_container">

<div class="input-wrapper" style="max-width: 992px;"
[ngClass]="{'section-disabled' : reassignment_on === false}">

<div class="row">
<div class="col-sm-8">
<div class="alert"
Expand All @@ -885,8 +885,8 @@ <h3 class="card-title onoffswitch_container">
// -------------------------------------------------------- -->
<input type="number" [(ngModel)]="reassignment_delay"
(ngModelChange)="onChangeReassignment_timeout($event)" class="input" id="reassignment_timeout"
name="reassignment_timeout" min="1" max="10000000"
style="margin-bottom: 1px;" [disabled]="reassignment_on === false">
name="reassignment_timeout" min="1" max="10000000" style="margin-bottom: 1px;"
[disabled]="reassignment_on === false">

<div *ngIf="reassignment_timeout_has_minimum_error === true" class="error-message"
style="color: #f6303a;font-size: 14px">
Expand Down Expand Up @@ -928,8 +928,8 @@ <h3 class="card-title onoffswitch_container">
<div class="onoffswitch">
<input (change)="toggleUnavailable_status_on($event)"
[checked]="automatic_unavailable_status_on === true" type="checkbox"
name="unavailable_status_on_onoffswitch" class="onoffswitch-checkbox"
id="unavailable_status_on">
name="unavailable_status_on_onoffswitch" class="onoffswitch-checkbox" id="unavailable_status_on"
[disabled]="reassignment_on === false">
<label class="onoffswitch-label" for="unavailable_status_on">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
Expand All @@ -946,7 +946,7 @@ <h3 class="card-title onoffswitch_container">


<div class="input-wrapper" style="max-width: 992px;"
[ngClass]="{'section-disabled' : automatic_unavailable_status_on === false}">
[ngClass]="{'section-disabled' : automatic_unavailable_status_on === false || reassignment_on === false}">
<div class="row">
<div class="col-sm-8">
<div class="alert"
Expand Down Expand Up @@ -975,7 +975,7 @@ <h3 class="card-title onoffswitch_container">
(ngModelChange)="onChangeAutomaticUnavailable($event)" class="input" id="automatic_idle_chats"
name="automatic_idle_chats" style="margin-bottom: 1px;"
style="margin-bottom: 1px;max-width: 93px;"
[disabled]="automatic_unavailable_status_on === false">
[disabled]="automatic_unavailable_status_on === false || reassignment_on === false">

<div *ngIf="automatic_idle_chats_has_minimum_error === true" class="error-message"
style="color: #f6303a;font-size: 14px">
Expand Down Expand Up @@ -1033,8 +1033,8 @@ <h3 class="card-title onoffswitch_container">
<!-- ./ row -->
<div class="row" *ngIf="PROJECT_SETTINGS_ROUTE">

<div class="col-md-12" style="text-align: center; border-top: 1px solid #cccccc; margin-top:25px">
<div style="color:#aaaaaa; margin-top:25px; cursor:pointer" (click)="openDeleteModal()">
<div *ngIf="DISPLAY_DELETE_PRJCT_BTN === true" class="col-md-12" style="text-align: center; border-top: 1px solid #cccccc; margin-top:25px">
<div style="color: rgba(0, 0, 0, 0.54); margin-top:25px; cursor:pointer" (click)="openDeleteModal()">
<i class="material-icons" style="vertical-align: middle">delete_forever</i>
<span style="vertical-align: middle; text-transform: uppercase">
<!-- ELIMINA PROGETTO -->
Expand Down Expand Up @@ -1075,27 +1075,44 @@ <h4 class="modal-title" style="color: #fff; padding-top:10px; font-size: 1.1em "
{{ "ProjectEditPage.TheProjectWillBeDeleted" | translate }}
</h4>
</div>
<div class="modal-body">
<label style="font-weight:100; text-align: left; padding-bottom:12px" class="col-sm-10 ">
<!-- Per eliminare il progetto, digita l'ID del progetto: -->
{{ "ProjectEditPage.ToDeleteTheProject" | translate }}:
<span style="color:#212121">
<strong> {{ id_project }}</strong>
</span>
</label>
<div class="col-sm-10">
<!-- [(ngModel)]="project_name" -->
<input class="" type="text" placeholder="{{ 'ProjectEditPage.ProjectId' | translate }}">
</div>
<div class="modal-body" style="min-height: 135px;">

<span *ngIf="SHOW_CIRCULAR_SPINNER === true">
<div class="loader" style="top:25%">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="15" fill="none" stroke-width="2" stroke-miterlimit="10" />
</svg>

</div>
<p style="margin-top: 40px; text-align: center;">
{{ "FaqPage.Processing" | translate }}
</p>
</span>

<span *ngIf="SHOW_CIRCULAR_SPINNER === false">
<label style="font-weight:100; text-align: left; padding-bottom:12px" class="col-sm-10 ">
<!-- Per eliminare il progetto, digita l'ID del progetto: -->
{{ "ProjectEditPage.ToDeleteTheProject" | translate }}:
<span style="color:#212121">
<strong> {{ id_project }}</strong>
</span>
</label>
<div class="col-sm-10">

<input class="" [(ngModel)]="project_id_to_delete" (ngModelChange)="onProjectIdToDeleteChange($event)"
type="text" placeholder="{{ 'ProjectEditPage.ProjectId' | translate }}">
</div>

</span>
</div>
<div class="modal-footer" style="margin-top: 75px;">
<div class="modal-footer" style="">
<button class="btn btn-white" (click)="onCloseModal()" style="padding:12px 16px;">
<!-- Chiudi -->
{{ "ProjectEditPage.Calcel" | translate }}
</button>
<!-- (click)="createProject() -->
<button style="margin-top:0px" class="btn btn-danger" disabled>
<!-- Elimina Progetto -->

<button (click)="deleteProject()" style="margin-top:0px" class="btn btn-danger"
[disabled]="DISABLE_DELETE_PROJECT_BTN === true">

{{ "ProjectEditPage.DeleteProject" | translate }}
</button>
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/app/project-edit-add/project-edit-add.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ button.close {
right: 0px;
background-color: #4caf50;
}
.onoffswitch-checkbox:disabled + .onoffswitch-label .onoffswitch-switch {
background-color: #ddd;
}

.onoffswitch-checkbox:disabled + .onoffswitch-label .onoffswitch-inner::before {
color: #ddd;
}

.onoffswitch-checkbox:disabled + .onoffswitch-label .onoffswitch-inner::after {
color: #ddd;
}
// ./end SWITCH BTN

.card-section-title {
Expand Down
114 changes: 97 additions & 17 deletions src/app/project-edit-add/project-edit-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ import * as moment from 'moment';
import brand from 'assets/brand/brand.json';
import { environment } from './../../environments/environment';
import { AppConfigService } from '../services/app-config.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'

@Component({
selector: 'app-project-edit-add',
templateUrl: './project-edit-add.component.html',
styleUrls: ['./project-edit-add.component.scss']
})
export class ProjectEditAddComponent implements OnInit, OnDestroy {

private unsubscribe$: Subject<any> = new Subject<any>();
tparams = brand;
// public_Key = environment.t2y12PruGU9wUtEGzBJfolMIgK; // now get from appconfig
public_Key: string;
Expand All @@ -46,6 +50,7 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
sharedSecret: string;

DISABLE_UPDATE_BTN = true;
DISABLE_DELETE_PROJECT_BTN = true;
project: Project;

AUTO_SEND_TRANSCRIPT_IS_ON: boolean;
Expand Down Expand Up @@ -91,6 +96,8 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {

updateSuccessMsg: string;
updateErrorMsg: string;
deleteSuccessMsg: string;
deleteErrorMsg: string;

// maximum_chats_has_error = false;
// reassignment_timeout_has_error = false;
Expand All @@ -100,7 +107,7 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
reassignment_timeout_has_maximum__error = false;
automatic_idle_chats_has_minimum_error = false;
automatic_idle_chats_has_maximum__error = false;

chat_limit_on: boolean;

reassignment_on: boolean;
Expand All @@ -112,7 +119,11 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
is_disabled_reassignment_section: boolean;
is_disabled_unavailable_status_section: boolean;
notificationNothingToSave: string;

project_id_to_delete: string;
SHOW_CIRCULAR_SPINNER = false;
DISPLAY_DELETE_PRJCT_BTN: boolean;
DISPLAY_ADVANCED_TAB: boolean;

constructor(
private projectService: ProjectService,
private router: Router,
Expand Down Expand Up @@ -144,6 +155,26 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
this.getAllUsersOfCurrentProject();
this.getPendingInvitation();
this.translateNotificationMsgs();
this.getProjectUserRole()
}

getProjectUserRole() {
this.usersService.project_user_role_bs
.pipe(
takeUntil(this.unsubscribe$)
)
.subscribe((user_role) => {
console.log('PROJECT-EDIT-ADD USER ROLE ', user_role);
if (user_role) {
if (user_role === 'owner') {

this.DISPLAY_DELETE_PRJCT_BTN = true
} else {
this.DISPLAY_DELETE_PRJCT_BTN = false

}
}
});
}


Expand All @@ -154,17 +185,18 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {

this.updateSuccessMsg = translation.UpdateProjectSuccess;
this.updateErrorMsg = translation.UpdateProjectError;
this.deleteSuccessMsg = translation.DeleteProjectSuccess
this.deleteErrorMsg = translation.DeleteProjectError

});

this.translate.get('NotificationNothingToSave')
this.translate.get('NotificationNothingToSave')
.subscribe((translation: any) => {
console.log('PROJECT-EDIT-ADD translateNotificationMsgs text', translation)

this.notificationNothingToSave = translation;

});


});
}


Expand Down Expand Up @@ -441,6 +473,14 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
this.prjct_profile_name = projectProfileData.profile_name;
}


if (this.prjct_profile_type === 'free' && this.prjct_trial_expired === true || this.prjct_profile_type === 'payment' && this.subscription_is_active === false) {
this.DISPLAY_ADVANCED_TAB = false;
} else if (this.prjct_profile_type === 'free' && this.prjct_trial_expired === false || this.prjct_profile_type === 'payment' && this.subscription_is_active === true) {
this.DISPLAY_ADVANCED_TAB = true;
}


this.getSubscriptionPayments(projectProfileData.subscription_id)
// this.getSubscriptionByID(projectProfileData.subscription_id);
}
Expand Down Expand Up @@ -850,7 +890,6 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
// }

onProjectNameChange(event) {

console.log('ON PROJECT NAME CHANGE ', event);
console.log('ON PROJECT NAME TO UPDATE ', this.project_name);

Expand All @@ -862,6 +901,8 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
}
}



edit() {
console.log('PROJECT ID WHEN EDIT IS PRESSED ', this.id_project);
console.log('PROJECT NAME WHEN EDIT IS PRESSED ', this.projectName_toUpdate);
Expand Down Expand Up @@ -952,16 +993,16 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {


// if (this.chat_limit_on === true || this.reassignment_on === true || this.automatic_unavailable_status_on === true) {
this.projectService.updateAdvancedSettings(this.max_agent_served_chat, this.reassignment_delay, this.automatic_idle_chats, this.chat_limit_on, this.reassignment_on, this.automatic_unavailable_status_on)
.subscribe((prjct) => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS - RES ', prjct);
}, (error) => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS - ERROR ', error);
this.notify.showWidgetStyleUpdateNotification(this.updateErrorMsg, 4, 'report_problem');
}, () => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS * COMPLETE *');
this.notify.showWidgetStyleUpdateNotification(this.updateSuccessMsg, 2, 'done');
})
this.projectService.updateAdvancedSettings(this.max_agent_served_chat, this.reassignment_delay, this.automatic_idle_chats, this.chat_limit_on, this.reassignment_on, this.automatic_unavailable_status_on)
.subscribe((prjct) => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS - RES ', prjct);
}, (error) => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS - ERROR ', error);
this.notify.showWidgetStyleUpdateNotification(this.updateErrorMsg, 4, 'report_problem');
}, () => {
console.log('PRJCT-EDIT-ADD UPDATE ADVANCED SETTINGS * COMPLETE *');
this.notify.showWidgetStyleUpdateNotification(this.updateSuccessMsg, 2, 'done');
})
// } else {

// this.notify.showWidgetStyleUpdateNotification(this.notificationNothingToSave, 3, 'report_problem');
Expand Down Expand Up @@ -1074,6 +1115,45 @@ export class ProjectEditAddComponent implements OnInit, OnDestroy {
this.display = 'none';
}

onProjectIdToDeleteChange($event) {
console.log('ON PROJECT ID CHANGE ', $event);
console.log('PROJECT ID ', this.id_project);

if ($event === this.id_project) {
this.DISABLE_DELETE_PROJECT_BTN = false;

} else {
this.DISABLE_DELETE_PROJECT_BTN = true;
}
}

deleteProject() {
this.SHOW_CIRCULAR_SPINNER = true;
console.log('deleteProject ID PROJECT TO DELETE ', this.project_id_to_delete);
console.log('deleteProject ID PROJECT ', this.id_project);

this.projectService.deleteProject(this.id_project).subscribe((data) => {
console.log('deleteProject RES ', data);

},
(error) => {
this.SHOW_CIRCULAR_SPINNER = false;
console.log('deleteProject - ERROR ', error);
this.notify.showWidgetStyleUpdateNotification(this.deleteErrorMsg, 4, 'report_problem');
},
() => {
console.log('deleteProject * COMPLETE *');

setTimeout(() => {
this.SHOW_CIRCULAR_SPINNER = false;
this.notify.showNotificationChangeProject(this.deleteSuccessMsg, 2, 'done');
this.router.navigate(['/projects']);
}, 1500);
});
}



goToWidgetAuthenticationDocs() {
const url = 'https://docs.tiledesk.com/widget/auth'
window.open(url, '_blank');
Expand Down

0 comments on commit 3401c07

Please sign in to comment.