Template interface Function modification 20/90220/2
authorcyuamber <xuranyjy@chinamobile.com>
Thu, 20 Jun 2019 08:40:14 +0000 (16:40 +0800)
committerxu ran <xuranyjy@chinamobile.com>
Thu, 20 Jun 2019 10:02:27 +0000 (10:02 +0000)
Change-Id: If9b5190f3a261084f34978db192faa68b6a6f19d
Issue-ID: DCAEGEN2-1625
Signed-off-by: cyuamber <xuranyjy@chinamobile.com>
components/datalake-handler/admin/src/src/app/core/models/template.model.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/edit-template-modal/edit-template-modal.component.css
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/edit-template-modal/edit-template-modal.component.html
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/edit-template-modal/edit-template-modal.component.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/new-template-modal/new-template-modal.component.css
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/new-template-modal/new-template-modal.component.html
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/new-template-modal/new-template-modal.component.ts
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/template-list.component.html
components/datalake-handler/admin/src/src/app/dashboard-setting/template/template-list/template-list.component.ts

index 5342d70..0586cd8 100644 (file)
@@ -39,6 +39,7 @@ export class Template {
     note:string;
     topic: string;
     designType: string;
+    display:string;
   }
 
 export class newTemplate {
@@ -48,4 +49,5 @@ export class newTemplate {
   note:string;
   topic: string;
   designType: string;
+  display:string;
 }
index 4e5a4bb..a7657cf 100644 (file)
 
         <div class="form-group">
           <div class="row">
-            <div class="col-md-3">
+            <div class="col-md-2">
               <label class="dl-emphasis1" for="inputtemplateName">{{ 'TEMPLATE_NAME' | translate }}</label>
             </div>
-            <div class="col-md-5">
+            <div class="col-md-6">
               <input  #inputtemplateName [(ngModel)]="this.templateInput.name" class="form-control dl-input-text" type="text" placeholder="Username" />
             </div>
           </div>
 
         <div class="form-group">
             <div class="row">
-              <div class="col-md-3">
+              <div class="col-md-2">
                 <label class="dl-emphasis1" for="templatebody">{{ 'TEMPLATE_BODY'| translate }}</label>
               </div>
-              <div class="col-md-9">
+              <div class="col-md-10">
                   <textarea #templatebody [(ngModel)]="this.templateInput.body"  class="form-control dl-input-text" placeholder="Put the template design here..." rows="3" style="min-height: 300px!important;"></textarea>
               </div>
             </div>
 
         <div class="form-group">
           <div class="row">
-            <div class="col-md-3">
+            <div class="col-md-2">
+              <label class="dl-emphasis1" style="line-height: 2.25rem">{{ 'FIELUPLOAD' | translate }}</label>
+            </div>
+            <div class="col-md-2 p-1" style="position: relative;
+    margin-left: 0.5rem;">
+              <input type="file" id="f-file" (change)="this.jsReadFiles()" />
+              <label for="f-file" style="height: 100%;width: 100%;">
+                <button type="button" class="btn dl-btn-dark btn-block" style="cursor: pointer">
+                  {{ 'FIELUPLOAD' | translate }}
+                </button>
+              </label>
+            </div>
+            <div class="col-md-2">
+              <span style="line-height: 2.25rem">{{this.fileName}}</span>
+            </div>
+          </div>
+        </div>
+
+        <div class="form-group">
+          <div class="row">
+            <div class="col-md-2">
               <label class="dl-emphasis1">{{ 'TEMPLATE_TYPE' | translate }}</label>
             </div>
-            <div class="col-md-7">
+            <div class="col-md-8">
               <select #templatetype class="custom-select dl-input-text" id="selDataFormat">
-                <option *ngFor="let item of templatetypedata" [selected]="item == this.templateInput.designType">{{item}}</option>
+                <option *ngFor="let item of templatetypedata" [selected]="item.display == this.templateInput.display">{{item.display}}</option>
               </select>
             </div>
           </div>
 
         <div class="form-group">
             <div class="row">
-              <div class="col-md-3">
+              <div class="col-md-2">
                 <label class="dl-emphasis1">{{ 'TOPICS_NAME' | translate }}</label>
               </div>
-              <div class="col-md-7">
+              <div class="col-md-8">
                 <select #topic class="custom-select dl-input-text" id="selDataFormat">
                   <option *ngFor="let item of topicname" [selected]="item == this.templateInput.topic">{{item}}</option>
                 </select>
index 9ce648b..5834d2b 100644 (file)
@@ -52,6 +52,7 @@ export class EditTemplateModalComponent implements OnInit {
 
   inputtemplateName = null;
   templateInputTitle = "";
+  fileName = null;
 
   ngOnInit() {
     this.getTopicName();
@@ -65,7 +66,8 @@ export class EditTemplateModalComponent implements OnInit {
       body: this.edittemplate.body,
       note: this.edittemplate.note,
       topic: this.edittemplate.topic,
-      designType: this.edittemplate.designType
+      designType:  this.edittemplate.designType,
+      display: this.edittemplate.display
     };
     this.templateInput = feed;
     this.templateInputTitle = ""+this.edittemplate.name;
@@ -83,12 +85,28 @@ export class EditTemplateModalComponent implements OnInit {
     });
   }
 
+  jsReadFiles(){
+    var thiss =this;
+    var file = (<HTMLInputElement>document.querySelector("#f-file")).files[0];
+    this.fileName = file.name;
+    var reader = new FileReader();
+    reader.onload = function() {
+      console.log(this.result);
+      thiss.templateInput.body = String(this.result);
+    }
+    reader.readAsText(file);
+  }
+
   passBack() {
     if(this.templateInput.name == '' || this.templateInput.name == undefined){
       return false;
     }
+    console.log(this.templateInput);
     this.edittemplate = this.templateInput;
-    this.edittemplate.designType = this.templatetype.nativeElement.value;
+    this.edittemplate.display = this.templatetype.nativeElement.value;
+    this.edittemplate.designType = this.templatetypedata.find((item) => {
+      return item.display == this.edittemplate.display
+    }).designType;
     this.edittemplate.topic = this.topic.nativeElement.value;
     this.passEntry.emit(this.edittemplate);
   }
index 9d01765..4024c56 100644 (file)
 
       <div class="form-group">
         <div class="row">
-          <div class="col-md-3">
+          <div class="col-md-2">
             <label class="dl-emphasis1" for="inputtemplateName">{{ 'TEMPLATE_NAME' | translate }}</label>
           </div>
-          <div class="col-md-5">
+          <div class="col-md-6">
             <input #inputtemplateName [(ngModel)]="this.templateInput.name" class="form-control dl-input-text" type="text" name="inputtemplateName" placeholder="Username" required="required"/>
           </div>
         </div>
 
       <div class="form-group">
           <div class="row">
-            <div class="col-md-3">
+            <div class="col-md-2">
               <label class="dl-emphasis1" for="templatebody">{{ 'TEMPLATE_BODY'| translate }}</label>
             </div>
-            <div class="col-md-9">
+            <div class="col-md-10">
                 <textarea #templatebody [(ngModel)]="this.templateInput.body" class="form-control dl-input-text" placeholder="Put the template design here..." rows="3" style="min-height: 300px!important;"></textarea>
             </div>
           </div>
 
       <div class="form-group">
         <div class="row">
-          <div class="col-md-3">
+          <div class="col-md-2">
+            <label class="dl-emphasis1" style="line-height: 2.25rem;">{{ 'FIELUPLOAD' | translate }}</label>
+          </div>
+          <div class="col-md-2 p-1" style="position: relative;
+    margin-left: 0.5rem;">
+            <input type="file" id="f-file" (change)="this.jsReadFiles()" />
+            <label for="f-file" style="height: 100%;width: 100%;">
+              <button type="button" class="btn dl-btn-dark btn-block" style="cursor: pointer">
+                {{ 'FIELUPLOAD' | translate }}
+              </button>
+            </label>
+          </div>
+          <div class="col-md-2">
+           <span style="line-height: 2.25rem">{{this.fileName}}</span>
+          </div>
+        </div>
+      </div>
+
+      <div class="form-group">
+        <div class="row">
+          <div class="col-md-2">
             <label class="dl-emphasis1">{{ 'TEMPLATE_TYPE' | translate }}</label>
           </div>
-          <div class="col-md-7">
+          <div class="col-md-8">
             <select #templatetype class="custom-select dl-input-text">
-              <option *ngFor="let item of templatetypedata" [selected]="item==templatetypedata[0]">{{item}}</option>
+              <option *ngFor="let item of templatetypedata" [selected]="item==templatetypedata[0]" [attr.designType]="[item.designType]">{{item.display}}</option>
             </select>
           </div>
         </div>
 
       <div class="form-group">
           <div class="row">
-            <div class="col-md-3">
+            <div class="col-md-2">
               <label class="dl-emphasis1">{{ 'TOPICS_NAME' | translate }}</label>
             </div>
-            <div class="col-md-7">
+            <div class="col-md-8">
               <select #topic class="custom-select dl-input-text">
                 <option *ngFor="let item of topicname" [selected]="item==topicname[0]">{{item}}</option>
               </select>
index fd6321b..3af75bb 100644 (file)
@@ -54,6 +54,7 @@ export class NewTemplateModalComponent implements OnInit {
   ) { }
   inputtemplateName = null;
   templatebody = null;
+  fileName = null;
 
   ngOnInit() {
     this.getTopicName();
@@ -66,7 +67,8 @@ export class NewTemplateModalComponent implements OnInit {
       body: this.template.body,
       note: this.template.note,
       topic: this.template.topic,
-      designType: this.template.designType
+      designType:  this.template.designType,
+      display: this.template.display
     };
     this.templateInput = feed;
   }
@@ -84,13 +86,27 @@ export class NewTemplateModalComponent implements OnInit {
     });
   }
 
+  jsReadFiles(){
+    var thiss =this;
+    var file =(<HTMLInputElement>document.querySelector("#f-file")).files[0];
+    this.fileName = file.name;
+    var reader = new FileReader();
+    reader.onload = function() {
+      console.log(this.result,"this.result");
+      thiss.templateInput.body = String(this.result);
+    }
+    reader.readAsText(file);
+  }
   passBack() {
     if(this.templateInput.name == '' || this.templateInput.name == undefined){
       return false;
     }
     this.template = this.templateInput;
     console.log(this.templateInput);
-    this.template.designType = this.templatetype.nativeElement.value;
+    this.template.display = this.templatetype.nativeElement.value;
+    this.template.designType = this.templatetypedata.find((item) => {
+        return item.display == this.template.display
+    }).designType;
     this.template.topic = this.topic.nativeElement.value;
     this.template.submitted = false;
     this.template.note = "";
index 8222648..01543f7 100644 (file)
@@ -63,7 +63,7 @@
 
         <ngx-datatable-column [width]="180" name="{{ 'TEMPLATE_TYPE' | translate }}" prop="type">
           <ng-template let-row="row" ngx-datatable-cell-template>
-            <span>{{ row.designType }}</span>
+            <span>{{ row.display }}</span>
           </ng-template>
         </ngx-datatable-column>
 
index cfe4300..70c2bd7 100644 (file)
@@ -103,6 +103,7 @@ export class TemplateListComponent {
         note: data["note"],
         topic: data["topic"],
         designType: data["designType"],
+        display: data["display"],
       };
       t.push(feed);
     }