From e32043f58a2450b6a5986dc2a01f64f8b22c3992 Mon Sep 17 00:00:00 2001
From: "Yang (Gabriel) Yu" <Gabriel.yuyang@huawei.com>
Date: Tue, 4 Sep 2018 21:02:27 +0800
Subject: Change naming and veriy test-scheduler function

Changes:
1. Testing-scheduler -> Test-scheduler
2. lots of windows breaks '\r' and '^M' in files,
   batch changes to unix breaks '$'
3. Add ui/build

Change-Id: I1f2c98ab9348460d4e68bfbfab664dae82b761ba
Signed-off-by: Yang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
---
 .../src/components/env_component/service_api.vue   | 112 +++++++++++++++++++++
 1 file changed, 112 insertions(+)
 create mode 100644 test-scheduler/ui/src/components/env_component/service_api.vue

(limited to 'test-scheduler/ui/src/components/env_component/service_api.vue')

diff --git a/test-scheduler/ui/src/components/env_component/service_api.vue b/test-scheduler/ui/src/components/env_component/service_api.vue
new file mode 100644
index 00000000..f6f58d2c
--- /dev/null
+++ b/test-scheduler/ui/src/components/env_component/service_api.vue
@@ -0,0 +1,112 @@
+<template>
+    <div class="panel panel-success">
+            <div class="panel-heading">
+                <button type="button" class="btn btn-xs btn-danger pull-right" v-on:click="deleteApi(name)">Delete</button>
+                <h5 class="panel-title">
+                    <a data-toggle="collapse" data-parent="panelParent" v-bind:href="'#' + name + '-collapse'" style="display:block;">{{ name }}</a>
+                </h5>
+            </div>
+            <div  v-bind:id="name + '-collapse'" class="panel-collapse collapse fade">
+                <div class="panel-body">
+                    <base-input name="name" v-model="name"></base-input>
+                    <base-input name="method" v-model="method"></base-input>
+                    <base-input name="baseuri" v-model="baseuri"></base-input>
+                    <api-param v-bind:params="params"></api-param>
+                    <div class="form-group" v-bind:class="{  'has-error': jsonSyntaxError}">
+                        <label class="col-lg-3 control-label" id="templateLabel">
+                            Template <i class="fa fa-question-circle"></i>
+                        </label>
+                        <div class="col-lg-7">
+                            <!-- help text -->
+                            <span id="tempHelp">Json格式文本，用于定义发送http请求的报文内容。示例如下：<br>( 其中 ((&lt;variable&gt;)) 为占位符，用于替换实际值 )<br>GET方式：<br>{<br> &nbsp;"uri" : "((baseuri))?name=((name))"<br>}<br>POST方式:<br>{<br> &nbsp;"uri" : "((baseuri))",<br> &nbsp;"body" : {<br>&nbsp;&nbsp;&nbsp;"name" : "((name))",<br>&nbsp;&nbsp;&nbsp;"account" : {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"id" : "((user_name))",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"addr" : "SH"<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;}<br>}</span>
+                            <textarea class="form-control" style="min-height: 200px;" v-model="templateStr"></textarea>
+                            <span class="help-block" v-show="jsonSyntaxError">Json语法错误，请检查！</span>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+</template>
+<script>
+import base_input from "./base_input.vue"
+import api_param from "./api_param.vue"
+import Vue from "vue"
+export default {
+    props: ['panelParent', 'name', 'method', 'baseuri', 'params', 'template'],
+    watch: {
+        name: function(val) {
+            this.$emit("name", val);
+        },
+        method: function(val) {
+            this.$emit("method", val);
+        },
+        baseuri: function(val) {
+            this.$emit("baseuri", val);
+        },
+        params: function(val) {
+            this.$emit("params", val);
+        },
+        templateStr: function(val) {
+            try {
+                console.log(JSON.parse(val));
+                this.jsonSyntaxError = false;
+                this.$emit("template", JSON.parse(val));
+            } catch(err) {
+                console.log("catch the exception templateStr");
+                this.jsonSyntaxError = true;
+            }
+        }
+    },
+    components: {
+        'base-input': base_input,
+        'api-param': api_param
+    },
+    data: function() {
+        return {
+            jsonSyntaxError: false,
+            templateStr: JSON.stringify(this.template, null, 2)
+        };
+    },
+    methods: {
+        deleteApi: function(apiName) {
+            this.$emit("delete", apiName);
+        }
+    }
+}
+</script>
+<style scoped>
+#templateLabel:hover+div #tempHelp{
+    display: block;
+}
+#tempHelp {
+    display: none;
+    position: absolute;
+    width: 90%;
+    min-height: 150px;
+    background-color: #ab2d2d;
+    color: white;
+    transition: display 1s;
+    text-align: left;
+    padding: 10px 16px;
+    z-index: 2;
+    font-size: 10px;
+    opacity: 0.9;
+}
+#tempHelp::after {
+    content: '';
+    position: absolute;
+    bottom: 92%;
+    right: 100%;
+    margin-left: -5px;
+    border-width: 5px;
+    border-style: solid;
+    border-color: transparent #ab2d2d transparent transparent;
+}
+@media(max-width:1200px) {
+    #tempHelp::after {
+        bottom: 100%;
+        left: 5%;
+        border-color: transparent transparent #ab2d2d transparent;
+    }
+}
+</style>
-- 
cgit 1.2.3-korg

