1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+ <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
8
+ <link rel="stylesheet" type="text/css" href="css/git-webui.css" />
9
+ #(##class(SourceControl.Git.Utils).GetSourceControlInclude())#
10
+ <style type="text/css">
11
+ h1, h2 {
12
+ margin-top: 10px
13
+ }
14
+
15
+ .A::after {
16
+ content: "Added";
17
+ position: absolute;
18
+ right: 10px;
19
+ }
20
+
21
+ .D::after {
22
+ content: "Deleted";
23
+ position: absolute;
24
+ right: 10px;
25
+ }
26
+
27
+ .M::after {
28
+ content: "Modified";
29
+ position: absolute;
30
+ right: 10px;
31
+ }
32
+
33
+ .R::after {
34
+ content: "Renamed";
35
+ position: absolute;
36
+ right: 10px;
37
+ }
38
+
39
+ .section-header {
40
+ margin: 20px 0 15px 0
41
+ }
42
+
43
+ #syncBtn {
44
+ position: absolute;
45
+ right: 15px;
46
+ margin-top: 10px;
47
+ }
48
+
49
+ .output-header {
50
+ margin-top: 120px;
51
+ }
52
+ .output {
53
+
54
+ margin-bottom: 20px;
55
+ border: 1.5px solid darkgray;
56
+ padding: 10px;
57
+ border-radius: 4px;
58
+ }
59
+
60
+ </style>
61
+ </head>
62
+ <body>
63
+ <server>
64
+ set settings = ##class(SourceControl.Git.Settings).%New()
65
+
66
+ set uncommittedWithAction = ##class(SourceControl.Git.Utils).UncommittedWithAction().%Get("user")
67
+ set commitMsg = ##class(SourceControl.Git.Utils).GenerateCommitMessageFromFiles(uncommittedWithAction)
68
+ set filesToSync = ($length(commitMsg) > 0)
69
+ set fileSectionDisplay = $select(
70
+ filesToSync = 1: "block",
71
+ 1: "none"
72
+ )
73
+ set noFileDisplay = $select(
74
+ filesToSync = 0: "block",
75
+ 1: "none"
76
+ )
77
+
78
+ set outputDisplay = "none"
79
+
80
+ </server>
81
+
82
+ <div class="container">
83
+ <h1 class="text-center">Sync Repository</h1>
84
+ <div class="row">
85
+ <div class="offset-sm-2 col-sm-8">
86
+ <div style="display: #(fileSectionDisplay)#">
87
+ <h3 class="section-header">Files to be committed with sync:</h3>
88
+ <ul class="list-group">
89
+ <server>
90
+ set iterator = uncommittedWithAction.%GetIterator()
91
+ while iterator.%GetNext(,.uncommitted) {
92
+ set action = uncommitted.%Get("action")
93
+ set file = uncommitted.%Get("file")
94
+ &html<<li class="list-group-item #(..EscapeHTML(action))#">#(..EscapeHTML(file))#</li>>
95
+ }
96
+ </server>
97
+ </ul>
98
+ <h3 class="section-header">Sync commit message:</h3>
99
+ <input class="form-control" type="text" name="syncMsg" id="syncMsg" value="#(..EscapeHTML(commitMsg))#">
100
+ </div>
101
+ <div style="display: #(noFileDisplay)#">
102
+ <h2 class="text-center">No files to commit with sync</h2>
103
+ </div>
104
+ <h3 class="section-header">Sync details:</h3>
105
+ <p>Upon syncing, the local repository will pull the changes from remote and commit the newest changes before committing and pushing</p>
106
+ <server>
107
+
108
+ if settings.defaultMergeBranch '= "" {
109
+ &html<<p>Local changes will be merged with #(..EscapeHTML(settings.defaultMergeBranch))# after receiving the latest changes</p>>
110
+ }
111
+ </server>
112
+
113
+ <button class="btn btn-lg btn-primary" id="syncBtn" onClick="disableInput(); #server(..PerformSync(self.document.getElementById('syncMsg').value))#">Sync</button>
114
+ <div>
115
+ <h3 class="output-header" id="outputHeader" style="display: #(outputDisplay)#">Sync output: </h3>
116
+ <div class="container output" id="outputContainer" style="display: #(outputDisplay)#">
117
+ <pre id="outputBox"></pre>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
122
+
123
+ </div>
124
+ </body>
125
+ <script type="text/javascript">
126
+ function disableInput() {
127
+ document.getElementById('syncMsg').disabled = true;
128
+ document.getElementById('syncBtn').innerHTML = 'Syncing...';
129
+ document.getElementById('syncBtn').disabled = true;
130
+ }
131
+ </script>
132
+ <script language="cache" method="PerformSync" arguments="syncMsg:%String">
133
+ &js<document.getElementById('outputContainer').style.display = 'block'>
134
+ &js<document.getElementById('outputHeader').style.display = 'block'>
135
+ set buffer = ##class(SourceControl.Git.Util.Buffer).%New()
136
+ do buffer.BeginCaptureOutput()
137
+
138
+ set st = ##class(SourceControl.Git.Utils).Sync(syncMsg)
139
+
140
+ set out = ##class(%Stream.GlobalCharacter).%New()
141
+ do buffer.EndCaptureOutput(.out)
142
+ while 'out.AtEnd {
143
+ set line = out.ReadLine()
144
+ set escapedLine = ..EscapeHTML(line)
145
+ set escapedLine = $replace(escapedLine, $char(10), "<br>")
146
+
147
+ &js<
148
+ var outputContainer = document.getElementById('outputBox');
149
+ var lineText = "#(escapedLine)#";
150
+ var lineTextNode = document.createTextNode(lineText);
151
+ outputContainer.innerHTML += lineText + "<br>";
152
+ >
153
+ }
154
+ &js<document.getElementById('syncBtn').innerHTML = 'Synced'>
155
+ </script>
156
+ </html>
157
+ <script method='OnPreHTTP' language='cache' runat='server' returntype='%Boolean'>
158
+ try {
159
+ set %session.UseSessionCookie = 1 // Always set back to autodetect
160
+ set %session.CookiePath = "" // Always clear
161
+ if (%request.UserAgent [ " Code/") {
162
+ // Workaround for VSCode webview
163
+ set %session.SessionScope = 0 // none; allowed because...
164
+ set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
165
+ }
166
+ } catch e {
167
+ // ignore; may occur on platform versions without the above properties
168
+ }
169
+ quit 1
170
+ </script>
171
+ <script method='OnPreHyperEvent' arguments="class:%String,method:%String" language='cache' runat='server' returntype='%Status'>
172
+ try {
173
+ set %session.UseSessionCookie = 1 // Always set back to autodetect
174
+ set %session.CookiePath = "" // Always clear
175
+ if (%request.UserAgent [ " Code/") {
176
+ // Workaround for VSCode webview
177
+ set %session.SessionScope = 0 // none; allowed because...
178
+ set %session.SecureSessionCookie = 1 // secure flag on session cookie - will be ignored over http, but that's OK because we already have it
179
+ }
180
+ } catch e {
181
+ // ignore; may occur on platform versions without the above properties
182
+ }
183
+ quit 1
184
+ </script>
0 commit comments