Fix run of AboutMe.app
This commit is contained in:
parent
56038cc284
commit
9cc2dc5a42
@ -39,6 +39,25 @@ type ApplicationsStorage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (as *ApplicationsStorage) createApp(appName string, appId string, appPath string) error {
|
func (as *ApplicationsStorage) createApp(appName string, appId string, appPath string) error {
|
||||||
|
appBundleName := appName + ".app"
|
||||||
|
newAppBundleHeader := webfilesystem.FileHeader{
|
||||||
|
MongoId: primitive.NewObjectID(),
|
||||||
|
Name: appBundleName,
|
||||||
|
Type: "directory",
|
||||||
|
Icon: "",
|
||||||
|
Data: primitive.NewObjectID(),
|
||||||
|
}
|
||||||
|
newAppBundleData := webfilesystem.DirectoryData{
|
||||||
|
MongoId: primitive.NewObjectID(),
|
||||||
|
Parent: primitive.NewObjectID(),
|
||||||
|
Children: []primitive.ObjectID{},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, err := as.fs.Write(appPath+"/"+appBundleName, &newAppBundleHeader, &newAppBundleData)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
newAppData := ApplicationManifest{
|
newAppData := ApplicationManifest{
|
||||||
AppId: appId,
|
AppId: appId,
|
||||||
Js: []string{},
|
Js: []string{},
|
||||||
@ -52,9 +71,7 @@ func (as *ApplicationsStorage) createApp(appName string, appId string, appPath s
|
|||||||
Icon: "",
|
Icon: "",
|
||||||
Data: primitive.NewObjectID(),
|
Data: primitive.NewObjectID(),
|
||||||
}
|
}
|
||||||
|
_, _, err = as.fs.Write(appPath+"/"+appBundleName+"/"+newAppFile.Name, &newAppFile, newAppData)
|
||||||
//TODO: Create folder for app, etc
|
|
||||||
_, _, err := as.fs.Write(appPath+"/"+newAppFile.Name, &newAppFile, newAppData)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -118,7 +135,7 @@ func (aStorage *ApplicationsStorage) PrivateRoute(route *gin.RouterGroup) {
|
|||||||
|
|
||||||
err := aStorage.createApp(appId, appName, appPath)
|
err := aStorage.createApp(appId, appName, appPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.Status(http.StatusInternalServerError)
|
ctx.String(http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ctx.Status(http.StatusOK)
|
ctx.Status(http.StatusOK)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class AboutMe{
|
class AboutMe{
|
||||||
appId = "AboutMe"
|
static appID = "AboutMe"
|
||||||
/**
|
/**
|
||||||
* @param {HTMLElement} appElem
|
* @param {HTMLElement} appElem
|
||||||
*/
|
*/
|
||||||
@ -8,16 +8,17 @@ class AboutMe{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} chroot
|
* @param {[]string} args
|
||||||
* @param {[]string} args
|
* @param {Object} runContext
|
||||||
*/
|
*/
|
||||||
async NewWindow(chroot, args){
|
async NewWindow(args, runContext){
|
||||||
console.log(chroot)
|
console.log(runContext)
|
||||||
if (chroot == ""){
|
const params = new URLSearchParams({
|
||||||
chroot = "/Applications" //FIXME
|
isMobile: WebDesktopEnvironment.isMobile,
|
||||||
}
|
path: `${runContext.bundlePath}/aboutme.props`,
|
||||||
const params = new URLSearchParams({isMobile: WebDesktopEnvironment.isMobile, path: `${chroot}/AboutMe.app/aboutme.props`})
|
runContext: runContext,
|
||||||
const response = await fetch(`/app/${this.appId}/render?`+ params)
|
})
|
||||||
|
const response = await fetch(`/app/${AboutMe.appID}/render?`+ params)
|
||||||
if (response.status != 200){
|
if (response.status != 200){
|
||||||
WebDesktopEnvironment.Alert("Error TODO") //TODO
|
WebDesktopEnvironment.Alert("Error TODO") //TODO
|
||||||
return
|
return
|
@ -41,7 +41,7 @@ class FinderWindow{
|
|||||||
windowElem = undefined
|
windowElem = undefined
|
||||||
|
|
||||||
async Init(args){
|
async Init(args){
|
||||||
// console.log(args)
|
console.log(args)
|
||||||
if (args[1] === "-desktop"){
|
if (args[1] === "-desktop"){
|
||||||
//todo pass div id, not div in args[]
|
//todo pass div id, not div in args[]
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
@ -131,11 +131,11 @@ class FinderWindow{
|
|||||||
WebDesktopEnvironment.Alert("UWAGA TODO MOVE FILE ERROR") //TODO
|
WebDesktopEnvironment.Alert("UWAGA TODO MOVE FILE ERROR") //TODO
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(event)
|
console.log(event, this.curPath)
|
||||||
let files = event.dataTransfer.files
|
let files = event.dataTransfer.files
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
const file = files[i];
|
const file = files[i];
|
||||||
console.log("file:" + file)
|
console.log("file:" + file.name)
|
||||||
|
|
||||||
const res = await WebFS.UploadFile(file, this.curPath)
|
const res = await WebFS.UploadFile(file, this.curPath)
|
||||||
if (res){
|
if (res){
|
||||||
|
@ -36,7 +36,8 @@ class WebDesktopEnvironment{
|
|||||||
async loadWDE(){
|
async loadWDE(){
|
||||||
// await WebDesktopEnvironment.load2('/Applications/Finder.app', [ "desktop", document.querySelector('#desktop-layer')])
|
// await WebDesktopEnvironment.load2('/Applications/Finder.app', [ "desktop", document.querySelector('#desktop-layer')])
|
||||||
await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/.desktop", "-desktop", document.querySelector('#desktop-layer')])
|
await WebDesktopEnvironment.Open('/Applications/Finder.app', ["/home/user/.desktop", "-desktop", document.querySelector('#desktop-layer')])
|
||||||
WebDesktopEnvironment.Open('/Applications/Finder.app', ["/",])
|
// WebDesktopEnvironment.Open('/Applications/Finder.app', ["/",])
|
||||||
|
WebDesktopEnvironment.Open('/Applications/AboutMe.app', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,16 +45,21 @@ class WebDesktopEnvironment{
|
|||||||
* @param {string[]} args
|
* @param {string[]} args
|
||||||
*/
|
*/
|
||||||
static async Open(appPath, args){
|
static async Open(appPath, args){
|
||||||
WebDesktopEnvironment.fetchApp(appPath).then(async appManifest =>{
|
const appManifest = await WebDesktopEnvironment.fetchApp(appPath)
|
||||||
if (appManifest === undefined) return //TODO return err
|
|
||||||
if (WebDesktopEnvironment.Applications[appManifest.appId] === undefined){
|
if (appManifest === undefined) return //TODO return err
|
||||||
WebDesktopEnvironment.load2(appManifest, () =>{
|
const runContext = {
|
||||||
WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args)
|
bundlePath: appPath,
|
||||||
})
|
runPath: "todo" //TODO
|
||||||
} else {
|
}
|
||||||
WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args)
|
if (WebDesktopEnvironment.Applications[appManifest.appId] === undefined){
|
||||||
}
|
WebDesktopEnvironment.load2(appManifest, () =>{
|
||||||
})
|
WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args, runContext)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
WebDesktopEnvironment.Applications[appManifest.appId].NewWindow(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +76,8 @@ class WebDesktopEnvironment{
|
|||||||
script.setAttribute("src", appManifest.js[0]) //FIXME path by fs read
|
script.setAttribute("src", appManifest.js[0]) //FIXME path by fs read
|
||||||
script.setAttribute("async", "false") //TODO Possible may creates a problems??
|
script.setAttribute("async", "false") //TODO Possible may creates a problems??
|
||||||
appElem.appendChild(script)
|
appElem.appendChild(script)
|
||||||
|
|
||||||
|
console.log(appElem)
|
||||||
document.getElementById("applications").appendChild(appElem)
|
document.getElementById("applications").appendChild(appElem)
|
||||||
script.addEventListener('load', (event) => {
|
script.addEventListener('load', (event) => {
|
||||||
let newApp = eval(`new ${appManifest.appId}()`);
|
let newApp = eval(`new ${appManifest.appId}()`);
|
||||||
@ -372,15 +379,15 @@ class WebFS{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {File} file
|
* @param {File} file
|
||||||
* @param {string} filePath
|
* @param {string} parentPath
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
static async UploadFile(file, filePath){
|
static async UploadFile(file, parentPath){
|
||||||
console.log('here')
|
console.log('here')
|
||||||
let formData = new FormData()
|
let formData = new FormData()
|
||||||
formData.append("file", file) //FIXME Conn reset
|
formData.append("file", file) //FIXME Conn reset
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
filePath: filePath,
|
parentPath: parentPath,
|
||||||
})
|
})
|
||||||
const response = await fetch(`/system/fs/upload?` + params,
|
const response = await fetch(`/system/fs/upload?` + params,
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@ package webfilesystem
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"path"
|
||||||
"personalwebsite/errormessage"
|
"personalwebsite/errormessage"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -15,8 +16,8 @@ func (fs *WebFileSystem) PrivateRoutes(route *gin.RouterGroup) {
|
|||||||
// ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
// ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||||
// return
|
// return
|
||||||
// }
|
// }
|
||||||
filePath := ctx.Query("filePath")
|
parentPath := ctx.Query("parentPath")
|
||||||
if filePath == "" {
|
if parentPath == "" {
|
||||||
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
ctx.JSON(http.StatusBadRequest, "TODO") //TODO json error struct
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ func (fs *WebFileSystem) PrivateRoutes(route *gin.RouterGroup) {
|
|||||||
ctx.SaveUploadedFile(file, dst)
|
ctx.SaveUploadedFile(file, dst)
|
||||||
|
|
||||||
//TODO: Not Save to disk
|
//TODO: Not Save to disk
|
||||||
err := fs.UploadFile(dst, filePath)
|
err := fs.UploadFile(dst, path.Join(parentPath, file.Filename))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.JSON(http.StatusInternalServerError, errormessage.ErrorMessage{
|
ctx.JSON(http.StatusInternalServerError, errormessage.ErrorMessage{
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
|
Loading…
Reference in New Issue
Block a user