Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI changes are done for bulk upload 1173 #477

Open
wants to merge 1 commit into
base: release-2.6.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,103 @@
</div>
</app-page-header>
<ion-content>
<div>
<ion-card class="session-sqr-card">
<ion-card-content class="card-content">
<div class="segment-button d-flex flex-justify-center flex-align-items-flex-end">
{{"START_CREATE_SESSION"|translate}}
<div class="d-flex flex-justify-center">
<ion-header>
<ion-segment (ionChange)="segmentChanged($event)" [value]="segmentType">
<ion-segment-button value="manage-session" class="normal-case">
<ion-label>{{ "CREATE_SESSIONS" | translate }}</ion-label>
</ion-segment-button>
<ion-segment-button value="bulk-upload" class="normal-case">
<ion-label>{{ "MANAGE_SESSION" | translate }}</ion-label>
</ion-segment-button>
</ion-segment>
</ion-header>
</div>
<div [ngSwitch]="segmentType">
<div>
<div *ngSwitchCase="'manage-session'">
<ion-card class="session-sqr-card">
<ion-card-content class="card-content">
<div
class="segment-button d-flex flex-justify-center flex-align-items-flex-end"
>
{{ "START_CREATE_SESSION" | translate }}
</div>
<ion-grid>
<ion-row class="d-flex flex-justify-center">
<ion-col
padding
size-xs="12"
size-sm="12"
size-md="8"
size-lg="6"
align-self-stretch
>
<ion-button
shape="round"
strong="true"
class="card-button"
(click)="createSession()"
>
{{ "CREATE_SESSION" | translate }}
<ion-icon
class="create-icon"
name="add-circle-outline"
></ion-icon>
</ion-button>
</ion-col>
</ion-row>
</ion-grid>
</ion-card-content>
</ion-card>
<div class="filter">
<p>{{ "FILTER" | translate }}</p>
<div class="circle-container" (click)="onClickFilter()">
<ion-icon class="ion-funnel-icon" name="funnel"></ion-icon>
</div>
<ion-grid>
<ion-row class="d-flex flex-justify-center">
<ion-col padding size-xs="12" size-sm="12" size-md="8" size-lg="6" align-self-stretch>
<ion-button shape="round" strong="true" class="card-button" (click)="createSession()">
{{'CREATE_SESSION' | translate}} <ion-icon class="create-icon" name="add-circle-outline"></ion-icon>
</ion-button>
</ion-col>
</ion-row>
</ion-grid>
</ion-card-content>
</ion-card>
</div>
<div class="filter">
<p>{{"FILTER"|translate}}</p>
<div class="circle-container" (click)="onClickFilter()">
<ion-icon class="ion-funnel-icon" name="funnel"></ion-icon>
</div>
<div *ngIf="tableData">
<app-generic-table
[headingText]="headingText"
[columnData]="columnData"
[noDataMessage]="noDataMessage"
[tableData]="tableData"
[totalCount]="totalCount"
(onClickEvent)="onCLickEvent($event)"
(paginatorChanged)="onPaginatorChange($event)"
(onSorting)="onSorting($event)"
[setPaginatorToFirstpage]="setPaginatorToFirstpage"
[showPaginator]="true"
>
<div class="download" (click)="onClickDownload()">
{{ download | translate }}
</div>
</app-generic-table>
</div>
</div>
<div *ngSwitchCase="'bulk-upload'" class="d-flex flex-justify-center flex-align-items-center">
<ion-grid>
<ion-row class="d-flex flex-justify-center">
<div class="ion-margin ion-padding">
<ion-button class="btn-width-200" (click)="downloadCSV()">{{
"DOWNLOAD_SAMPLE_CSV" | translate
}}</ion-button>
</div>
<div class="ion-margin ion-padding">
<ion-button class="btn-width-200" (click)="upload.click()">{{
"UPLOAD_CSV" | translate
}}</ion-button>
<input
type="file"
accept=".csv"
(change)="uploadCSV($event)"
hidden
#upload
/>
</div>
</ion-row>
</ion-grid>
</div>
</div>
</div>
</div>
<div *ngIf="tableData">
<app-generic-table [headingText]="headingText" [columnData]="columnData" [noDataMessage]="noDataMessage" [tableData]="tableData" [totalCount]="totalCount" (onClickEvent)='onCLickEvent($event)' (paginatorChanged)="onPaginatorChange($event)" (onSorting)="onSorting($event)" [setPaginatorToFirstpage]="setPaginatorToFirstpage" [showPaginator]="true">
<div class="download" (click)="onClickDownload()">{{ download | translate}}</div>
</app-generic-table>
</div>
</ion-content>
</ion-content>
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@
color: #6da6f2;
text-decoration: underline;
cursor: pointer;
}
.normal-case {
text-transform: none;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { AdminWorkapceService } from 'src/app/core/services/admin-workspace/admi
import { CommonRoutes } from 'src/global.routes';
import { ModalController } from '@ionic/angular';
import { FilterPopupComponent } from 'src/app/shared/components/filter-popup/filter-popup.component';
import { UtilService } from 'src/app/core/services';
import { HttpService, ToastService, UtilService } from 'src/app/core/services';
import { SessionService } from 'src/app/core/services/session/session.service';
import { MenteeListPopupComponent } from 'src/app/shared/components/mentee-list-popup/mentee-list-popup.component';
import * as moment from 'moment';
import { OrganisationService } from 'src/app/core/services/organisation/organisation.service';

@Component({
selector: 'app-manage-session',
Expand All @@ -24,7 +25,11 @@ export class ManageSessionComponent implements OnInit {
// label: 'MANAGE_SESSION'
};
receivedEventData: any;
constructor(private adminWorkapceService: AdminWorkapceService, private router: Router, private modalCtrl: ModalController,private utilService:UtilService, private sessionService:SessionService) { }
constructor(private adminWorkapceService: AdminWorkapceService, private router: Router, private modalCtrl: ModalController,private utilService:UtilService, private sessionService:SessionService,
private http: HttpService,
private toast: ToastService,
private organisation: OrganisationService,
) { }
headingText = "SESSION_LIST"
download = "DOWNLOAD";
page = 1;
Expand Down Expand Up @@ -91,6 +96,7 @@ export class ManageSessionComponent implements OnInit {
'LIVE': [{ icon: 'eye', cssColor: 'white-color' ,action:'VIEW'}, { icon: 'create', cssColor: 'white-color' ,action:'EDIT'}],
'COMPLETED': [{ icon: 'eye', cssColor: 'white-color' ,action:'VIEW'}]
};
segmentType = 'manage-session';

async ngOnInit() {
this.fetchSessionList()
Expand Down Expand Up @@ -209,4 +215,36 @@ export class ManageSessionComponent implements OnInit {
this.router.navigate([`${CommonRoutes.CREATE_SESSION}`]);
}

segmentChanged(event){
this.segmentType = event.target.value;
}

async downloadCSV(){
let config = {
url: urlConstants.API_URLS.ADMIN_DOWNLOAD_SAMPLE_CSV,
payload: {}
}
this.http.get(config).then(async (response)=>{
await this.sessionService.openBrowser(response.result,"_blank")
})
}

async uploadCSV(event){
let file= event.target.files[0];
if(file.type != 'text/csv'){
this.toast.showToast('PLEASE_UPLOAD_CSV_FILE', 'danger')
event.target.value='';
}else{
let signedUrl = await this.organisation.getSignedUrl(event.target.files[0].name)
this.organisation.upload(event.target.files[0], signedUrl).subscribe(async () => {
let data = await this.organisation.bulkUpload(signedUrl.filePath);
if(data){
this.toast.showToast(data.message, 'success');
event.target.value='';
}
(error) => event.target.value='';
})
}
}

}
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,6 @@
"LOGGED_OUT_AT": "Logged out at",
"EXPIRED": "Expired",
"GENERATE_OTP":"Generate OTP",
"VALIDATE_OTP": "Validate OTP"
"VALIDATE_OTP": "Validate OTP",
"CREATE_SESSIONS":"Create sessions"
}