annotate OrthancServer/Plugins/Samples/ConnectivityChecks/WebResources/app.js @ 4431:b7f27b116685

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Jan 2021 14:34:44 +0100
parents 0a954155aea5
children d9473bd5ed43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3622
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3622
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
3622
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * General Public License for more details.
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 new Vue({
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 el: '#app',
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 data: {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 dicomNodes: {},
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 peers: [],
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 canTestPeers: false,
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 dicomWebServers: []
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 methods: {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 toggle: function (todo) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 todo.done = !todo.done
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 testDicomModalities: function () {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 console.log('testing DICOM modalities');
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 .get('../../modalities?expand')
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 this.dicomNodes = response.data;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 for (let alias of Object.keys(this.dicomNodes)) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 this.dicomNodes[alias]['alias'] = alias;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 this.dicomNodes[alias]['status'] = 'testing';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 axios
4176
0a954155aea5 fix echo request in connectivity check
Alain Mazy <alain@mazy.be>
parents: 4122
diff changeset
45 .post('../../modalities/' + alias + '/echo', {})
3622
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 this.dicomNodes[alias]['status'] = 'ok';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 .catch(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 this.dicomNodes[alias]['status'] = 'ko';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 testOrthancPeers: function () {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 console.log('testing Orthanc peers');
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 .get('../../peers?expand')
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 this.peers = response.data;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 for (let alias of Object.keys(this.peers)) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 this.peers[alias]['alias'] = alias;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 if (this.canTestPeers) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 this.peers[alias]['status'] = 'testing';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 .get('../../peers/' + alias + '/system') // introduced in ApiVersion 5 only !
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 this.peers[alias]['status'] = 'ok';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 .catch(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 this.peers[alias]['status'] = 'ko';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 else {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 this.peers[alias]['status'] = 'unknown';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 testDicomWebServers: function () {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 console.log('testing Dicom-web servers');
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 .get('../../dicom-web/servers?expand')
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 this.dicomWebServers = response.data;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 for (let alias of Object.keys(this.dicomWebServers)) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 this.dicomWebServers[alias]['alias'] = alias;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 this.dicomWebServers[alias]['status'] = 'testing';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 // perform a dummy qido-rs to test the connectivity
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 .post('../../dicom-web/servers/' + alias + '/qido', {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 'Uri' : '/studies',
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 'Arguments' : {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 '00100010' : 'CONNECTIVITY^CHECKS'
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 this.dicomWebServers[alias]['status'] = 'ok';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 .catch(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 this.dicomWebServers[alias]['status'] = 'ko';
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 this.$forceUpdate();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 computed: {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 },
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 mounted() {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 axios
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 .get('../../system')
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 .then(response => {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 this.canTestPeers = response.data.ApiVersion >= 5;
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 this.testDicomModalities();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 if (this.canTestPeers) {
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 this.testOrthancPeers();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 this.testDicomWebServers();
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 })
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 }
8afc14fab01f New sample plugin: ConnectivityChecks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 })