diff options
Diffstat (limited to 'testing-scheduler/ui/src/components')
4 files changed, 984 insertions, 0 deletions
diff --git a/testing-scheduler/ui/src/components/message/showMessage.js b/testing-scheduler/ui/src/components/message/showMessage.js new file mode 100644 index 00000000..39cc32bf --- /dev/null +++ b/testing-scheduler/ui/src/components/message/showMessage.js @@ -0,0 +1,30 @@ +import toastr from '../../assets/js/toastr.min.js'
+export default function(type, title, info, detail="") {
+ if(typeof type == "number") {
+ if(200 <= type && type < 300) {
+ type = "success";
+ } else if (300 <= type && type < 500) {
+ type = "warning";
+ } else if (500 <= type) {
+ type = "error";
+ } else {
+ type = "info";
+ }
+ }
+ if(detail != "") {
+ detail = "* <strong>detail:</strong> " + detail;
+ }
+ var content = "<br>* " + info + "<br><br>" + detail;
+ if(type == "success"){
+ toastr.success(content, title);
+ }
+ else if(type == "info") {
+ toastr.info(content, title);
+ }
+ else if(type == "error"){
+ toastr.error(content, title);
+ }
+ else {
+ toastr.warning(content, title);
+ }
+}
\ No newline at end of file diff --git a/testing-scheduler/ui/src/components/testcase.vue b/testing-scheduler/ui/src/components/testcase.vue new file mode 100644 index 00000000..4d15dc70 --- /dev/null +++ b/testing-scheduler/ui/src/components/testcase.vue @@ -0,0 +1,349 @@ +<template>
+ <div class="wrapper wrapper-content animated fadeIn">
+ <div class="row" style="margin-bottom: 20px;">
+ <div class="col-md-8">
+ <ol class="breadcrumb" style="padding-left: 20px; font-size: 17px;">
+ <li>
+ <router-link to="/" >root</router-link>
+ </li>
+ <li>
+ <router-link :to="{ path: '/testcase', query: { name: sname }}"><b>{{this.$route.query.name}}</b></router-link>
+ </li>
+ </ol>
+ </div>
+ </div>
+ <div id="page-content" style="" class="row">
+ <div class="col-lg-8">
+ <div class="ibox">
+ <div class="ibox-title">
+ <h5 style="font-size:26px;margin-top: -3px;">Test Case</h5>
+ <div class="ibox-tools">
+ <button class="btn btn-info btn-sm my-button-sm" type="button" v-on:click="runMultiTestcase()">Run</button>
+ <button class="btn btn-success btn-sm my-button-sm" type="button" v-on:click="create()">Create</button>
+ <button class="btn btn-danger btn-sm my-button-sm" v-on:click="deleteCases()" type="button">Delete</button>
+ <a class="collapse-link">
+ <i class="fa fa-chevron-up"></i>
+ </a>
+ <a class="fullscreen-link">
+ <i class="fa fa-expand"></i>
+ </a>
+ </div>
+ </div>
+ <div class="ibox-content" style="text-align:center;">
+ <table class="my-table table table-bordered" cellspacing="0" cellpadding="0" style="text-align: center;">
+ <thead>
+ <tr>
+ <td class="checkbox1" style="width:20px"><input type="checkbox" v-model="selectAll"> All</td>
+ <td class="smallbox" style="with:250px;">TestCase Name</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="testcase in testcases">
+ <td><input class="checkbox1" style="width:20px" type="checkbox" v-model="selected" :value="testcase.testcase"> </td>
+ <td class="smallbox" style="with:250px;"><router-link :to="{ path: '/content', query: { suiteName: sname, caseName: testcase.testcase } }">{{testcase.testcase}}</router-link></td>
+ </tr>
+ </tbody>
+ <tfoot id="create-box" style="display: none">
+ <tr>
+ <td class="checkbox1" style="width:20px"><input type="checkbox"> </td>
+ <td class="smallbox" style="with:250px;"><input type="text" v-model="newCase" @keydown.enter="additem" ></td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ <hr />
+ <div class="row">
+ <div class="col-lg-12">
+ <div class="ibox">
+ <div class="ibox-title">
+ <h5 style="font-size:26px;margin-top: -3px;">Workflow</h5>
+ <div class="ibox-tools">
+ <a class="collapse-link">
+ <i class="fa fa-chevron-up"></i>
+ </a>
+ <a class="fullscreen-link">
+ <i class="fa fa-expand"></i>
+ </a>
+ </div>
+ </div>
+ <div class="ibox-content" style="padding-top: 30px;">
+ <div id="executing" class="row" style="padding: 0 30px 60px;">
+ <div class="col-md-offset-2 col-md-8">
+ <div class="table-responsive">
+ <table class="table text-center" style="margin-top: 30px;">
+ <thead>
+ <tr>
+ <th class="text-center">#</th>
+ <th class="text-center">testcase</th>
+ <th class="text-center">status</th>
+ <th class="text-center">operation</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="testcase in runTestcases">
+ <td>{{ testcase.id }}</td>
+ <td>{{ testcase.testcase }}</td>
+ <td><span class="badge" v-bind:class="'badge-' + statusClass(testcase.status)">{{ testcase.status }}</span></td>
+ <td>
+ <div style="display: inline-block;min-width: 130px;">
+ <button class="btn btn-primary btn-outline btn-xs fadeIn" v-on:click="runTestcase()" v-show="testcase.status == 'failed'">rerun</button>
+ <button class="btn btn-primary btn-outline btn-xs fadeIn" v-on:click="runNextCase($event.target)" v-show="testcase.status == 'failed'">run next one</button>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ <hr class="hr-line-solid">
+ <div class="row" style="margin-top: 60px;">
+ <wfresult v-bind:workflowId="workflowId" v-bind:wfloading='wfloading' v-bind:wfJson='wfJson' v-on:wfComplete="wfComplete = $event"></wfresult>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
+<script>
+import wfresult from './workflow_graph/wfresult.vue'
+import showMessage from './message/showMessage.js'
+export default {
+ name: 'testcase',
+ data () {
+ return {
+ testcases: [],
+ sname: this.$route.query.name,
+ newCase:'',
+ addstory:'',
+ workflowId: '',
+ wfloading: false,
+ wfJson: '',
+ selected: [],
+ curRunningId: 0,
+ runTestcases: [],
+ wfComplete: false
+ }
+ },
+ created: function() {
+ var self = this;
+ var msgTitle = "GET -- TESTCASES";
+ var errorInfo = "Failed to get testcase list.";
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testsuite/content",
+ method:"GET",
+ data:{
+ suiteName: this.$route.query.name
+ },
+ success:function (data) {
+ if(data['code'] == 200) {
+ self.testcases = data['result'];
+ } else {
+ showMessage(data['code'], msgTitle, errorInfo, data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, errorInfo, msg);
+ }
+ });
+ },
+ computed: {
+ selectAll: {
+ get: function () {
+ return this.testcases ? this.selected.length == this.testcases.length : false;
+ },
+ set: function (value) {
+ var selected = [];
+ if (value) {
+ this.testcases.forEach(function (testcase) {
+ selected.push(testcase.testcase);
+ });
+ }
+ this.selected = selected;
+ }
+ }
+ },
+ methods:{
+ create: function () {
+ var cbox = document.getElementById("create-box");
+ cbox.style.display = "table-footer-group";
+ },
+ additem: function () {
+ var self = this;
+ var msgTitle = "CREATE -- TESTCASE";
+ const caseName = self.newCase.trim();
+ if(caseName)
+ {
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testcase/new",
+ method:"POST",
+ data:{
+ suiteName: self.sname,
+ caseName: caseName
+ },
+ success:function (data) {
+ if(data['code'] == 200){
+ self.testcases.push({
+ id: self.testcases.length + 1 ,
+ testcase: caseName,
+ });
+ showMessage(data['code'], msgTitle, "Create <strong>" + caseName + "</strong> succesfully!");
+ } else {
+ showMessage(data['code'], msgTitle, "Failed to create <strong>" + caseName + "</strong>!", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, "Failed to create <strong>" + caseName + "</strong>!", msg);
+ }
+ });
+ }
+ var cbox = document.getElementById("create-box");
+ cbox.style.display = "none";
+ this.newCase = '';
+ },
+ deleteCases:function () {
+ var self = this;
+ var msgTitle = "DELETE -- TESTCASE";
+ var deleteArr = self.selected.slice(0);
+ self.testcases = self.testcases.filter(item => {
+ for(var i in deleteArr) {
+ if(item.testcase == deleteArr[i]) {
+ return false;
+ }
+ }
+ return true;
+ });
+ self.selected = [];
+ for(var i in deleteArr)
+ {
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testcase/delete",
+ method: "POST",
+ data: {
+ suiteName: self.sname,
+ caseName: deleteArr[i]
+ },
+ success: function(data) {
+ if(data['code'] == 200){
+ showMessage(data['code'], msgTitle, "Delete <strong>" + deleteArr[i] + "</strong> succesfully!");
+ } else {
+ showMessage(data['code'], msgTitle, "Failed to delete <strong>" + deleteArr[i] + "</strong>!", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, "Failed to delete <strong>" + deleteArr[i] + "</strong>!", msg);
+ }
+ });
+ }
+ },
+ runMultiTestcase: function() {
+ var self = this;
+ var msgTitle = "RUN -- TESTCASES";
+ self.runTestcases = [];
+ if(self.selected.length == 0) {
+ showMessage("warning", msgTitle, "please select one!");
+ return;
+ }
+ for(var i=0; i < self.selected.length; i++) {
+ var testcaseItem = {'id': i, 'testcase': '', 'status': "waiting"};
+ testcaseItem['testcase'] = self.selected[i];
+ self.runTestcases.push(testcaseItem);
+ }
+ self.curRunningId = 0;
+ showMessage("info", msgTitle, "start to run <strong>testcases</strong>");
+ self.runOneTestcase();
+ },
+ runOneTestcase: function() {
+ var self = this;
+ var msgTitle = "RUN -- TESTCASE";
+ if (self.curRunningId == self.runTestcases.length) {
+ self.curRunningId = 0;
+ return;
+ }
+ self.wfComplete = false;
+ var i = self.curRunningId;
+ self.runTestcases[i]['status'] = "running";
+ $.ajax({
+ url: self.global.SERVER_ADDR + "execute/testcase",
+ method: "POST",
+ data: {
+ "suiteName": self.sname,
+ "caseName": self.runTestcases[self.curRunningId]['testcase']
+ },
+ beforeSend: function(XHR) {
+ self.wfloading = true;
+ },
+ success: function(data) {
+ if(data['code'] == 200) {
+ self.workflowId = data['result']['workflowId'];
+ $.ajax({
+ url: self.global.SERVER_ADDR + "story-content",
+ method: "GET",
+ data: {
+ "service": self.sname,
+ "story": self.runTestcases[self.curRunningId]['testcase']
+ },
+ success: function(data) {
+ if(data['code'] == 200) {
+ self.wfJson = data['result']['content'];
+ } else {
+ showMessage(data['code'], msgTitle, "workflow.json get failed!");
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, msg);
+ }
+ });
+ } else {
+ var i = self.curRunningId;
+ self.runTestcases[i]['status'] = "failed";
+ self.wfloading = false;
+ showMessage(data['code'], msgTitle, "Failed to run <strong>" + self.runTestcases[i]['testcase'] + "</strong>", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ var i = self.curRunningId;
+ self.runTestcases[i]['status'] = "failed";
+ self.wfloading = false;
+ showMessage(status, msgTitle, "Failed to run <strong>" + self.runTestcases[i]['testcase'] + "</strong>", msg);
+ }
+ });
+ },
+ statusClass: function(status) {
+ if(status == "waiting") {
+ return "success";
+ }
+ if(status == "running") {
+ return "warning";
+ }
+ if(status == "pass") {
+ return "primary";
+ }
+ if(status == "failed") {
+ return "danger";
+ }
+ },
+ runNextCase: function(obj) {
+ $(obj).parent().css({"display": "none"});
+ var i = this.curRunningId++;
+ this.runOneTestcase();
+ }
+ },
+ watch: {
+ wfComplete: function(val) {
+ if(val == false) return;
+ this.wfloading = false;
+ var i = this.curRunningId++;
+ this.runTestcases[i]['status'] = "pass";
+ this.runOneTestcase();
+ }
+ },
+ components: {
+ wfresult
+ }
+}
+</script>
\ No newline at end of file diff --git a/testing-scheduler/ui/src/components/testsuite.vue b/testing-scheduler/ui/src/components/testsuite.vue new file mode 100644 index 00000000..3752b2ec --- /dev/null +++ b/testing-scheduler/ui/src/components/testsuite.vue @@ -0,0 +1,369 @@ +<template>
+ <div class="wrapper wrapper-content animated fadeIn">
+ <div class="row" style="margin-bottom: 20px;">
+ <div class="col-md-8">
+ <ol class="breadcrumb" style="padding-left: 20px; font-size: 17px;">
+ <li>
+ <router-link to="/" >root</router-link>
+ </li>
+ </ol>
+ </div>
+ </div>
+ <div id="page-content" class="row">
+ <div class="col-lg-8">
+ <div class="ibox">
+ <div class="ibox-title">
+ <h5 style="font-size:26px;margin-top: -3px;">Test Suite</h5>
+ <div class="ibox-tools">
+ <button class="btn btn-info btn-sm my-button-sm" type="button" v-on:click="runTestsuites()">Run</button>
+ <button class="btn btn-success btn-sm my-button-sm" type="button" v-on:click="createSuite()">Create</button>
+ <button class="btn btn-danger btn-sm my-button-sm" v-on:click="deleteSuites()" type="button">Delete</button>
+ <a class="collapse-link">
+ <i class="fa fa-chevron-up"></i>
+ </a>
+ <a class="fullscreen-link">
+ <i class="fa fa-expand"></i>
+ </a>
+ </div>
+ </div>
+ <div class="ibox-content" style="text-align:center;">
+ <table class="my-table table table-bordered" cellspacing="0" cellpadding="0" style="text-align: center;">
+ <thead>
+ <tr>
+ <td style="width:20px"><input type="checkbox" v-model="selectAll"> All</td>
+ <td class="smallbox" style="with:250px;">TestSuite Name</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="testsuite in testsuites">
+ <td><input style="width:20px" type="checkbox" v-model="selected" :value="testsuite.testsuite"> </td>
+ <td class="smallbox" style="with:250px;"><router-link :to="{ path: '/testcase', query: { name: testsuite.testsuite }}" >{{testsuite.testsuite}}</router-link></td>
+ </tr>
+ </tbody>
+ <tfoot id="create-box" style="display: none">
+ <tr>
+ <td style="width:20px"><input type="checkbox"> </td>
+ <td class="smallbox" style="with:250px;"><input type="text" v-model="newSuite" @keydown.enter="addItem" ></td>
+ </tr>
+ </tfoot>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+ <hr />
+ <div class="row">
+ <div class="col-lg-12">
+ <div class="ibox">
+ <div class="ibox-title">
+ <h5 style="font-size:26px;margin-top: -3px;">Workflow</h5>
+ <div class="ibox-tools">
+ <a class="collapse-link">
+ <i class="fa fa-chevron-up"></i>
+ </a>
+ <a class="fullscreen-link">
+ <i class="fa fa-expand"></i>
+ </a>
+ </div>
+ </div>
+ <div class="ibox-content" style="padding-top: 30px;">
+ <div id="executing" class="row" style="padding: 0 30px 60px;">
+ <div class="col-md-offset-2 col-md-8">
+ <div class="table-responsive">
+ <table class="table text-center" style="margin-top: 30px;">
+ <thead>
+ <tr>
+ <th class="text-center">#</th>
+ <th class="text-center">testcase</th>
+ <th class="text-center">status</th>
+ <th class="text-center">operation</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr v-for="testcase in casesInSuite">
+ <td>{{ testcase.id }}</td>
+ <td>{{ testcase.testcase }}</td>
+ <td><span class="badge" v-bind:class="'badge-' + statusClass(testcase.status)">{{ testcase.status }}</span></td>
+ <td>
+ <div style="display: inline-block;min-width: 130px;">
+ <button class="btn btn-primary btn-outline btn-xs fadeIn" v-on:click="runTestcase()" v-show="testcase.status == 'failed'">rerun</button>
+ <button class="btn btn-primary btn-outline btn-xs fadeIn" v-on:click="runNextCase($event.target)" v-show="testcase.status == 'failed'">run next one</button>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ <hr class="hr-line-solid">
+ <div class="row" style="margin-top: 60px;">
+ <wfresult v-bind:workflowId="workflowId" v-bind:wfloading='wfloading' v-bind:wfJson='wfJson' v-on:wfComplete="wfComplete = $event"></wfresult>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</template>
+<script>
+import wfresult from './workflow_graph/wfresult.vue'
+import showMessage from './message/showMessage.js'
+export default {
+ name: 'testsuite',
+ data () {
+ return {
+ newSuite : '',
+ testsuites : '',
+ service_selected : '',
+ workflowId: '',
+ wfloading: false,
+ wfJson: '',
+ selected: [],
+ casesInSuite: [],
+ running: {
+ suiteName: "",
+ caseName: ""
+ },
+ curRunningId: 0,
+ wfComplete: false
+ }
+ },
+ created: function() {
+ var self = this;
+ var msgTitle = "GET -- TESTSUITES";
+ var errorInfo = "Failed to get testsuite list.";
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testsuite/list",
+ method:"GET",
+ data:{},
+ success:function (data) {
+ if(data['code'] == 200) {
+ self.testsuites = data['result'];
+ } else {
+ showMessage(data['code'], msgTitle, errorInfo, data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, errorInfo, msg);
+ }
+ });
+ },
+ computed: {
+ selectAll: {
+ get: function () {
+ return this.testsuites ? this.selected.length == this.testsuites.length : false;
+ },
+ set: function (value) {
+ var selected = [];
+ if (value) {
+ this.testsuites.forEach(function (story) {
+ selected.push(story.testsuite);
+ });
+ }
+ this.selected = selected;
+ }
+ }
+},
+ methods:{
+ createSuite: function () {
+ var cbox = document.getElementById("create-box");
+ cbox.style.display = "table-footer-group";
+ },
+ addItem: function () {
+ var self = this;
+ const suiteName = self.newSuite.trim();
+ if(suiteName)
+ {
+ var msgTitle = "CREATE -- TESTSUITE";
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testsuite/new",
+ method:"POST",
+ data:{
+ suiteName:suiteName
+ },
+ success:function(data){
+ if(data['code'] == 200){
+ self.testsuites.push({
+ id: self.testsuites.length + 1 ,
+ testsuite: suiteName,
+ });
+ showMessage(data['code'], msgTitle, "Create <strong>" + suiteName + "</strong> succesfully!");
+ } else {
+ showMessage(data['code'], msgTitle, "Failed to create <strong>" + suiteName + "</strong>!", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, "Failed to create <strong>" + suiteName + "</strong>!", msg);
+ }
+ })
+ }
+ var cbox = document.getElementById("create-box");
+ cbox.style.display = "none";
+ this.newSuite = '';
+ },
+ deleteSuites:function () {
+ var self = this;
+ var msgTitle = "DELETE -- TESTSUITE";
+ var deleteArr = self.selected.slice(0);
+ self.testsuites = self.testsuites.filter(item => {
+ for(var i in deleteArr) {
+ if(item.testsuite == deleteArr[i]) {
+ return false;
+ }
+ }
+ return true;
+ });
+ self.selected = [];
+ for(var i in deleteArr)
+ {
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testsuite/delete",
+ method:"POST",
+ data:{
+ suiteName: deleteArr[i]
+ },
+ success:function (data) {
+ if(data['code'] == 200){
+ showMessage(data['code'], msgTitle, "Delete <strong>" + deleteArr[i] + "</strong> succesfully!");
+ } else {
+ showMessage(data['code'], msgTitle, "Failed to delete <strong>" + deleteArr[i] + "</strong>!", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, "Failed to delete <strong>" + deleteArr[i] + "</strong>!", msg);
+ }
+ });
+ }
+ },
+ runTestsuites: function() {
+ var self = this;
+ var msgTitle = "RUN -- TESTSUITE";
+ if(self.selected.length == 0) {
+ showMessage("warning", msgTitle, "please select one!");
+ return;
+ } else if(self.selected.length != 1) {
+ showMessage("warning", msgTitle, "sorry, one suite at a time!");
+ return;
+ }
+ self.running.suiteName = self.selected[0];
+ $.ajax({
+ url: this.global.SERVER_ADDR + "testsuite/content",
+ method: "GET",
+ data: {
+ "suiteName": self.running.suiteName
+ },
+ success: function(data) {
+ if (data['code'] == 200) {
+ var caseList = data['result'];
+ if(caseList.length == 0) {
+ showMessage("info", msgTitle, "<strong>" + self.running.suiteName + "</strong> is empty!");
+ return;
+ }
+ for(var i=0; i < caseList.length; i++) {
+ caseList[i]['status'] = "waiting";
+ }
+ self.casesInSuite = caseList;
+ showMessage(data['code'], msgTitle, "Start to run <strong>" + self.running.suiteName + "</strong>");
+ self.runTestcase();
+ } else {
+ showMessage(data['code'], msgTitle, "Failed to run <strong>" + self.running.suiteName + "</strong>", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, "Failed to run <strong>" + self.running.suiteName + "</strong>", msg);
+ }
+ });
+ },
+ runTestcase: function() {
+ var self = this;
+ var msgTitle = "RUN -- TESTCASE";
+ if (self.curRunningId == self.casesInSuite.length) {
+ self.curRunningId = 0;
+ return;
+ }
+ self.wfComplete = false;
+ var i = self.curRunningId;
+ self.casesInSuite[i]['status'] = "running";
+ self.running.caseName = self.casesInSuite[i]['testcase'];
+ $.ajax({
+ url: self.global.SERVER_ADDR + "execute/testcase",
+ method: "POST",
+ data: {
+ "suiteName": self.running.suiteName,
+ "caseName": self.running.caseName
+ },
+ beforeSend: function(XHR) {
+ self.wfloading = true;
+ },
+ success: function(data) {
+ if(data['code'] == 200) {
+ self.workflowId = data['result']['workflowId'];
+ $.ajax({
+ url: self.global.SERVER_ADDR + "story-content",
+ method: "GET",
+ data: {
+ "service": self.running.suiteName,
+ "story": self.running.caseName
+ },
+ success: function(data) {
+ if(data['code'] == 200) {
+ self.wfJson = data['result']['content'];
+ } else {
+ showMessage(data['code'], msgTitle, "workflow.json get failed!");
+ }
+ },
+ error: function(obj, status, msg) {
+ showMessage(status, msgTitle, msg);
+ }
+ });
+ } else {
+ var i = self.curRunningId;
+ self.casesInSuite[i]['status'] = "failed";
+ self.wfloading = false;
+ showMessage(data['code'], msgTitle, "Failed to run <strong>" + self.running.caseName + "</strong>", data['error']);
+ }
+ },
+ error: function(obj, status, msg) {
+ var i = self.curRunningId;
+ self.casesInSuite[i]['status'] = "failed";
+ self.wfloading = false;
+ showMessage(status, msgTitle, "Failed to run <strong>" + self.running.caseName + "</strong>", msg);
+ }
+ });
+ },
+ statusClass: function(status) {
+ if(status == "waiting") {
+ return "success";
+ }
+ if(status == "running") {
+ return "warning";
+ }
+ if(status == "pass") {
+ return "primary";
+ }
+ if(status == "failed") {
+ return "danger";
+ }
+ },
+ runNextCase: function(obj) {
+ $(obj).parent().css({"display": "none"});
+ var i = this.curRunningId++;
+ this.runTestcase();
+ }
+ },
+ watch: {
+ wfComplete: function(val) {
+ if(val == false) return;
+ this.wfloading = false;
+ var i = this.curRunningId++;
+ this.casesInSuite[i]['status'] = "pass";
+ // run the next testcase.
+ this.runTestcase();
+ }
+ },
+ components: {
+ wfresult
+ }
+}
+</script>
\ No newline at end of file diff --git a/testing-scheduler/ui/src/components/workflow_graph/wfresult.vue b/testing-scheduler/ui/src/components/workflow_graph/wfresult.vue new file mode 100644 index 00000000..ace6076d --- /dev/null +++ b/testing-scheduler/ui/src/components/workflow_graph/wfresult.vue @@ -0,0 +1,236 @@ +<template>
+<div style="min-height: 600px; overflow-x: auto; overflow-y: auto;">
+ <div id="file-section1" class="col-md-4">
+ <div id="workflow-content-div">
+ <div class="dark-gray-bg" style="font-size: 17px; max-width: 500px; margin: 0 auto 10px;"> WORKFLOW.JSON CONTENT</div>
+ <pre class="white-pink" id="workflow-content" style="height: 600px; background-color:#f5f5f5;"></pre>
+ </div>
+ </div>
+ <div class="col-md-8" id="graph-show-section" style="">
+ <div v-show="!wfloading" style="margin-top: 10px;">
+ <div style="min-height: 30px; text-align: right;">
+ <button v-show="workflowId != '' && !wfCompletedFlag" class="btn" v-on:click="completeWF(1)" title="mark the status 'complete' by hand.">mark it <strong>complete</strong></button>
+ </div>
+ <div id="workflow-graph">
+ </div>
+ </div>
+ <div v-show="wfloading" class="spiner-example" id="loading">
+ <div class="sk-spinner sk-spinner-three-bounce">
+ <div class="sk-bounce1"></div>
+ <div class="sk-bounce2"></div>
+ <div class="sk-bounce3"></div>
+ </div>
+ </div>
+ <div class="row">
+ <div id="iframeContainer"></div>
+ <div id="workflowId" style="display:none">
+ <input name="workflowId" type="hidden" v-bind:value="workflowId" />
+ <input name="function" type="hidden" value="graphLoad" />
+ <button id="graphloadbtn" type="button" onclick="graphLoad()"></button>
+ </div>
+ </div>
+ </div>
+</div>
+</template>
+<script>
+export default {
+ props: ['workflowId', 'wfloading', 'wfJson'],
+ name: 'wfresult',
+ data: function() {
+ return {
+ frameLoadedFlag : false,
+ initalPaintFlag : false,
+ RESPONSE_TIME_LIMIT : 6000,
+ responseTimeCounter : 0,
+ wfCompletedFlag : false,
+ intervalTime : 1000,
+ timer: null
+ }
+ },
+ computed: {
+ wfget: function(){
+ return !this.wfloading;
+ }
+ },
+ watch: {
+ workflowId: function(val){
+ console.log("############## workflowId changed! " + val);
+ this.graphLoad();
+ },
+ wfJson: function(val){
+ this.fillWfContent(val);
+ }
+ },
+ mounted: function(){
+ window.clearInterval(this.timer);
+ },
+ destroyed: function(){
+ window.clearInterval(this.timer);
+ },
+ methods: {
+ graphLoad: function(){
+ console.log("load function activate");
+ this.reset();
+ this.initialPaintWFGraph();
+ var self = this;
+ self.timer = window.setInterval(function() {
+ if(!self.initalPaintFlag) {
+ if(self.responseTimeCounter > self.RESPONSE_TIME_LIMIT) {
+ self.initialPaintWFGraph();
+ self.responseTimeCounter = 0;
+ }
+ } else {
+ if(self.frameLoadedFlag || self.responseTimeCounter > self.RESPONSE_TIME_LIMIT) {
+ self.repaintWFGraph();
+ self.responseTimeCounter = 0;
+ }
+ }
+ self.responseTimeCounter += self.intervalTime;
+ }, self.intervalTime);
+ },
+ reset: function(){
+ this.frameLoadedFlag = false;
+ this.initalPaintFlag = false;
+ this.RESPONSE_TIME_LIMIT = 6000;
+ this.responseTimeCounter = 0;
+ this.wfCompletedFlag = false;
+ var graphDiv = document.getElementById("workflow-graph");
+ graphDiv.innerHTML = '';
+ },
+ initialPaintWFGraph: function() {
+ console.log("start to initial paint");
+ this.setIframeSrc();
+ var iframe = document.getElementById("testFrame");
+ var self = this;
+ if (iframe.attachEvent) {
+ iframe.attachEvent("onload", function(){
+ window.setTimeout(function(){
+ self.frameLoadedFlag = true;
+ self.initialPaint();
+ console.log("finish to initial paint");
+ }, 1000);
+ });
+ } else {
+ iframe.onload = function(){
+ window.setTimeout(function(){
+ self.frameLoadedFlag = true;
+ self.initialPaint();
+ console.log("finish to initial paint");
+ }, 1000);
+ }
+ }
+ },
+ setIframeSrc: function(){
+ var iframeContainer = document.getElementById("iframeContainer");
+ var iframeDiv = document.getElementById("testFrame");
+ if(iframeDiv != undefined ) {
+ iframeContainer.removeChild(iframeDiv);
+ }
+ var apiPrefix = this.global.WF_GRAPH_ADDR + "#/workflow/id/";
+ var apiUrl = apiPrefix + this.workflowId;
+ console.log("workflowId prop:" + this.workflowId);
+ var iframeDiv = "<iframe id=\"testFrame\" width=\"0\" height=\"0\" style=\"border: none;\" src=\"" + apiUrl + "\"></iframe>";
+ iframeContainer.innerHTML = iframeDiv;
+ this.frameLoadedFlag = false;
+ },
+ initialPaint: function() {
+ var iframe = document.getElementById("testFrame");
+ var frameContent = iframe.contentWindow.document.getElementById("graph-ui-content");
+ if(frameContent == null) return;
+ this.frameLoadedFlag = true;
+ var content = frameContent.cloneNode(true);
+ content.id = "graph-ui-content-1";
+ var graphDiv = document.getElementById("workflow-graph");
+ graphDiv.appendChild(content);
+ this.initalPaintFlag = true;
+ this.wfloading = false;
+ console.log("####################wfloading false######################");
+ },
+ repaint: function() {
+ var iframe = document.getElementById("testFrame");
+ var frameContent = iframe.contentWindow.document.getElementById("graph-ui-content");
+ if(frameContent == null) return;
+ this.frameLoadedFlag = true;
+ var newContent = frameContent.cloneNode(true);
+ var newNodes = newContent.getElementsByClassName("node");
+ var oldContent = document.getElementById("graph-ui-content-1");
+ var oldNodes = oldContent.getElementsByClassName("node");
+ var completeText = iframe.contentWindow.document.getElementsByClassName("ui-content")[0].getElementsByTagName("h4")[0].getElementsByTagName("span")[3].innerHTML;
+ if(newNodes.length > oldNodes.length) {
+ console.log("execute in new > old");
+ newContent.id = "graph-ui-content-1";
+ var graphDiv = document.getElementById("workflow-graph");
+ graphDiv.innerHTML = '';
+ graphDiv.appendChild(newContent);
+ }
+ else if(newNodes.length == oldNodes.length) {
+ console.log("execute in new = old");
+ for(var i = 0; i < newNodes.length; i++)
+ {
+ var newGraph = newNodes[i].children[0];
+ var newGraphStyle = newGraph.getAttribute("style");
+ var oldGraph = oldNodes[i].children[0];
+ var oldGraphStyle = oldGraph.getAttribute("style");
+ if(newGraphStyle != oldGraphStyle) {
+ oldGraph.setAttribute("style", newGraphStyle);
+ }
+ var newText = newNodes[i].getElementsByTagName("text")[0];
+ var newTextStyle = newText.getAttribute("style");
+ var oldText = oldNodes[i].getElementsByTagName("text")[0];
+ var oldTextStyle = oldText.getAttribute("style");
+ if(oldTextStyle != newTextStyle) {
+ oldText.setAttribute("style", newTextStyle);
+ }
+ }
+ if(completeText == "COMPLETED") {
+ this.completeWF(5);
+ }
+ }
+ else {
+ console.log("execute in new < old");
+ }
+ },
+ repaintWFGraph: function() {
+ this.setIframeSrc();
+ var iframe = document.getElementById("testFrame");
+ var self = this;
+ if (iframe.attachEvent) {
+ iframe.attachEvent("onload", function(){
+ window.setTimeout(function(){
+ self.frameLoadedFlag = true;
+ self.repaint();
+ }, 1000);
+ });
+ } else {
+ iframe.onload = function(){
+ window.setTimeout(function(){
+ self.frameLoadedFlag = true;
+ self.repaint();
+ }, 1000);
+ }
+ }
+ },
+ completeWF: function(delay) {
+ this.wfCompletedFlag = true;
+ console.log("#####################################completed: clean the interval " + this.timer);
+ window.clearInterval(this.timer);
+ var self = this;
+ window.setTimeout(function() {
+ self.$emit("wfComplete", true);
+ }, delay*1000);
+ },
+ fillWfContent: function(wfContent) {
+ var contentDiv = document.getElementById("workflow-content");
+ contentDiv.innerHTML = wfContent;
+ }
+ }
+}
+</script>
+<style scoped>
+#workflow-graph {
+ text-align: center;
+}
+#workflow-graph > div{
+ display: inline-block;
+}
+</style>
\ No newline at end of file |