Skip to content

Commit

Permalink
Detection and Error messages working
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Endres <je@johannes-endres.de>
  • Loading branch information
joendres committed Feb 18, 2020
1 parent 2988b06 commit 0dae5f7
Show file tree
Hide file tree
Showing 23 changed files with 995 additions and 293 deletions.
17 changes: 10 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
image: node:lts

cache:
key: ${CI_COMMIT_REF_SLUG}
key: node_modules
paths:
- node_modules/

before_script:
- npm install node-fetch
- npm install web-ext
- npm install jshint

lint:
stage: test
before_script:
- npm install --loglevel error web-ext
- npm install --loglevel error jshint
script:
# web-ext fails if parameters of different run modes are set
- unset WEB_EXT_API_KEY
Expand All @@ -21,6 +19,9 @@ lint:

pages:
stage: deploy
before_script:
- npm install --loglevel error node-fetch
- npm install --loglevel error web-ext
script:
- node build-tools/build-pages.js
# web-ext fails if parameters of different run modes are set
Expand All @@ -37,9 +38,11 @@ pages:

sign:
stage: deploy
before_script:
- npm install --loglevel error web-ext
script:
# web-ext sign always fails (as documented), so manipulate the return code
- npx web-ext sign --channel=listed --api-url-prefix=https://addons.thunderbird.net/api/v3 ; true
- 'npx web-ext sign --channel=listed --api-url-prefix=https://addons.thunderbird.net/api/v3 || true'
environment:
name: production
url: https://addons.thunderbird.net/de/thunderbird/addon/filelink-nextcloud-owncloud/
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.4.0 2020-02-18
- Close #27: Show Nextcloud/ownCloud flavor and version
- Close #70: Show product name instead of account name
- Close #79: Warn about unsupported version
- Small changes to styling

3.3.0 2020-01-04
- Catalan translation by @josepmanel
- Spanish translation by @josepmanel (Close #3)
Expand Down
9 changes: 6 additions & 3 deletions src/_locales/ca/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"resetButton": {
"message": "Reinciar"
},
"detailSummary": {
"message": "Ajuda"
},
"serverUrl": {
"message": "URL del servidor"
},
Expand Down Expand Up @@ -63,5 +60,11 @@
"content": "$2"
}
}
},
"success": {
"message": "Correcte"
},
"error_0": {
"message": "Error desconegut"
}
}
25 changes: 19 additions & 6 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,25 @@
"full": {
"content": "$2"
}
},
"success": {
"message": "Alles OK"
},
"error_0": {
"message": "Unbekanner Fehler"
}
},
"success": {
"message": "Alles OK"
},
"error_0": {
"message": "Unbekanner Fehler"
},
"error_cloud_unreachable": {
"message": "Keine Verbindung zur Cloud. Prüfe Server-URL und Netzwerkverbindung"
},
"error_no_cloud": {
"message": "Keine kompatible Cloud unter dieser URL"
},
"unsupported_cloud": {
"message": "Datenverlust droht: Veraltete Version von Nextcloud oder ownCloud. Bitte den Cloud-Admin um ein Update"
},
"obsolete_version": {
"description": "This is displayed instead of the icon if the cloud version is not supported, so it should be quite short and contain exactly two lines.",
"message": "Veraltete<br>Cloud"
}
}
13 changes: 13 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,18 @@
},
"error_0": {
"message": "Unknown error"
},
"error_cloud_unreachable": {
"message": "No connection. Check Server URL and network conection."
},
"error_no_cloud": {
"message": "No compatible cloud at this URL."
},
"unsupported_cloud": {
"message": "Obsolete version of Nextcloud or ownCloud. You might loose data. Ask your cloud admin to update."
},
"obsolete_version": {
"description": "This is displayed instead of the icon if the cloud version is not supported, so it should be quite short and contain exactly two lines.",
"message": "Obsolete<br>version"
}
}
9 changes: 6 additions & 3 deletions src/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"resetButton": {
"message": "Reinicia"
},
"detailSummary": {
"message": "Ayuda"
},
"serverUrl": {
"message": "URL del servidor"
},
Expand Down Expand Up @@ -63,5 +60,11 @@
"content": "$2"
}
}
},
"success": {
"message": "Correcto"
},
"error_0": {
"message": "Error desconocido"
}
}
4 changes: 3 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
const ncc = new CloudConnection(accountId);
ncc.load()
.then(() => ncc.updateConfigured())
.then(() => ncc.updateFreeSpaceInfo());
.then(() => ncc.updateFreeSpaceInfo())
.then(() => ncc.updateCloudVersion())
.then(() => ncc.store());
}
});
})();
Expand Down
55 changes: 45 additions & 10 deletions src/lib/cloudconnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,51 @@ class CloudConnection {
* Thunderbirds cloudFileAccount
*/
async updateFreeSpaceInfo() {
this._doApiCall(apiUrlUserInfo + this.username)
.then(data => {
if (data && data.quota) {
browser.cloudFile.updateAccount(this._accountId,
{
spaceRemaining: data.quota.free >= 0 ? data.quota.free : -1,
spaceUsed: data.quota.used > 0 ? data.quota.used : -1,
});
}
});
let data = await this._doApiCall(apiUrlUserInfo + this.username);
if (data && data.quota) {
await browser.cloudFile.updateAccount(this._accountId,
{
spaceRemaining: data.quota.free >= 0 ? data.quota.free : -1,
spaceUsed: data.quota.used > 0 ? data.quota.used : -1,
});
}
}

/**
*
* @param {string} url Base URL of the cloud
* @returns {*} versionstring and type
*/
static async fetchCloudVersion(url) {
let response = await fetch(url + "/status.php");
let status = await response.json();
let major = parseInt(status.versionstring.split(/\./)[0]);
let retval = {
type: null,
versionstring: status.versionstring,
productname: status.productname,
};
if (major >= 16) {
retval.type = "Nextcloud";
} else if (major === 10 && status.needsDbUpgrade !== undefined) {
retval.type = "ownCloud";
} else {
retval.type = "Unsupported";
}
return retval;
}

/**
* Set cloudtype and versionstring of this object
*/
async updateCloudVersion() {
try {
let res = await CloudConnection.fetchCloudVersion(this.serverUrl);
this.versionstring = res.versionstring;
this.cloudtype = res.type;
this.productname = res.productname;
} catch (error) {
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"description": "__MSG_extensionDescription__",
"homepage_url": "https://gitlab.com/joendres/filelink-nextcloud",
"author": "Johannes Endres",
"version": "3.3.0",
"version": "3.4.0",
"icons": {
"48": "icon48.png"
},
Expand Down
3 changes: 0 additions & 3 deletions src/prefspane/Checkbox.svg

This file was deleted.

File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 48 additions & 49 deletions src/prefspane/management.css
Original file line number Diff line number Diff line change
@@ -1,105 +1,104 @@
body.busy * {
cursor: progress;
/* Fix problems in the official css */

body {
font-family: -apple-system, BlinkMacSystemFont, 'helvetica neue', ubuntu, roboto, noto, 'segoe ui', helvetica, arial, sans-serif;
}

* {
box-sizing: border-box;
.input__field, .input__field::placeholder {
font-size: inherit;
}

/* show the turning wheel cursor while the dialog is busy */

body.busy * {
cursor: progress;
}

/* Header elements */

#header::after {
content: "";
clear: both;
display: table;
}

h2 {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin: 0;
}

#logo {
#cloud_info {
float: right;
height: 32px;
text-align: right;
margin-left: 8px;
}

#cloud_info #logo {
height: 36px;
}

/* Free space display */

#freespaceGauge {
margin-top: 4px;
display: flex;
align-items: center;
white-space: nowrap;
visibility: hidden;
}

meter {
width: 100%;
margin-left: .5em;
}

meter:-moz-meter-optimum::-moz-meter-bar {
background: #30e60b;
background: var(--green-50);
}

meter:-moz-meter-sub-optimum::-moz-meter-bar {
background: #ffe900;
background: var(--yellow-50);
}

meter:-moz-meter-sub-sub-optimum::-moz-meter-bar {
background: #ff0039;
background: var(--red-50);
}

meter {
width: 100%;
margin-left: 8px;
height: 16px;
background: #d7d7db;
background: var(--grey-30);
}

/* Message bar */
/* Account form elements */

#msg_container {
/* functional */
/* visibility: hidden; */
z-index: 1;
position: absolute;
top: 9%;
/* Fit into frame */
width: 97%;
input[type=number] {
max-width: 4em;
text-align: right;
}

#msg_container .msg_bar {
margin-bottom: 4px;
#resetButton {
float: right;
}

/* Account form elements */
/* Help button */

input {
width: 100%;
}

input[type=number] {
max-width: 4em;
text-align: right;
padding-right: 0;
.input__label {
/* photon defines it as block which makes it overlap the help button and take its hover event */
display: inline;
}

.helpbutton {
float: right;
margin-right: 2px;
}

.helpbutton p {
visibility: hidden;
width: 50%;
position: absolute;
z-index: 1;
right: 0.2em;
top: 0.5em;
width: 50%;
right: 0;
}

.helpbutton:hover p {
visibility: visible;
}

fieldset {
position: relative;
border: none;
padding-left: 0;
padding-right: 0;
}

#resetButton {
float: right;
}
Loading

0 comments on commit 0dae5f7

Please sign in to comment.