Export DataSet to GoogleSheet
This commit is contained in:
@@ -7,7 +7,7 @@ import { DataRow } from './dataRow.model copy';
|
||||
|
||||
export class DataSet extends Base {
|
||||
number?: Number;
|
||||
source?: string;
|
||||
source?: string;
|
||||
name?: string;
|
||||
dataRows: DataRow[] = [];
|
||||
|
||||
@@ -15,7 +15,7 @@ export class DataSet extends Base {
|
||||
super();
|
||||
Object.assign(this, data);
|
||||
}
|
||||
override deserialize(input: any): this {
|
||||
override deserialize(input: any): this {
|
||||
Object.assign(this, Object.assign(this, super.deserialize(input)));
|
||||
if (this.dataRows) { this.dataRows = this.dataRows.map(x => new DataRow().deserialize(x)); }
|
||||
return this;
|
||||
@@ -34,7 +34,7 @@ export class DataSet extends Base {
|
||||
modifiedAt: '',
|
||||
createdBy: '',
|
||||
modifiedBy: '',
|
||||
});
|
||||
});
|
||||
}
|
||||
fillForm(form: UntypedFormGroup) {
|
||||
form.patchValue(this);
|
||||
@@ -53,21 +53,21 @@ export class DataSet extends Base {
|
||||
//API Actions
|
||||
static add(input: DataSet, _http: HttpClient): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.post<string>(`${environment.api.url}/datasets`, {...input.serialize(), }).subscribe({
|
||||
_http.post<string>(`${environment.api.url}/datasets`, { ...input.serialize(), }).subscribe({
|
||||
next: (data) => resolve(data),
|
||||
error: (e) => reject(e)
|
||||
}
|
||||
error: (e) => reject(e)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
static getList(_http: HttpClient): any {
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.get<DataSet[]>(`${environment.api.url}/datasets`)
|
||||
.pipe(map(data => data.map(x => new DataSet().deserialize(x))))
|
||||
.subscribe({
|
||||
next: (data) => resolve(data),
|
||||
error: (e) => reject(e)
|
||||
})
|
||||
.pipe(map(data => data.map(x => new DataSet().deserialize(x))))
|
||||
.subscribe({
|
||||
next: (data) => resolve(data),
|
||||
error: (e) => reject(e)
|
||||
})
|
||||
});
|
||||
}
|
||||
static getById(id: string, _http: HttpClient): Promise<DataSet> {
|
||||
@@ -83,20 +83,31 @@ export class DataSet extends Base {
|
||||
formData.append(file.name, file);
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.post<DataRow[]>(`${environment.api.url}/datasets/parseFile`, formData,
|
||||
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
resolve(data);
|
||||
},
|
||||
error: (e) => reject(e)
|
||||
})
|
||||
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
resolve(data);
|
||||
},
|
||||
error: (e) => reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise<DataRow[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.get<DataRow[]>(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`,
|
||||
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
|
||||
.subscribe({
|
||||
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
|
||||
.subscribe({
|
||||
next: (data) => {
|
||||
resolve(data);
|
||||
},
|
||||
error: (e) => reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
static exportToGoogleSheet(id: string, _http: HttpClient): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
_http.get<boolean>(`${environment.api.url}/datasets/exportToGoogleSheet/${id}`,
|
||||
).subscribe({
|
||||
next: (data) => {
|
||||
resolve(data);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user