add testsuite and testcase list pages in frontend of testing-scheduler
[bottlenecks.git] / testing-scheduler / ui / src / components / message / showMessage.js
diff --git a/testing-scheduler/ui/src/components/message/showMessage.js b/testing-scheduler/ui/src/components/message/showMessage.js
new file mode 100644 (file)
index 0000000..39cc32b
--- /dev/null
@@ -0,0 +1,30 @@
+import toastr from '../../assets/js/toastr.min.js'\r
+export default function(type, title, info, detail="") {\r
+    if(typeof type == "number") {\r
+        if(200 <= type && type < 300) {\r
+            type = "success";\r
+        } else if (300 <= type && type < 500) {\r
+            type = "warning";\r
+        } else if (500 <= type) {\r
+            type = "error";\r
+        } else {\r
+            type = "info";\r
+        }\r
+    }\r
+    if(detail != "") {\r
+        detail = "* <strong>detail:</strong>  " + detail;\r
+    }\r
+    var content = "<br>* " + info + "<br><br>" + detail;\r
+    if(type == "success"){\r
+        toastr.success(content, title);\r
+    }\r
+    else if(type == "info") {\r
+        toastr.info(content, title);\r
+    }\r
+    else if(type == "error"){\r
+        toastr.error(content, title);\r
+    }\r
+    else {\r
+        toastr.warning(content, title);\r
+    }\r
+}
\ No newline at end of file