Debian Codegraph @

src/opencdeserver/api/app/templates/upload_files.html

raw
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>Kontroll.digital</title>
6 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
7 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
8 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
9 <script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
10 <script>
11 $(document).ready(function () {
12 $('#save_metadata_button').on('click', function (event) {
13 event.preventDefault();
14 save_metadata();
15 });
16 });
17 function save_metadata () {
18 let form_values = $('#save_metadata_form').serialize();
19 console.log('Form values: ' + form_values);
20 $.ajax ({
21 type: 'POST',
22 url: './save-metadata-for-documents',
23 data: form_values,
24 dataType: 'json',
25 success: function (msg) {
26 if (msg) {
27 console.log('Result of save-metadata-for-documents: ' + msg);
28 callback(msg)
29 }
30 },
31 error: function () {
32 let errors = ['An unknown error occured.'];
33 console.log(errors);
34 }
35 });
36 }
37 function callback (msg) {
38 let callback_url = $('#callback_url').val();
39 let session_id = $('#upload_session').val();
40 let server_context = $('#server_context').val();
41 let upload_documents_url = 'https://api.kontroll.digital/documents/1.0/upload-instructions'
42 + '?session_id=' + session_id
43 + '&server_context=' + server_context
44
45 callback_url = callback_url + '?upload_documents_url=' + encodeURIComponent(upload_documents_url)
46
47 console.log('Upload documents url: ' + upload_documents_url);
48 console.log('Callback url: ' + callback_url);
49
50 $.get ({
51 url: callback_url,
52 crossDomain: true,
53 dataType: 'html',
54 success: function (msg) {
55 if (msg) {
56 console.log('Result text: ' + msg);
57 $('#result_message').text('You may now close this window.');
58 }
59 },
60 error: function () {
61 let errors = ['An unknown error occured.'];
62 console.log(errors);
63 }
64 });
65 }
66 </script>
67 <style>
68 body {
69 align-content: center;
70 justify-content: center;
71 padding-top: 40px;
72 padding-bottom: 40px;
73 background-color: #f5f5f5;
74 }
75 .page_layout {
76 width: 100%;
77 max-width: 780px;
78 padding: 15px;
79 margin: 0 auto;
80 }
81 </style>
82 </head>
83 <body>
84 <div id="page_layout" class="page_layout">
85 <form action="" id="save_metadata_form" name="save_metadata_form">
86 <h1 class="h3 mb-3">kontroll.digital</h1>
87
88 <div id="save_metadata_div">
89
90 <table class="table">
91 <thead>
92 <tr>
93 <th scope="col">Id</th>
94 <th scope="col">Title</th>
95 <th scope="col">Version</th>
96 <th scope="col">File name</th>
97 </tr>
98 </thead>
99 <tbody>
100
101 {% for document in documents %}
102
103 <tr>
104 <input type="hidden" id="session_file_id@{{document.session_file_id}}" name="session_file_id@{{document.session_file_id}}" value="{{document.session_file_id}}">
105 <td>{{document.document_id}}<input type="hidden" id="document@{{document.session_file_id}}" name="document@{{document.session_file_id}}" value="{{document.document_id}}"></td>
106 <td><input type="text" id="title@{{document.session_file_id}}" name="title@{{document.session_file_id}}" value="{{document.title}}"></td>
107 <td><input type="text" id="version_number@{{document.session_file_id}}" name="version_number@{{document.session_file_id}}" value="{{document.version_number}}"></td>
108 <td>{{document.file_name}}<input type="hidden" id="filename@{{document.session_file_id}}" name="filename@{{document.session_file_id}}" value="{{document.file_name}}"></td>
109 <tr>
110
111 {% endfor %}
112
113 </tbody>
114 </table>
115
116 <input type="hidden" id="username" name="username" value="{{username}}">
117 <input type="hidden" id="email" name="email" value="{{email}}">
118 <input type="hidden" id="full_name" name="full_name" value="{{full_name}}">
119 <input type="hidden" id="upload_session" name="upload_session" value="{{upload_session}}">
120 <input type="hidden" id="server_context" name="server_context" value="{{server_context}}">
121 <input type="hidden" id="callback_url" name="callback_url" value="{{callback_url}}">
122 <input type="hidden" id="callback_expires_in" name="callback_expires_in" value="{{callback_expires_in}}">
123
124 <div class="form-group mb-3">
125 <label for="project">Associate document with this project:</label>
126 <select class="form-control" id="project" name="project">
127 {% for project in projects %}
128 <option value="{{project.project_id}}">{{project.name}}</option>
129 {% endfor %}
130 </select>
131 </div>
132
133 <button class="btn btn-lg btn-primary btn-block" type="submit" id="save_metadata_button">Save metadata</button>
134
135 </div>
136 </form>
137 </div>
138 </body>
139 </html>
140