summaryrefslogtreecommitdiffstats
path: root/test-scheduler/ui/src/components/message/showMessage.js
blob: 2ac203e7dce58701bbfe1c4778141bfb2a71cb67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);
    }
}