@@ -133,7 +133,7 @@ do ##class(kutac.monitor.utils.Installer).setup(.pVars)</Description>
133133<Implementation ><![CDATA[
134134 Set Namespace=tInstaller.Evaluate("${Namespace}")
135135 Do tInstaller.PushNS("%SYS")
136- Set tSC = ..Update(Namespace, "intersystems-ru", "deepsee-sysmon-dashboards", "master ")
136+ Set tSC = ..Update(Namespace, "intersystems-ru", "deepsee-sysmon-dashboards", "UDL ")
137137 Do tInstaller.PopNS()
138138 If $$$ISERR(tSC) Throw ##class(%Installer.Exception).CreateFromStatus(tSC)
139139 quit $$$OK
@@ -169,7 +169,7 @@ do ##class(kutac.monitor.utils.Installer).setup(.pVars)</Description>
169169
170170 Zn Namespace
171171 Set st = ..DownloadFiles(links,req,.list)
172- Set st2 = $system.OBJ.CompileList(.list )
172+ Set st2 = $system.OBJ.CompileAll( )
173173 Zn namespace
174174
175175 Return $$$ADDSC(st, st2)
@@ -216,7 +216,7 @@ do ##class(kutac.monitor.utils.Installer).setup(.pVars)</Description>
216216<FormalSpec >File:%ZEN.proxyObject</FormalSpec >
217217<ReturnType >%Boolean</ReturnType >
218218<Implementation ><![CDATA[
219- Set extensions = ",xml,cls,csp,csr,mac,int,bas,inc,gbl,prj,obj,pkg,gof,"
219+ Set extensions = ",xml,cls,csp,csr,mac,int,bas,inc,gbl,prj,obj,pkg,gof,js,html,css "
220220 Return:($L(File.name,".")=1) 0 //no extension
221221 Set File.Extension = $P(File.name,".",$L(File.name,"."))
222222 Return $F(extensions,","_$ZCVT(File.Extension,"l")_",")
@@ -233,18 +233,261 @@ do ##class(kutac.monitor.utils.Installer).setup(.pVars)</Description>
233233 Set st = $$$OK
234234
235235 For i = 1:1:Links.Count() {
236- Set streq = Request.Get($e(Links.GetAt(i),35,*)) // Remove "https://raw.githubusercontent.com/" from URL.
236+ Set link = Links.GetAt(i)
237+ Set streq = Request.Get($e(link,35,*)) // Remove "https://raw.githubusercontent.com/" from URL.
237238 Set:$$$ISERR(streq) st=$$$ADDSC(st, streq)
238- Set stload = $system.OBJ.LoadStream(Request.HttpResponse.Data,"",.error,.items)
239+
240+ Set binarystream = Request.HttpResponse.Data
241+ Do binarystream.Rewind() // just in case
242+
243+ Set stream=##class(%GlobalCharacterStream).%New() //translating binary stream into character stream
244+ While 'binarystream.AtEnd {
245+ Do stream.WriteLine(binarystream.ReadLine())
246+ }
247+ Do stream.Rewind()
248+
249+
250+ Set strload = ""
251+ If ..IsUDLFormat(stream, link) {
252+ Set stload = ..LoadUDLFile(stream, link)
253+ }
254+ ElseIf ..IsWebFormat(stream, link)
255+ {
256+ Set stload = ..LoadWebFile(binarystream, link,"csp/")
257+ }
258+ Else {
259+ Set stload = $system.OBJ.LoadStream(stream,"",.error,.items,,,,"UTF8")
260+ }
261+
239262 Set:$$$ISERR(stload) st=$$$ADDSC(st, stload)
240- Merge Items = items
263+ Merge Items = items // Does not overwrite existing array keys: Items(itemname)=""
241264 }
242265
243266 Set Request.Server="api.github.com"
244267 Return st
245268]]> </Implementation >
246269</Method >
247270
271+ <Method name =" IsWebFormat" >
272+ <ClassMethod >1</ClassMethod >
273+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
274+ <ReturnType >%Boolean</ReturnType >
275+ <Implementation ><![CDATA[
276+ set params = $find(url, "?")
277+ if params {
278+ set url = $extract(url, 1, params - 2)
279+ }
280+
281+ Set extensions = "csp,js,html,css"
282+ If $Find(extensions, $Piece(url, ".", *)) {
283+ Set st = ##class(%XML.TextReader).ParseStream(contentStream)
284+ Do contentStream.Rewind()
285+ If $$$ISERR(st) {
286+ Return $$$YES
287+ }
288+ Else {
289+ Return $$$NO
290+ }
291+ }
292+ Else {
293+ Return $$$NO
294+ }
295+ ]]> </Implementation >
296+ </Method >
297+
298+ <UDLText name =" T" >
299+ <Content ><![CDATA[
300+ // Класс не универсальный, загрузку web составляющей нужно прописывать самому. Эта информация для тех кто хочет просто скопипастить этот метод.
301+
302+ ]]> </Content >
303+ </UDLText >
304+
305+ <Method name =" LoadWebFile" >
306+ <ClassMethod >1</ClassMethod >
307+ <FormalSpec >contentStream:%CacheString,url:%String,CSPDirInRepo:%String="csp/"</FormalSpec >
308+ <ReturnType >%Status</ReturnType >
309+ <Implementation ><![CDATA[
310+ Set st = $$$OK
311+
312+ Set filestream = ##class(%Stream.FileCharacter).%New()
313+ Do contentStream.Rewind()
314+ do filestream.Rewind()
315+
316+ set CSPPath = $system.CSP.GetFileName($system.CSP.GetDefaultApp($namespace)_"/")
317+ set fileDirectory = $Piece(url, CSPDirInRepo, 2)
318+ set st = filestream.LinkToFile(CSPPath_fileDirectory)
319+
320+ While 'contentStream.AtEnd
321+ {
322+ Do filestream.WriteLine(contentStream.ReadLine())
323+ }
324+ if $$$ISERR(st) Quit st
325+
326+ set st = filestream.%Save()
327+ Return st
328+ ]]> </Implementation >
329+ </Method >
330+
331+ <Method name =" IsUDLFormat" >
332+ <ClassMethod >1</ClassMethod >
333+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
334+ <ReturnType >%Boolean</ReturnType >
335+ <Implementation ><![CDATA[
336+ set params = $find(url, "?")
337+ if params {
338+ set url = $extract(url, 1, params - 2)
339+ }
340+
341+ Set extensions = "cls,mac,int,inc,dfi"
342+ If $Find(extensions, $Piece(url, ".", *)) {
343+ Set st = ##class(%XML.TextReader).ParseStream(contentStream)
344+ Do contentStream.Rewind()
345+ If $$$ISERR(st) {
346+ Return $$$YES
347+ }
348+ Else {
349+ Return $$$NO
350+ }
351+ }
352+ Else {
353+ Return $$$NO
354+ }
355+ ]]> </Implementation >
356+ </Method >
357+
358+ <Method name =" LoadUDLFile" >
359+ <ClassMethod >1</ClassMethod >
360+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
361+ <ReturnType >%Status</ReturnType >
362+ <Implementation ><![CDATA[
363+ Set st = $$$OK
364+ Set ext = ..GetExt(url)
365+ If ext = "cls" {
366+ Set st = ..CreateClass(contentStream, url)
367+ }
368+ Elseif ext = "dfi" {
369+ Set st = ..CreateDFI(contentStream, url)
370+ }
371+ Else {
372+ Set st = ..CreateOther(contentStream, url)
373+ }
374+
375+ Return st
376+ ]]> </Implementation >
377+ </Method >
378+
379+ <Method name =" GetExt" >
380+ <ClassMethod >1</ClassMethod >
381+ <FormalSpec >url:%String</FormalSpec >
382+ <ReturnType >%String</ReturnType >
383+ <Implementation ><![CDATA[ Return $ZConvert($Piece(url, ".", *), "l")
384+ ]]> </Implementation >
385+ </Method >
386+
387+ <Method name =" CreateClass" >
388+ <ClassMethod >1</ClassMethod >
389+ <FormalSpec >contentStream:%CharacterStream,url:%String</FormalSpec >
390+ <ReturnType >%Status</ReturnType >
391+ <Implementation ><![CDATA[
392+ Set st = ..GetClassName(url, .className)
393+ Do contentStream.Rewind()
394+ Return:$$$ISERR(st) st
395+
396+ If '..IsClassExist(className) {
397+ Set clsDef = ##class(%Dictionary.ClassDefinition).%New()
398+ Set clsDef.Name = className
399+ Set st = clsDef.%Save()
400+ Return:$$$ISERR(st) st
401+ }
402+
403+
404+ Set namespace = $namespace
405+
406+ Set st = ##class(%Compiler.UDL.TextServices).SetTextFromStream(namespace, className, contentStream)
407+ Return st
408+ ]]> </Implementation >
409+ </Method >
410+
411+ <Method name =" GetClassName" >
412+ <ClassMethod >1</ClassMethod >
413+ <FormalSpec ><![CDATA[ url:%String,&name]]> </FormalSpec >
414+ <ReturnType >%Status</ReturnType >
415+ <Implementation ><![CDATA[
416+ Set formattedUrl = $Translate($Translate(url, "\", "/"), "/", ".")
417+ Set name = $Replace($Extract(formattedUrl, $Find(formattedUrl, "cls."), *), ".cls", "")
418+ Return $$$OK
419+ ]]> </Implementation >
420+ </Method >
421+
422+ <Method name =" IsClassExist" >
423+ <ClassMethod >1</ClassMethod >
424+ <FormalSpec >className:%String</FormalSpec >
425+ <ReturnType >%Boolean</ReturnType >
426+ <Implementation ><![CDATA[
427+ Set query = "SELECT TOP 1 COUNT(ID) FROM %Dictionary.ClassDefinition WHERE ID = ?"
428+ Set statement = ##class(%SQL.Statement).%New()
429+ Set st = statement.%Prepare(query)
430+ Set rset = statement.%Execute(className)
431+ If rset.%Next() && (rset.%ROWCOUNT > 0) {
432+ Return 1
433+ }
434+ Return 0
435+ ]]> </Implementation >
436+ </Method >
437+
438+ <Method name =" CreateDFI" >
439+ <ClassMethod >1</ClassMethod >
440+ <FormalSpec >contentStream:%CharacterStream,url:%String</FormalSpec >
441+ <ReturnType >%Status</ReturnType >
442+ <Implementation ><![CDATA[
443+ Set st = $$$OK
444+ Try {
445+ Set st = ..GetDFIName(url, .name)
446+ Return:$$$ISERR(st) st
447+
448+ Set tDoc = ##class(%DeepSee.UI.FolderItemDocument).%New(name)
449+ Set st = tDoc.ImportFromXML(contentStream)
450+ Return:$$$ISERR(st) st
451+
452+ Set st = tDoc.Save()
453+ Return:$$$ISERR(st) st
454+ } Catch e {
455+ Set st = e.AsStatus()
456+ }
457+ Return st
458+ ]]> </Implementation >
459+ </Method >
460+
461+ <Method name =" GetDFIName" >
462+ <ClassMethod >1</ClassMethod >
463+ <FormalSpec ><![CDATA[ url:%String,&name]]> </FormalSpec >
464+ <ReturnType >%Status</ReturnType >
465+ <Implementation ><![CDATA[
466+ Set formattedUrl = $Translate($Translate(url, "\", "/"), "/", ".")
467+ Set name = $Replace($Extract(formattedUrl, $Find(formattedUrl, "dfi."), *), "%20", " ")
468+ Return $$$OK
469+ ]]> </Implementation >
470+ </Method >
471+
472+ <Method name =" CreateOther" >
473+ <ClassMethod >1</ClassMethod >
474+ <FormalSpec >contentStream:%GlobalCharacterStream,url:%String</FormalSpec >
475+ <ReturnType >%Status</ReturnType >
476+ <Implementation ><![CDATA[
477+ Set internalName = $Piece(url, "/", *)
478+
479+ Set rtn = ##class(%Routine).%New(internalName)
480+ Set status = rtn.CopyFrom(contentStream)
481+ Return:$$$ISERR(status) status
482+
483+ Set status = rtn.Save()
484+ Return:$$$ISERR(status) status
485+
486+ Set status = rtn.Compile()
487+ Return status
488+ ]]> </Implementation >
489+ </Method >
490+
248491<Method name =" ConfiguringMonitor" >
249492<ClassMethod >1</ClassMethod >
250493<FormalSpec >pVars,pLogLevel,tInstaller</FormalSpec >
0 commit comments