DataSet - createdBy & createdAt

This commit is contained in:
2022-12-27 22:22:21 +01:00
parent 360928b928
commit 149734cb19
10 changed files with 82 additions and 72 deletions

View File

@@ -19,8 +19,8 @@ export class Base implements Deserializable, Serializable {
}
deserialize(input: any): this {
if (input.createdAt) { input.createdAt = moment(input.createdAt); }
if (input.modifiedAt) { input.modifiedAt = moment(input.modifiedAt); }
if (input.createdAt) { input.createdAt = moment(input.createdAt).utc(true); }
if (input.modifiedAt) { input.modifiedAt = moment(input.modifiedAt).utc(true); }
if (input.createdBy) { input.createdBy = new User(input.createdBy); }
if (input.modifiedBy) { input.modifiedBy = new User(input.modifiedBy); }
Object.assign(this, input);

View File

@@ -10,6 +10,7 @@ export class DataSet extends Base {
source?: string;
name?: string;
dataRows: DataRow[] = [];
created?: string;
constructor(data: Partial<DataSet> = {}) {
super();
@@ -34,6 +35,8 @@ export class DataSet extends Base {
modifiedAt: '',
createdBy: '',
modifiedBy: '',
modified: '',
created: ''
});
}
fillForm(form: UntypedFormGroup) {
@@ -92,10 +95,12 @@ export class DataSet extends Base {
})
})
}
static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise<DataRow[]> {
static parseGoogleSheet(sheetId: string, _http: HttpClient): Promise<any> {
return new Promise((resolve, reject) => {
_http.get<DataRow[]>(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`,
).pipe(map(data => data.map(x => new DataRow().deserialize(x))))
_http.get<any>(`${environment.api.url}/datasets/parseGoogleSheet/${sheetId}`,
).pipe(map(data => {
data.dataRows = data.dataRows.map((x: any) => new DataRow().deserialize(x))
}))
.subscribe({
next: (data) => {
resolve(data);