Skip to content

Commit

Permalink
add imageformat to directory && add UI to open files
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Feb 21, 2024
1 parent ef2e573 commit 7202680
Show file tree
Hide file tree
Showing 23 changed files with 917 additions and 173 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
9 changes: 9 additions & 0 deletions starsky-tools/mock/api/desktop-editor/open.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{
"subPath": "/20221029_101722_DSC05623.arw",
"fullFilePath": "/data/testcontent//20221029_101722_DSC05623.arw",
"imageFormat": 12,
"status": 8,
"appPath": ""
}
]
2 changes: 1 addition & 1 deletion starsky-tools/mock/api/env/features.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"systemTrashEnabled":false,"useLocalDesktop":false, "openEditorEnabled": false}
{"systemTrashEnabled":false,"useLocalDesktop":false, "openEditorEnabled": true}
84 changes: 55 additions & 29 deletions starsky-tools/mock/set-router.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
const express = require("express");
const path = require("path");

var apiAccountChangeSecretIndex = require("./api/account/change-secret/index.json");
var apiAccountPermissionsIndex = require("./api/account/permissions/index.json");
const apiAccountChangeSecretIndex = require("./api/account/change-secret/index.json");
const apiAccountPermissionsIndex = require("./api/account/permissions/index.json");

var accountStatus = require("./api/account/status/index.json");
var apiHealthDetails = require("./api/health/details/index.json");
var apiHealthCheckForUpdates = require("./api/health/check-for-updates/index.json");
var apiGeoReverseLookup = require("./api/geo-reverse-lookup/index.json");
const accountStatus = require("./api/account/status/index.json");
const apiHealthDetails = require("./api/health/details/index.json");
const apiHealthCheckForUpdates = require("./api/health/check-for-updates/index.json");
const apiGeoReverseLookup = require("./api/geo-reverse-lookup/index.json");

var apiIndexIndex = require("./api/index/index.json");
var apiIndex__Starsky = require("./api/index/__starsky.json");
var apiIndex0001 = require("./api/index/0001.json");
var apiIndex0001_toggleDeleted = require("./api/index/0001_toggleDeleted.json");
const apiIndexIndex = require("./api/index/index.json");
const apiIndex__Starsky = require("./api/index/__starsky.json");
const apiIndex0001 = require("./api/index/0001.json");
const apiIndex0001_toggleDeleted = require("./api/index/0001_toggleDeleted.json");

var apiIndex__Starsky01dif = require("./api/index/__starsky_01-dif.json");
var apiIndex__Starsky01difColorclass0 = require("./api/index/__starsky_01-dif_colorclass0.json");
const apiIndex__Starsky01dif = require("./api/index/__starsky_01-dif.json");
const apiIndex__Starsky01difColorclass0 = require("./api/index/__starsky_01-dif_colorclass0.json");

var apiIndex__Starsky01dif20180101170001 = require("./api/index/__starsky_01-dif-2018.01.01.17.00.01.json");
const apiIndex__Starsky01dif20180101170001 = require("./api/index/__starsky_01-dif-2018.01.01.17.00.01.json");

var apiInfo__testJpg = require("./api/info/test.jpg.json");
const apiInfo__testJpg = require("./api/info/test.jpg.json");

var apiSearchTrash = require("./api/search/trash/index.json");
var apiSearch = require("./api/search/index.json");
var apiSearchTest = require("./api/search/test.json");
var apiSearchTest1 = require("./api/search/test1.json");
var apiUpdate__Starsky01dif20180101170001_Deleted = require("./api/update/__starsky_01-dif-2018.01.01.17.00.01_Deleted.json");
var apiUpdate__Starsky01dif20180101170001_Ok = require("./api/update/__starsky_01-dif-2018.01.01.17.00.01_Ok.json");
const apiSearchTrash = require("./api/search/trash/index.json");
const apiSearch = require("./api/search/index.json");
const apiSearchTest = require("./api/search/test.json");
const apiSearchTest1 = require("./api/search/test1.json");
const apiUpdate__Starsky01dif20180101170001_Deleted = require("./api/update/__starsky_01-dif-2018.01.01.17.00.01_Deleted.json");
const apiUpdate__Starsky01dif20180101170001_Ok = require("./api/update/__starsky_01-dif-2018.01.01.17.00.01_Ok.json");

var apiEnvIndex = require("./api/env/index.json");
var apiEnvFeatures = require("./api/env/features.json");
const apiEnvIndex = require("./api/env/index.json");
const apiEnvFeatures = require("./api/env/features.json");

var apiPublishIndex = require("./api/publish/index.json");
var apiPublishCreateIndex = require("./api/publish/create/index.json");
const apiPublishIndex = require("./api/publish/index.json");
const apiPublishCreateIndex = require("./api/publish/create/index.json");

var githubComReposQdrawStarskyReleaseIndex = require("./github.com/repos/qdraw/starsky/releases/index.json");
const apiDeskopEditorOpen = require("./api/desktop-editor/open.json");

const githubComReposQdrawStarskyReleaseIndex = require("./github.com/repos/qdraw/starsky/releases/index.json");

function setRouter(app, isStoryBook = false) {
var prefix = "/starsky";
const prefix = "/starsky";

app.use(
prefix + "/api/thumbnail",
Expand All @@ -59,7 +61,7 @@ function setRouter(app, isStoryBook = false) {
res.json(accountStatus);
});

var isChangePasswordSuccess = false;
let isChangePasswordSuccess = false;
app.post(prefix + "/api/account/change-secret/", (req, res) => {
console.log(req.body);

Expand Down Expand Up @@ -159,7 +161,7 @@ function setRouter(app, isStoryBook = false) {
return res.json("not found");
});

var isDeleted = true;
let isDeleted = true;
app.post(prefix + "/api/update", (req, res) => {
if (!req.body) {
res.statusCode = 500;
Expand Down Expand Up @@ -248,6 +250,30 @@ function setRouter(app, isStoryBook = false) {
return res.json(apiEnvIndex);
});

app.post(prefix + "/api/desktop-editor/amount-confirmation", (req, res) => {
if (!req.body) {
return res.json("no body ~ the normal api does ignore it");
}
console.log(`amount-confirmation ${req.body.f}`);

return res.json(req.body.f !== "/true.jpg");
});

app.post(prefix + "/api/desktop-editor/open", (req, res) => {
if (!req.body) {
return res.json("no body ~ the normal api does ignore it");
}
console.log(`open ${req.body.f}`);

if (req.body.f === "/true.jpg") {
res.statusCode = 400;
res.json()
return
}

return res.json(apiDeskopEditorOpen);
});

app.get(prefix + "/api/health/application-insights", (req, res) => {
res.set("Content-Type", "application/javascript");
return res.send("");
Expand Down Expand Up @@ -282,7 +308,7 @@ function setRouter(app, isStoryBook = false) {
});

// Simulate waiting
var fakeLoading = {};
let fakeLoading = {};
app.get(prefix + "/export/zip/:id", (req, res) => {
if (!fakeLoading[req.params.id]) {
fakeLoading[req.params.id] = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ private string GetDesktopEditorPath(ExtensionRolesHelper.ImageFormat imageFormat

var appPath = appSettingsDefaultEditor?.ApplicationPath ?? string.Empty;

if ( string.IsNullOrEmpty(appPath) )
{
return string.Empty;
}

// Under Mac OS the ApplicationPath is a .app folder
// Under Windows the ApplicationPath is a .exe file
if ( _hostFileSystem.IsFolderOrFile(appPath) !=
Expand Down
1 change: 1 addition & 0 deletions starsky/starsky.feature.import/Services/Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ private async Task CreateNewDatabaseDirectory(string parentPath)
{
AddToDatabase = DateTime.UtcNow,
IsDirectory = true,
ImageFormat = ExtensionRolesHelper.ImageFormat.directory,
ColorClass = ColorClassParser.Color.None
};

Expand Down
18 changes: 12 additions & 6 deletions starsky/starsky.foundation.database/Helpers/StatusCodesHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using starsky.foundation.database.Models;
using starsky.foundation.platform.Helpers;
using starsky.foundation.platform.Models;

namespace starsky.foundation.database.Helpers
Expand All @@ -16,7 +17,8 @@ public StatusCodesHelper(AppSettings appSettings)

public FileIndexItem.ExifStatus IsReadOnlyStatus(FileIndexItem fileIndexItem)
{
if ( fileIndexItem.IsDirectory == true && _appSettings.IsReadOnly(fileIndexItem.FilePath!) )
if ( fileIndexItem.IsDirectory == true &&
_appSettings.IsReadOnly(fileIndexItem.FilePath!) )
{
return FileIndexItem.ExifStatus.DirReadOnly;
}
Expand Down Expand Up @@ -53,13 +55,16 @@ public FileIndexItem.ExifStatus IsReadOnlyStatus(DetailView? detailView)

public static FileIndexItem.ExifStatus IsDeletedStatus(FileIndexItem? fileIndexItem)
{
return fileIndexItem?.Tags != null && fileIndexItem.Tags.Contains(TrashKeyword.TrashKeywordString) ?
FileIndexItem.ExifStatus.Deleted : FileIndexItem.ExifStatus.Default;
return fileIndexItem?.Tags != null &&
fileIndexItem.Tags.Contains(TrashKeyword.TrashKeywordString)
? FileIndexItem.ExifStatus.Deleted
: FileIndexItem.ExifStatus.Default;
}

public static FileIndexItem.ExifStatus IsDeletedStatus(DetailView? detailView)
{
if ( !string.IsNullOrEmpty(detailView?.FileIndexItem?.Tags) && detailView.FileIndexItem.Tags.Contains(TrashKeyword.TrashKeywordString) )
if ( !string.IsNullOrEmpty(detailView?.FileIndexItem?.Tags) &&
detailView.FileIndexItem.Tags.Contains(TrashKeyword.TrashKeywordString) )
{
return FileIndexItem.ExifStatus.Deleted;
}
Expand All @@ -83,6 +88,7 @@ public static bool ReturnExifStatusError(FileIndexItem statusModel,
{
case FileIndexItem.ExifStatus.DirReadOnly:
statusModel.IsDirectory = true;
statusModel.ImageFormat = ExtensionRolesHelper.ImageFormat.directory;
statusModel.Status = FileIndexItem.ExifStatus.DirReadOnly;
fileIndexResultsList.Add(statusModel);
return true;
Expand All @@ -107,6 +113,7 @@ public static bool ReturnExifStatusError(FileIndexItem statusModel,
fileIndexResultsList.Add(statusModel);
return true;
}

return false;
}

Expand All @@ -120,6 +127,7 @@ public static bool ReadonlyDenied(FileIndexItem statusModel,
fileIndexResultsList.Add(statusModel);
return true;
}

return false;
}

Expand All @@ -132,7 +140,5 @@ public static void ReadonlyAllowed(FileIndexItem statusModel,
statusModel.Status = FileIndexItem.ExifStatus.ReadOnly;
fileIndexResultsList.Add(statusModel);
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public partial class Query
if ( currentFileIndexItem.IsDirectory == true )
{
currentFileIndexItem.CollectionPaths = new List<string> { singleItemDbPath };

return new DetailView
{
IsDirectory = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,10 @@ public enum ImageFormat
mp4 = 50,

// archives
zip = 60
zip = 60,

// folder
directory = 1000
}


Expand Down
1 change: 1 addition & 0 deletions starsky/starsky.foundation.sync/SyncServices/SyncFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ internal async Task CompareFolderListAndFixMissingFolders(List<string> subPaths,
await _query.AddItemAsync(new FileIndexItem(path)
{
IsDirectory = true,
ImageFormat = ExtensionRolesHelper.ImageFormat.directory,
AddToDatabase = DateTime.UtcNow,
ColorClass = ColorClassParser.Color.None
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using starsky.foundation.database.Models;
using starsky.foundation.database.Query;
using starsky.foundation.platform.Enums;
using starsky.foundation.platform.Helpers;
using starsky.foundation.platform.Interfaces;
using starsky.foundation.platform.JsonConverter;
using starsky.foundation.platform.Models;
Expand Down Expand Up @@ -114,6 +115,7 @@ private async Task<List<FileIndexItem>> SyncTaskInternal(
syncData.Add(new FileIndexItem(_appSettings.FullPathToDatabaseStyle(fullFilePath))
{
IsDirectory = true,
ImageFormat = ExtensionRolesHelper.ImageFormat.directory,
Status = FileIndexItem.ExifStatus.NotFoundSourceMissing
});

Expand Down
4 changes: 2 additions & 2 deletions starsky/starsky/Controllers/DesktopEditorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public DesktopEditorController(IOpenEditorDesktopService openEditorDesktopServic
/// <response code="200">returns a list of items from the database</response>
/// <response code="404">subPath not found in the database</response>
/// <response code="401">User unauthorized</response>
[HttpGet("/api/desktop-editor/open")]
[HttpPost("/api/desktop-editor/open")]
[Produces("application/json")]
[ProducesResponseType(typeof(List<PathImageFormatExistsAppPathModel>), 200)]
[ProducesResponseType(typeof(List<PathImageFormatExistsAppPathModel>), 204)]
Expand Down Expand Up @@ -59,7 +59,7 @@ public async Task<IActionResult> OpenAsync(
/// <returns></returns>
/// <response code="200">bool, true is no confirmation, false is ask confirmation</response>
/// <response code="401">User unauthorized</response>
[HttpGet("/api/desktop-editor/amount-confirmation")]
[HttpPost("/api/desktop-editor/amount-confirmation")]
[Produces("application/json")]
[ProducesResponseType(typeof(bool), 200)]
[ProducesResponseType(401)]
Expand Down
5 changes: 4 additions & 1 deletion starsky/starsky/Controllers/DiskController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public async Task<IActionResult> Mkdir(string f)
continue;
}

await _query.AddItemAsync(new FileIndexItem(subPath) { IsDirectory = true });
await _query.AddItemAsync(new FileIndexItem(subPath)
{
IsDirectory = true, ImageFormat = ExtensionRolesHelper.ImageFormat.directory
});

// add to fs
_iStorage.CreateDirectory(subPath);
Expand Down
Loading

0 comments on commit 7202680

Please sign in to comment.