Commit a581a15f authored by cazenave's avatar cazenave
Browse files

fill form

parent 61cc1857
......@@ -128,5 +128,8 @@
}
}
},
"defaultProject": "register-front"
"defaultProject": "register-front",
"cli": {
"analytics": "a001f330-3ed0-419e-9239-ca8717d62470"
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -11,31 +11,30 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~8.2.14",
"@angular/cdk": "~8.2.3",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@angular/animations": "~9.1.11",
"@angular/cdk": "~9.2.4",
"@angular/common": "~9.1.11",
"@angular/compiler": "~9.1.11",
"@angular/core": "~9.1.11",
"@angular/forms": "~9.1.11",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.11",
"@angular/platform-browser-dynamic": "~9.1.11",
"@angular/router": "~9.1.11",
"file-saver": "^2.0.2",
"hammerjs": "^2.0.8",
"ngx-filesaver": "^9.0.0",
"rxjs": "~6.4.0",
"rxjs": "~6.5.5",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.25",
"@angular/cli": "~8.3.26",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@types/node": "~8.9.4",
"@angular-devkit/build-angular": "~0.900.1",
"@angular/cli": "^9.1.9",
"@angular/compiler-cli": "~9.1.11",
"@angular/language-service": "~9.1.11",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
......@@ -47,6 +46,6 @@
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
"typescript": "^3.6.4"
}
}
......@@ -10,8 +10,8 @@ import { MatMenuModule } from '@angular/material/menu';
import { MatDividerModule } from '@angular/material/divider';
import { MatCardModule } from '@angular/material/card';
import { MatInputModule } from '@angular/material/input';
import { MatDialogModule } from '@angular/material'
import { MatProgressSpinnerModule } from '@angular/material'
import { MatDialogModule } from '@angular/material/dialog';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { RepositoryComponent } from './repository/repository.component';
import { AccessapiComponent } from './accessapi/accessapi.component';
......
<mat-card class="example-card">
<mat-card-header>
<mat-card-title>Login</mat-card-title>
......
......@@ -8,7 +8,8 @@ import {Router} from '@angular/router';
})
export class LoginComponent implements OnInit {
constructor(private router: Router) { }
constructor(private router: Router) { }
username: string;
password: string;
......
......@@ -40,7 +40,8 @@ export class RepositoryComponent implements OnInit {
repositorytoyaml(buttonType) {
if (buttonType == 'submit') {
let data: string;
data ='\n\
data ='\
repository: \n\
title: '+ this.Form.value.reponame +' \n\
description: '+ this.Form.value.repodescription +' \n\
......@@ -53,26 +54,42 @@ repository: \n\
const fileName = `repository.yaml`;
const fileType = this._FileSaverService.genType(fileName);
const txtBlob = new Blob([data], { type: fileType });
this._FileSaverService.save(txtBlob, fileName);
}
if (buttonType == 'fill') {
const files = (event.target as HTMLInputElement).files;
if (files.length > 0) {
this.importFile = files[0];
/* lire le fichier ligne à ligne et remplir un array */
this.Form.setValue({
reponame: 'ça marche !',
repodescription: '',
repourl: '',
repoversion: '',
repolicence: '',
repolanguage: '',
filetofill: ''
});
}
const files = (event.target as HTMLInputElement).files;
this.importFile = files[0];
let text = "";
let lines = [];
let line = "";
let map = new Map();
let fileReader = new FileReader();
fileReader.onload = (event) => {
text = fileReader.result;
lines = text.split("\n");
for ( let i = 0; i < lines.length; i++) {
line = lines[i].split(": ");
map.set(line[0].trim(),line[1]);
}
this.Form.setValue({
reponame: map.get('title') ,
repodescription: map.get('description'),
repourl: map.get('url'),
repoversion: map.get('version'),
repolicence: map.get('licence'),
repolanguage: map.get('language'),
filetofill: ''
});
}
fileReader.readAsText(this.importFile);
}
}
......
import 'hammerjs';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment