99 <server>set $NAMESPACE = "USER"</server>
1010 #(##class(SourceControl.Git.Utils).GetSourceControlInclude())#
1111 <style type="text/css">
12- h1 {
12+ h1, h2 {
1313 margin-top: 10px
1414 }
15+
1516 .A::after {
1617 content: "Added";
1718 position: absolute;
4647 margin-top: 10px;
4748 }
4849
50+ .output-header {
51+ margin-top: 120px;
52+ }
4953 .output {
50- margin-top: 100px;
54+
5155 margin-bottom: 20px;
5256 border: 1.5px solid darkgray;
5357 padding: 10px;
7276 1: "none"
7377 )
7478
79+ set outputDisplay = "none"
80+
7581 </server>
7682
7783 <div class="container">
94100 <input class="form-control" type="text" name="syncMsg" id="syncMsg" value="#(commitMsg)#">
95101 </div>
96102 <div style="display: #(noFileDisplay)#">
97- <h1 class="text-center">No files to commit with sync</h1 >
103+ <h2 class="text-center">No files to commit with sync</h2 >
98104 </div>
99105 <h3 class="section-header">Sync details:</h3>
100106 <p>Upon syncing, the local repository will pull the changes from remote and commit the newest changes before committing and pushing</p>
105111 }
106112 </server>
107113
108- <button class="btn btn-lg btn-primary" id="syncBtn" onClick="#server(..PerformSync())# ">Sync</button>
114+ <button class="btn btn-lg btn-primary" id="syncBtn" onClick="disableInput() ">Sync</button>
109115 <div>
110- <div class="container output">
111-
116+ <h3 class="output-header" id="outputHeader" style="display: #(outputDisplay)#">Sync output: </h3>
117+ <div class="container output" id="outputContainer" style="display: #(outputDisplay)#">
118+ <pre id="outputBox"></pre>
112119 </div>
113120 </div>
114121 </div>
115122 </div>
116123
117124 </div>
118125 </body>
126+ <script type="text/javascript">
127+ function disableInput() {
128+ document.getElementById('syncMsg').disabled = true;
129+ document.getElementById('syncBtn').innerHTML = 'Syncing...';
130+ document.getElementById('syncBtn').disabled = true;
131+ #server(..PerformSync(self.document.getElementById('syncMsg').value))#
132+ }
133+ </script>
134+ <script language="cache" method="PerformSync" arguments="syncMsg:%String">
135+ &js<document.getElementById('outputContainer').style.display = 'block'>
136+ &js<document.getElementById('outputHeader').style.display = 'block'>
137+ set $NAMESPACE = "USER"
138+ set buffer = ##class(SourceControl.Git.Util.Buffer).%New()
139+ do buffer.BeginCaptureOutput()
140+
141+ set st = ##class(SourceControl.Git.Utils).Sync(syncMsg)
142+
143+ set out = ##class(%Stream.GlobalCharacter).%New()
144+ do buffer.EndCaptureOutput(.out)
145+ while 'out.AtEnd {
146+ set line = out.ReadLine()
147+ set escapedLine = ..EscapeHTML(line)
148+ set escapedLine = $replace(escapedLine, $char(10), "<br>")
119149
120- <script language="cache" method="PerformSync">
121- &js<document.getElementById('syncBtn').innerHTML = 'Syncing...'>
122- &js<document.getElementById('syncBtn').disabled = true>
150+ &js<
151+ var outputContainer = document.getElementById('outputBox');
152+ var lineText = "#(escapedLine)#";
153+ var lineTextNode = document.createTextNode(lineText);
154+ outputContainer.innerHTML += lineText + "<br>";
155+ >
156+ }
157+ &js<document.getElementById('syncBtn').innerHTML = 'Synced'>
123158 </script>
124- </html>
159+ </html>
160+ <script method='OnPreHTTP' language='cache' runat='server' returntype='%Boolean'>
161+ try {
162+ set %session.UseSessionCookie = 1 // Always set back to autodetect
163+ set %session.CookiePath = "" // Always clear
164+ if (%request.UserAgent [ " Code/") {
165+ // Workaround for VSCode webview
166+ set %session.SessionScope = 0 // none; allowed because...
167+ set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
168+ }
169+ } catch e {
170+ // ignore; may occur on platform versions without the above properties
171+ }
172+ quit 1
173+ </script>
174+ <script method='OnPreHyperEvent' arguments="class:%String,method:%String" language='cache' runat='server' returntype='%Status'>
175+ try {
176+ set %session.UseSessionCookie = 1 // Always set back to autodetect
177+ set %session.CookiePath = "" // Always clear
178+ if (%request.UserAgent [ " Code/") {
179+ // Workaround for VSCode webview
180+ set %session.SessionScope = 0 // none; allowed because...
181+ set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
182+ }
183+ } catch e {
184+ // ignore; may occur on platform versions without the above properties
185+ }
186+ quit 1
187+ </script>
0 commit comments