Skip to content

Commit

Permalink
feat: import data
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh-Umachagi committed Aug 15, 2020
1 parent 4831a66 commit 6d5c4a0
Show file tree
Hide file tree
Showing 9 changed files with 1,020 additions and 104 deletions.
44 changes: 25 additions & 19 deletions apps/api/src/app/export_import/import/import-all.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {
Controller,
HttpStatus,
Get,
// Post,
// UseInterceptors,
// UploadedFiles,
Injectable
Post,
UseInterceptors,
Injectable,
Body
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { OnDestroy } from '@angular/core';
// import { FilesInterceptor } from '@nestjs/platform-express';
// import { diskStorage } from 'multer';
import { FilesInterceptor } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { ImportAllService } from '.';

@Injectable()
Expand All @@ -19,7 +19,6 @@ import { ImportAllService } from '.';
export class ImportAllController implements OnDestroy {
constructor(private importAllService: ImportAllService) {}

@ApiTags('Import')
@ApiOperation({ summary: 'Find all exports.' })
@ApiResponse({
status: HttpStatus.OK,
Expand All @@ -31,18 +30,25 @@ export class ImportAllController implements OnDestroy {
})
@Get()
async importAll() {}
// @Post()
// @UseInterceptors(
// FilesInterceptor('file', 1, {
// storage: diskStorage({
// destination: './import',
// filename: (rq, file, cb) => {
// cb(null, 'export.zip');
// }
// })
// })
// )
// async uploadFile(@UploadedFiles() file) {}

@UseInterceptors(
FilesInterceptor('file', 1, {
storage: diskStorage({
destination: './import',
filename: (rq, file, cb) => {
cb(null, 'import.zip');
}
})
})
)
@Post()
async parse(@Body() { importType }) {
this.importAllService.removeExtractedFiles();

this.importAllService.unzipAndParse(importType === 'clean');

return;
}

ngOnDestroy() {}
}
217 changes: 214 additions & 3 deletions apps/api/src/app/export_import/import/import-all.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,226 @@
import { Module } from '@nestjs/common';
import { CqrsModule } from '@nestjs/cqrs';
import { ImportAllController } from './import-all.controller';
import { ImportAllService } from '.';
import { ImportAllService } from './import-all.service';
import { MulterModule } from '@nestjs/platform-express';

import { Country } from '../../country/country.entity';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Tag } from '../../tags/tag.entity';
import { User } from '../../user/user.entity';
import { UserOrganization } from '../../user-organization/user-organization.entity';
import { Activity } from '../../timesheet/activity.entity';
import { ApprovalPolicy } from '../../approval-policy/approval-policy.entity';
import { AvailabilitySlots } from '../../availability-slots/availability-slots.entity';
import { Candidate } from '../../candidate/candidate.entity';
import { CandidateDocument } from '../../candidate-documents/candidate-documents.entity';
import { CandidateEducation } from '../../candidate-education/candidate-education.entity';
import { CandidateExperience } from '../../candidate-experience/candidate-experience.entity';
import { CandidateFeedback } from '../../candidate-feedbacks/candidate-feedbacks.entity';
import { CandidateInterview } from '../../candidate-interview/candidate-interview.entity';
import { CandidateInterviewers } from '../../candidate-interviewers/candidate-interviewers.entity';
import { CandidatePersonalQualities } from '../../candidate-personal-qualities/candidate-personal-qualities.entity';
import { CandidateSkill } from '../../candidate-skill/candidate-skill.entity';
import { CandidateSource } from '../../candidate-source/candidate-source.entity';
import { CandidateTechnologies } from '../../candidate-technologies/candidate-technologies.entity';
import { Deal } from '../../deal/deal.entity';
import { EmailTemplate } from '../../email-template';
import { Email } from '../../email';
import { Employee } from '../../employee/employee.entity';
import { Equipment } from '../../equipment/equipment.entity';
import { ExpenseCategory } from '../../expense-categories/expense-category.entity';
import { GoalKPI } from '../../goal-kpi/goal-kpi.entity';
import { Expense } from '../../expense/expense.entity';
import { GoalTimeFrame } from '../../goal-time-frame/goal-time-frame.entity';
import { Goal } from '../../goal/goal.entity';
import { IntegrationTenant } from '../../integration-tenant/integration-tenant.entity';
import { InvoiceItem } from '../../invoice-item/invoice-item.entity';
import { Invoice } from '../../invoice/invoice.entity';
import { KeyResult } from '../../keyresult/keyresult.entity';
import { Language } from '../../language/language.entity';
import { OrganizationContact } from '../../organization-contact/organization-contact.entity';
import { OrganizationDepartment } from '../../organization-department/organization-department.entity';
import { OrganizationDocuments } from '../../organization-documents/organization-documents.entity';
import { OrganizationEmploymentType } from '../../organization-employment-type/organization-employment-type.entity';
import { OrganizationPositions } from '../../organization-positions/organization-positions.entity';
import { OrganizationProjects } from '../../organization-projects/organization-projects.entity';
import { OrganizationTeam } from '../../organization-team/organization-team.entity';
import { OrganizationTeamEmployee } from '../../organization-team-employee/organization-team-employee.entity';
import { OrganizationVendor } from '../../organization-vendors/organization-vendors.entity';
import { Organization } from '../../organization/organization.entity';
import { Pipeline } from '../../pipeline/pipeline.entity';
import { ProductCategory } from '../../product-category/product-category.entity';
import { ProductOption } from '../../product-option/product-option.entity';
import { ProductVariantSettings } from '../../product-settings/product-settings.entity';
import { ProductType } from '../../product-type/product-type.entity';
import { ProductVariantPrice } from '../../product-variant-price/product-variant-price.entity';
import { ProductVariant } from '../../product-variant/product-variant.entity';
import { Product } from '../../product/product.entity';
import { RequestApproval } from '../../request-approval/request-approval.entity';
import { RolePermissions } from '../../role-permissions/role-permissions.entity';
import { Role } from '../../role/role.entity';
import { Skill } from '../../skills/skill.entity';
import { Tenant } from '../../tenant/tenant.entity';
import { TimeLog } from '../../timesheet/time-log.entity';
import { TimeSlot } from '../../timesheet/time-slot.entity';
import { TimeOffPolicy } from '../../time-off-policy/time-off-policy.entity';
import { Timesheet } from '../../timesheet/timesheet.entity';
import { TimeOffRequest } from '../../time-off-request/time-off-request.entity';
import { Income } from '../../income/income.entity';
import { Integration } from '../../integration/integration.entity';
import { Invite } from '../../invite/invite.entity';
import { AppointmentEmployees } from '../../appointment-employees/appointment-employees.entity';
import { CandidateCriterionsRating } from '../../candidate-criterions-rating/candidate-criterion-rating.entity';
import { Contact } from '../../contact/contact.entity';
import { EmployeeAppointment } from '../../employee-appointment';
import { EmployeeLevel } from '../../organization_employeeLevel/organization-employee-level.entity';
import { EmployeeRecurringExpense } from '../../employee-recurring-expense/employee-recurring-expense.entity';
import { EmployeeSetting } from '../../employee-setting/employee-setting.entity';
import { EquipmentSharing } from '../../equipment-sharing';
import { HelpCenter } from '../../help-center/help-center.entity';
import { HelpCenterAuthor } from '../../help-center-author/help-center-author.entity';
import { HelpCenterArticle } from '../../help-center-article/help-center-article.entity';
import { IntegrationSetting } from '../../integration-setting/integration-setting.entity';
import { IntegrationMap } from '../../integration-map/integration-map.entity';
import { IntegrationEntitySettingTiedEntity } from '../../integration-entity-setting-tied-entity/integration-entity-setting-tied-entitiy.entity';
import { IntegrationEntitySetting } from '../../integration-entity-setting/integration-entity-setting.entity';
import { KeyResultUpdate } from '../../keyresult-update/keyresult-update.entity';
import { OrganizationAwards } from '../../organization-awards/organization-awards.entity';
import { OrganizationLanguages } from '../../organization-languages/organization-languages.entity';
import { OrganizationRecurringExpense } from '../../organization-recurring-expense/organization-recurring-expense.entity';
import { OrganizationSprint } from '../../organization-sprint/organization-sprint.entity';
import { Payment } from '../../payment/payment.entity';
import { Proposal } from '../../proposal/proposal.entity';
import { RequestApprovalEmployee } from '../../request-approval-employee/request-approval-employee.entity';
import { RequestApprovalTeam } from '../../request-approval-team/request-approval-team.entity';
import { Screenshot } from '../../timesheet/screenshot.entity';
import { Task } from '../../tasks/task.entity';
import { TimeSlotMinute } from '../../timesheet/time-slot-minute.entity';
import { EquipmentSharingPolicy } from '../../equipment-sharing-policy/equipment-sharing-policy.entity';
import { EstimateEmail } from '../../estimate-email/estimate-email.entity';
import { EventType } from '../../event-types/event-type.entity';
import { GoalGeneralSetting } from '../../goal-general-setting/goal-general-setting.entity';
import { PipelineStage } from '../../pipeline-stage/pipeline-stage.entity';
@Module({
imports: [
CqrsModule,
MulterModule.register({
dest: './import'
})
}),

TypeOrmModule.forFeature([
Activity,
AppointmentEmployees,
ApprovalPolicy,
AvailabilitySlots,

Candidate,
CandidateDocument,
CandidateEducation,
CandidateExperience,
CandidateExperience,
CandidateFeedback,
CandidateInterview,
CandidateInterviewers,
CandidatePersonalQualities,
CandidateCriterionsRating,
CandidateSkill,
CandidateSource,
CandidateTechnologies,
Contact,
Country,

Deal,

EstimateEmail,
EmailTemplate,
Email,
Employee,
EmployeeAppointment,
EmployeeLevel,
EmployeeRecurringExpense,
EmployeeSetting,
Equipment,
EquipmentSharing,
EquipmentSharingPolicy,
ExpenseCategory,
Expense,
EventType,

GoalGeneralSetting,
GoalKPI,
GoalTimeFrame,
Goal,

HelpCenter,
HelpCenterArticle,
HelpCenterAuthor,

Income,
Integration,
IntegrationTenant,
IntegrationSetting,
IntegrationMap,
IntegrationEntitySetting,
IntegrationEntitySettingTiedEntity,
Invite,
InvoiceItem,
Invoice,

KeyResult,
KeyResultUpdate,

Language,

OrganizationAwards,
OrganizationContact,
OrganizationDepartment,
OrganizationDocuments,
OrganizationEmploymentType,
OrganizationLanguages,
OrganizationPositions,
OrganizationProjects,
OrganizationRecurringExpense,
OrganizationSprint,
OrganizationTeam,
OrganizationTeamEmployee,
OrganizationVendor,
Organization,

Payment,
Pipeline,
PipelineStage,
ProductCategory,
ProductOption,
ProductVariantSettings,
ProductType,
ProductVariantPrice,
ProductVariant,
Product,
Proposal,

RequestApproval,
RequestApprovalEmployee,
RequestApprovalTeam,
Role,
RolePermissions,

Screenshot,
Skill,

Tag,
Task,
Tenant,
TimeLog,
TimeSlot,
TimeOffPolicy,
TimeOffRequest,
Timesheet,
TimeLog,
TimeSlotMinute,

User,
UserOrganization
])
],
controllers: [ImportAllController],
providers: [ImportAllService],
Expand Down
Loading

0 comments on commit 6d5c4a0

Please sign in to comment.