chore
							parent
							
								
									556f673b3e
								
							
						
					
					
						commit
						733dada3fe
					
				
							
								
								
									
										43
									
								
								app.go
								
								
								
								
							
							
						
						
									
										43
									
								
								app.go
								
								
								
								
							|  | @ -27,6 +27,7 @@ type Page struct { | ||||||
| 	BaseUrl      string | 	BaseUrl      string | ||||||
| 	Actions      []Action | 	Actions      []Action | ||||||
| 	Integrations []*Integration | 	Integrations []*Integration | ||||||
|  | 	Onitachi     map[string]*Oni | ||||||
| 	Version      string | 	Version      string | ||||||
| 	Build        string | 	Build        string | ||||||
| 	Files        []ActiveFile | 	Files        []ActiveFile | ||||||
|  | @ -79,6 +80,7 @@ func (cui *ConfigUI) App(w http.ResponseWriter, r *http.Request) { | ||||||
| 		}, | 		}, | ||||||
| 		Actions:      cui.Actions, | 		Actions:      cui.Actions, | ||||||
| 		Integrations: cui.Integrations, | 		Integrations: cui.Integrations, | ||||||
|  | 		Onitachi:     cui.Onitachi, | ||||||
| 		Static:       cui.NoReconfig, | 		Static:       cui.NoReconfig, | ||||||
| 		HideConfig:   cui.HideConfig, | 		HideConfig:   cui.HideConfig, | ||||||
| 		ResultBellow: cui.ResultBellow, | 		ResultBellow: cui.ResultBellow, | ||||||
|  | @ -127,3 +129,44 @@ func (cui *ConfigUI) App(w http.ResponseWriter, r *http.Request) { | ||||||
| 		panic(err) | 		panic(err) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func (cui *ConfigUI) Program(w http.ResponseWriter, r *http.Request) { | ||||||
|  | 	Files := []ActiveFile{} | ||||||
|  | 	for _, i := range cui.fileIndex { | ||||||
|  | 		Files = append(Files, ActiveFile{ | ||||||
|  | 			Name:  cui.Files[i].Name, | ||||||
|  | 			Path:  cui.Files[i].Path, | ||||||
|  | 			Order: cui.Files[i].Order, | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | 	sort.Slice(Files, func(i, j int) bool { | ||||||
|  | 		if Files[i].Order == Files[j].Order { | ||||||
|  | 			return Files[i].Name < Files[j].Name | ||||||
|  | 		} | ||||||
|  | 		return Files[i].Order < Files[j].Order | ||||||
|  | 	}) | ||||||
|  | 	plat := "unix" | ||||||
|  | 	if runtime.GOOS == "windows" { | ||||||
|  | 		plat = "windows" | ||||||
|  | 	} | ||||||
|  | 	data := Page{ | ||||||
|  | 		AppName: cui.AppName, | ||||||
|  | 		BaseUrl: cui.BaseUrl, | ||||||
|  | 		File:    ActiveFile{}, | ||||||
|  | 		Files:   Files, | ||||||
|  | 		Editor: Editor{ | ||||||
|  | 			Platform: plat, | ||||||
|  | 		}, | ||||||
|  | 		Actions:      cui.Actions, | ||||||
|  | 		Integrations: cui.Integrations, | ||||||
|  | 		Onitachi:     cui.Onitachi, | ||||||
|  | 		Static:       cui.NoReconfig, | ||||||
|  | 		HideConfig:   cui.HideConfig, | ||||||
|  | 		Version:      version, | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	err := cui.tmpl.ExecuteTemplate(w, "muzan", data) | ||||||
|  | 	if err != nil { | ||||||
|  | 		panic(err) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -152,6 +152,7 @@ func (cui *ConfigUI) mux() *http.ServeMux { | ||||||
| 		} | 		} | ||||||
| 	}) | 	}) | ||||||
| 	cuiR.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.FS(cui.PublicFS)))) | 	cuiR.Handle("/public/", http.StripPrefix("/public/", http.FileServer(http.FS(cui.PublicFS)))) | ||||||
|  | 	cuiR.HandleFunc("/program", cui.Program) | ||||||
| 	cuiR.HandleFunc("/", cui.App) | 	cuiR.HandleFunc("/", cui.App) | ||||||
| 	return cuiR | 	return cuiR | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,7 +0,0 @@ | ||||||
| {{define "action"}} |  | ||||||
| {{template "base/header" .}} |  | ||||||
| {{template "components/error" .}} |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| {{template "base/footer" .}} |  | ||||||
| {{end}} |  | ||||||
|  | @ -6,11 +6,6 @@ | ||||||
|       </p> |       </p> | ||||||
|     </div> |     </div> | ||||||
|   </footer> |   </footer> | ||||||
|   <script src="{{.BaseUrl}}public/ace/js/ace.js" type="text/javascript" charset="utf-8"></script> |  | ||||||
|   <script src="{{.BaseUrl}}public/ace/js/ext-beautify.js" type="text/javascript" charset="utf-8"></script> |  | ||||||
|   <script src="{{.BaseUrl}}public/ace/js/ext-searchbox.js" type="text/javascript" charset="utf-8"></script> |  | ||||||
|   {{template "base/script" .}} |  | ||||||
|   <!-- <script src="/public/js/main.js"></script> --> |  | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
| {{end}} | {{end}} | ||||||
|  | @ -1,4 +1,8 @@ | ||||||
| {{define "base/script"}} | {{define "base/script"}} | ||||||
|  | 
 | ||||||
|  | <script src="{{.BaseUrl}}public/ace/js/ace.js" type="text/javascript" charset="utf-8"></script> | ||||||
|  | <script src="{{.BaseUrl}}public/ace/js/ext-beautify.js" type="text/javascript" charset="utf-8"></script> | ||||||
|  | <script src="{{.BaseUrl}}public/ace/js/ext-searchbox.js" type="text/javascript" charset="utf-8"></script> | ||||||
| <script> | <script> | ||||||
| window.ToolIsFollow = false; | window.ToolIsFollow = false; | ||||||
| window.LastDelta = 0; | window.LastDelta = 0; | ||||||
|  |  | ||||||
|  | @ -14,24 +14,26 @@ | ||||||
|       </li> |       </li> | ||||||
|       {{ end }} |       {{ end }} | ||||||
|     </ul> |     </ul> | ||||||
|     {{/* {{if .Actions}} |     {{if .Onitachi}} | ||||||
|     <p class="menu-label"> |     <p class="menu-label"> | ||||||
|       Actions |       Programs | ||||||
|     </p> |     </p> | ||||||
|     <ul class="menu-list"> |     <ul class="menu-list"> | ||||||
|       {{- range .Actions -}} |       {{- range $key, $value := .Onitachi -}} | ||||||
|       <li> |       <li> | ||||||
|         <a class="button has-tooltip-arrow {{.State|state_class}}" id="actbtn-{{.Name|normal}}" |         <a class="has-tooltip-arrow" data-tooltip="{{$value.Cmd}}" href="{{$.BaseUrl}}program?name={{.Name}}"> | ||||||
|           data-tooltip="{{.Cmd}}" onclick="toolDoAction('{{.Name}}')"> |           <div class="level"> | ||||||
|           <span>{{- .Name -}}</span> |           <span>{{$key}}</span> | ||||||
|           <span class="icon is-small"><span class="material-icons"> |             <div class="tags has-addons"> | ||||||
|             {{.State|state_icon}} |               <span class="tag">State</span> | ||||||
|           </span></span> |               <span class="tag {{$value.State|state_class}}">{{$value.State}}</span> | ||||||
|  |             </div> | ||||||
|  |           </div> | ||||||
|         </a> |         </a> | ||||||
|       </li> |       </li> | ||||||
|       {{- end -}} |       {{- end -}} | ||||||
|     </ul> |     </ul> | ||||||
|     {{end}} */}} |     {{end}} | ||||||
|     {{if not .HideConfig}} |     {{if not .HideConfig}} | ||||||
|     <p class="menu-label"> |     <p class="menu-label"> | ||||||
|       System |       System | ||||||
|  |  | ||||||
|  | @ -80,5 +80,6 @@ async function toolDoIntegration(name){ | ||||||
| {{if not .ResultBellow}} | {{if not .ResultBellow}} | ||||||
| {{template "components/result" .}} | {{template "components/result" .}} | ||||||
| {{end}} | {{end}} | ||||||
|  | {{template "base/script" .}} | ||||||
| {{template "base/footer" .}} | {{template "base/footer" .}} | ||||||
| {{end}} | {{end}} | ||||||
|  | @ -0,0 +1,73 @@ | ||||||
|  | {{define "muzan"}} | ||||||
|  | {{template "base/header" .}} | ||||||
|  | {{template "components/error" .}} | ||||||
|  | <script> | ||||||
|  | var Active = "{{.File.Name}}"; | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <div class="columns"> | ||||||
|  |   <div class="column is-one-quarter"> | ||||||
|  |     <div class="box"> | ||||||
|  |       {{template "components/menu" .}} | ||||||
|  |     </div> | ||||||
|  |     {{if .Actions}} | ||||||
|  |     <div class="box"> | ||||||
|  |       <p class="menu-label has-text-left">Actions</p> | ||||||
|  |       <div class="buttons are-small"> | ||||||
|  |       {{- range .Actions -}} | ||||||
|  |         <button class="button has-tooltip-arrow" id="actbtn-{{.Name|normal}}" | ||||||
|  |           data-tooltip="{{.Cmd}}" onclick="toolDoAction('{{.Name}}')"> | ||||||
|  |           <span>{{- .Name -}}</span> | ||||||
|  |         </button> | ||||||
|  |       {{- end -}} | ||||||
|  |       </div> | ||||||
|  |     </div> | ||||||
|  |     {{end}} | ||||||
|  |     {{if .Integrations}} | ||||||
|  |     <div class="box"> | ||||||
|  |       <p class="menu-label has-text-left">Integrations</p> | ||||||
|  |       <div class="buttons are-small"> | ||||||
|  |       {{- range .Integrations -}} | ||||||
|  |         <button class="button has-tooltip-arrow" id="itgbtn-{{.Name|normal}}" | ||||||
|  |           data-tooltip="{{.Description}}" onclick="toolDoIntegration('{{.Name}}')"> | ||||||
|  |           <span>{{- .Name -}}</span> | ||||||
|  |         </button> | ||||||
|  |       {{- end -}} | ||||||
|  |       </div> | ||||||
|  |     </div> | ||||||
|  |     {{end}} | ||||||
|  |     <div class="box has-text-centered"> | ||||||
|  |       <a href="{{.BaseUrl}}api/export" class="button is-small">Export Files</a> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  |   <div class="column"> | ||||||
|  |     <div class="box"> | ||||||
|  |       Home | ||||||
|  |       {{/* {{template "components/editor" .}} */}} | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  | 
 | ||||||
|  | <script> | ||||||
|  | async function toolDoAction(name){ | ||||||
|  |   let el = document.getElementById('actbtn-'+name.replaceAll(" ","-")); | ||||||
|  |   el.classList.add("is-loading") | ||||||
|  |   el.classList.remove("has-tooltip-arrow") | ||||||
|  |   await DoAction('action',name) | ||||||
|  |   el.classList.remove("is-loading") | ||||||
|  |   el.classList.add("has-tooltip-arrow") | ||||||
|  |   {{if not .ResultBellow}}ResultViewTog(){{end}} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | async function toolDoIntegration(name){ | ||||||
|  |   let el = document.getElementById('itgbtn-'+name.replaceAll(" ","-")); | ||||||
|  |   el.classList.add("is-loading") | ||||||
|  |   el.classList.remove("has-tooltip-arrow") | ||||||
|  |   await DoAction('integration',name) | ||||||
|  |   el.classList.remove("is-loading") | ||||||
|  |   el.classList.add("has-tooltip-arrow") | ||||||
|  |   {{if not .ResultBellow}}ResultViewTog(){{end}} | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  | {{template "base/footer" .}} | ||||||
|  | {{end}} | ||||||
		Loading…
	
		Reference in New Issue